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.
@@ -5784,34 +5784,40 @@ function unwasm(opts) {
5784
5784
  fileName: asset.name
5785
5785
  });
5786
5786
  },
5787
- async load(id) {
5788
- if (id === UMWASM_HELPERS_ID) return getPluginUtils();
5789
- if (!WASM_ID_RE.test(id)) return;
5790
- const idPath = id.split("?")[0];
5791
- if (!existsSync(idPath)) return;
5792
- this.addWatchFile(idPath);
5793
- return (await promises.readFile(idPath)).toString("binary");
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
- async transform(code, id) {
5796
- if (!WASM_ID_RE.test(id)) return;
5797
- const buff = Buffer.from(code, "binary");
5798
- const isModule = id.endsWith("?module");
5799
- const name = `wasm/${basename(id.split("?")[0], ".wasm")}-${sha1(buff)}.wasm`;
5800
- const parsed = isModule ? {
5801
- imports: [],
5802
- exports: ["default"]
5803
- } : parse(name, buff);
5804
- const asset = assets[name] = {
5805
- name,
5806
- id,
5807
- source: buff,
5808
- imports: parsed.imports,
5809
- exports: parsed.exports
5810
- };
5811
- return {
5812
- code: isModule ? await getWasmModuleBinding(asset, opts) : await getWasmESMBinding(asset, opts),
5813
- map: { mappings: "" }
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.1",
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
  },