unwasm 0.4.0 → 0.4.1

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.
@@ -19,9 +19,8 @@ interface UnwasmPluginOptions {
19
19
  }
20
20
  //#endregion
21
21
  //#region src/plugin/index.d.ts
22
- declare const rollup: (opts: UnwasmPluginOptions) => Plugin;
23
- declare const _default: {
24
- rollup: (opts: UnwasmPluginOptions) => Plugin;
25
- };
22
+ declare function unwasm(opts: UnwasmPluginOptions): Plugin;
23
+ /** @deprecated use unwasm export */
24
+ declare const rollup: typeof unwasm;
26
25
  //#endregion
27
- export { type UnwasmPluginOptions, _default as default, rollup };
26
+ export { type UnwasmPluginOptions, rollup, unwasm };
@@ -1,7 +1,6 @@
1
1
  import { existsSync, promises } from "node:fs";
2
2
  import { basename } from "pathe";
3
3
  import MagicString from "magic-string";
4
- import { createUnplugin } from "unplugin";
5
4
  import { createHash } from "node:crypto";
6
5
  import { genImport, genObjectFromRaw, genSafeVariableName, genString } from "knitwork";
7
6
  import { resolveModulePath } from "exsolve";
@@ -5733,7 +5732,7 @@ export function createLazyWasmModule(_instantiator) {
5733
5732
  //#endregion
5734
5733
  //#region src/plugin/index.ts
5735
5734
  const WASM_ID_RE = /\.wasm\??.*$/i;
5736
- const unplugin = createUnplugin((opts) => {
5735
+ function unwasm(opts) {
5737
5736
  const assets = Object.create(null);
5738
5737
  const _parseCache = Object.create(null);
5739
5738
  function parse(name, source) {
@@ -5760,8 +5759,9 @@ const unplugin = createUnplugin((opts) => {
5760
5759
  }
5761
5760
  return {
5762
5761
  name: "unwasm",
5763
- rollup: {
5764
- async resolveId(id, importer) {
5762
+ resolveId: {
5763
+ order: "pre",
5764
+ async handler(id, importer) {
5765
5765
  if (id === UMWASM_HELPERS_ID) return id;
5766
5766
  if (id.startsWith(UNWASM_EXTERNAL_PREFIX)) return {
5767
5767
  id,
@@ -5775,15 +5775,15 @@ const unplugin = createUnplugin((opts) => {
5775
5775
  moduleSideEffects: false
5776
5776
  };
5777
5777
  }
5778
- },
5779
- generateBundle() {
5780
- if (opts.esmImport) for (const asset of Object.values(assets)) this.emitFile({
5781
- type: "asset",
5782
- source: asset.source,
5783
- fileName: asset.name
5784
- });
5785
5778
  }
5786
5779
  },
5780
+ generateBundle() {
5781
+ if (opts.esmImport) for (const asset of Object.values(assets)) this.emitFile({
5782
+ type: "asset",
5783
+ source: asset.source,
5784
+ fileName: asset.name
5785
+ });
5786
+ },
5787
5787
  async load(id) {
5788
5788
  if (id === UMWASM_HELPERS_ID) return getPluginUtils();
5789
5789
  if (!WASM_ID_RE.test(id)) return;
@@ -5843,9 +5843,9 @@ const unplugin = createUnplugin((opts) => {
5843
5843
  };
5844
5844
  }
5845
5845
  };
5846
- });
5847
- const rollup = unplugin.rollup;
5848
- var plugin_default = { rollup };
5846
+ }
5847
+ /** @deprecated use unwasm export */
5848
+ const rollup = unwasm;
5849
5849
 
5850
5850
  //#endregion
5851
- export { plugin_default as default, rollup };
5851
+ export { rollup, unwasm };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unwasm",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
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 && changelogen --release && npm publish && git push --follow-tags",
27
+ "release": "pnpm test && pnpm build && changelogen --release --publish",
28
28
  "test": "pnpm lint && pnpm test:types && vitest run --coverage",
29
29
  "test:types": "tsc --noEmit --skipLibCheck"
30
30
  },