Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed May 18, 2023
1 parent 9c68983 commit 4efd83b
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/core/integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"sugarss": "^3.0.3",
"tailwindcss": "^3.0.2",
"tempy": "^0.3.0",
"wasm-sourcemap": "^1.0.0",
"ws": "^7.0.0"
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "@parcel/config-default",
"transformers": {
"*.wasm": ["parcel-transformer-test"]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log(new URL("index.wasm", import.meta.url))
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
19 changes: 19 additions & 0 deletions packages/core/integration-tests/test/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
overlayFS,
run,
} from '@parcel/test-utils';
import * as wasmmap from 'wasm-sourcemap';
import {relativePath} from '@parcel/utils';

describe('plugin', function () {
it("continue transformer pipeline on type change that doesn't change the pipeline", async function () {
Expand Down Expand Up @@ -310,4 +312,21 @@ parcel-transformer-b`,
await assertAsset('const replaced = 1;');
await assertAsset('const replaced = 2;');
});

it('should output sourcemaps when packaging Wasm', async () => {
let b = await bundle(
path.join(__dirname, '/integration/wasm-sourcemap-transformer/index.js'),
);
let wasmPath = nullthrows(
b.getBundles().find(b => b.type === 'wasm'),
).filePath;
let mapPath = wasmPath + '.map';
assert(await fs.exists(mapPath));

let wasm = await fs.readFile(wasmPath);
assert.equal(
wasmmap.GetSourceMapURL(wasm),
relativePath(distDir, mapPath, false),
);
});
});
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14120,6 +14120,11 @@ w3c-xmlserializer@^3.0.0:
dependencies:
xml-name-validator "^4.0.0"

wasm-sourcemap@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/wasm-sourcemap/-/wasm-sourcemap-1.0.0.tgz#c9aa3a2105eb2f15b838687b5aebeac4e0c9a07c"
integrity sha512-IiOoUHnsI6bVVbs8Q+JO6cj7KtxwGiiS5nJGDbZXfj6srbIDzjjbZk9WMAusvynTzzlPlMgJhb/4SGz92ZgXsA==

wcwidth@^1.0.0, wcwidth@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8"
Expand Down

0 comments on commit 4efd83b

Please sign in to comment.