unwasm 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/plugin/index.mjs +33 -27
- package/package.json +2 -2
package/dist/plugin/index.mjs
CHANGED
|
@@ -5784,34 +5784,40 @@ function unwasm(opts) {
|
|
|
5784
5784
|
fileName: asset.name
|
|
5785
5785
|
});
|
|
5786
5786
|
},
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5787
|
+
load: {
|
|
5788
|
+
order: "pre",
|
|
5789
|
+
async handler(id) {
|
|
5790
|
+
if (id === UMWASM_HELPERS_ID) return getPluginUtils();
|
|
5791
|
+
if (!WASM_ID_RE.test(id)) return;
|
|
5792
|
+
const idPath = id.split("?")[0];
|
|
5793
|
+
if (!existsSync(idPath)) return;
|
|
5794
|
+
this.addWatchFile(idPath);
|
|
5795
|
+
return (await promises.readFile(idPath)).toString("binary");
|
|
5796
|
+
}
|
|
5794
5797
|
},
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
name,
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5798
|
+
transform: {
|
|
5799
|
+
order: "pre",
|
|
5800
|
+
async handler(code, id) {
|
|
5801
|
+
if (!WASM_ID_RE.test(id)) return;
|
|
5802
|
+
const buff = Buffer.from(code, "binary");
|
|
5803
|
+
const isModule = id.endsWith("?module");
|
|
5804
|
+
const name = `wasm/${basename(id.split("?")[0], ".wasm")}-${sha1(buff)}.wasm`;
|
|
5805
|
+
const parsed = isModule ? {
|
|
5806
|
+
imports: [],
|
|
5807
|
+
exports: ["default"]
|
|
5808
|
+
} : parse(name, buff);
|
|
5809
|
+
const asset = assets[name] = {
|
|
5810
|
+
name,
|
|
5811
|
+
id,
|
|
5812
|
+
source: buff,
|
|
5813
|
+
imports: parsed.imports,
|
|
5814
|
+
exports: parsed.exports
|
|
5815
|
+
};
|
|
5816
|
+
return {
|
|
5817
|
+
code: isModule ? await getWasmModuleBinding(asset, opts) : await getWasmESMBinding(asset, opts),
|
|
5818
|
+
map: { mappings: "" }
|
|
5819
|
+
};
|
|
5820
|
+
}
|
|
5815
5821
|
},
|
|
5816
5822
|
renderChunk(code, chunk) {
|
|
5817
5823
|
if (!opts.esmImport) return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unwasm",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "WebAssembly tools for JavaScript",
|
|
5
5
|
"repository": "unjs/unwasm",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"lint": "eslint --cache . && prettier -c src test",
|
|
25
25
|
"lint:fix": "eslint --cache . --fix && prettier -c src test -w",
|
|
26
26
|
"prepack": "pnpm build",
|
|
27
|
-
"release": "pnpm test && pnpm build && changelogen --release --publish",
|
|
27
|
+
"release": "pnpm test && pnpm build && changelogen --release --push --publish",
|
|
28
28
|
"test": "pnpm lint && pnpm test:types && vitest run --coverage",
|
|
29
29
|
"test:types": "tsc --noEmit --skipLibCheck"
|
|
30
30
|
},
|