unwasm 0.3.11 → 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.
package/README.md CHANGED
@@ -96,13 +96,13 @@ npm install unwasm
96
96
  yarn add unwasm
97
97
 
98
98
  # pnpm
99
- pnpm install unwasm
99
+ pnpm add unwasm
100
100
 
101
101
  # bun
102
102
  bun install unwasm
103
103
 
104
104
  # deno
105
- deno install unwasm
105
+ deno install npm:unwasm
106
106
  ```
107
107
 
108
108
  <!-- /automd -->
@@ -113,7 +113,7 @@ deno install unwasm
113
113
 
114
114
  ```js
115
115
  // rollup.config.js
116
- import { rollup as unwasm } from "unwasm/plugin";
116
+ import { unwasm } from "unwasm/plugin";
117
117
 
118
118
  export default {
119
119
  plugins: [
@@ -200,6 +200,24 @@ To hint to the bundler how to resolve imports needed by the `.wasm` file, you ne
200
200
 
201
201
  **Note:** The imports can also be prefixed with `#` like `#env` if you like to respect Node.js conventions.
202
202
 
203
+ ## Wasm ESM Imports
204
+
205
+ unwasm also supports importing from other ES modules in Wasm (read more: [ESM Integration Spec](https://github.com/WebAssembly/esm-integration/tree/main/proposals/esm-integration)).
206
+
207
+ **Example:**
208
+
209
+ ```wast
210
+ (module
211
+ (import "./add-esmi-deps.mjs" "getValue" (func $getValue (result i32)))
212
+
213
+ (func (export "addImported") (param $a i32) (result i32)
214
+ local.get $a
215
+ call $getValue
216
+ i32.add
217
+ )
218
+ )
219
+ ```
220
+
203
221
  ## Contribution
204
222
 
205
223
  <details>
@@ -0,0 +1,26 @@
1
+ import { Plugin } from "rollup";
2
+
3
+ //#region src/plugin/shared.d.ts
4
+ interface UnwasmPluginOptions {
5
+ /**
6
+ * Directly import the `.wasm` files instead of bundling as base64 string.
7
+ *
8
+ * @default false
9
+ */
10
+ esmImport?: boolean;
11
+ /**
12
+ * Avoid using top level await and always use a proxy.
13
+ *
14
+ * Useful for compatibility with environments that don't support top level await.
15
+ *
16
+ * @default false
17
+ */
18
+ lazy?: boolean;
19
+ }
20
+ //#endregion
21
+ //#region src/plugin/index.d.ts
22
+ declare function unwasm(opts: UnwasmPluginOptions): Plugin;
23
+ /** @deprecated use unwasm export */
24
+ declare const rollup: typeof unwasm;
25
+ //#endregion
26
+ export { type UnwasmPluginOptions, rollup, unwasm };