unwasm 0.3.11 → 0.4.0
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 +21 -3
- package/dist/plugin/index.d.mts +27 -0
- package/dist/plugin/index.mjs +5851 -0
- package/dist/tools/index.d.mts +28 -0
- package/dist/tools/index.mjs +5535 -0
- package/examples/add-esmi-deps.mjs +3 -0
- package/examples/add-esmi.wasm +0 -0
- package/examples/build.mjs +14 -0
- package/package.json +25 -43
- package/dist/plugin.cjs +0 -377
- package/dist/plugin.d.cts +0 -28
- package/dist/plugin.d.mts +0 -26
- package/dist/plugin.d.ts +0 -28
- package/dist/plugin.mjs +0 -368
- package/dist/tools.cjs +0 -6598
- package/dist/tools.d.cts +0 -28
- package/dist/tools.d.mts +0 -28
- package/dist/tools.d.ts +0 -28
- package/dist/tools.mjs +0 -6596
- package/plugin.d.ts +0 -3
package/README.md
CHANGED
|
@@ -96,13 +96,13 @@ npm install unwasm
|
|
|
96
96
|
yarn add unwasm
|
|
97
97
|
|
|
98
98
|
# pnpm
|
|
99
|
-
pnpm
|
|
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 {
|
|
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,27 @@
|
|
|
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 const rollup: (opts: UnwasmPluginOptions) => Plugin;
|
|
23
|
+
declare const _default: {
|
|
24
|
+
rollup: (opts: UnwasmPluginOptions) => Plugin;
|
|
25
|
+
};
|
|
26
|
+
//#endregion
|
|
27
|
+
export { type UnwasmPluginOptions, _default as default, rollup };
|