unwasm 0.4.2 → 0.5.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/dist/plugin/index.d.mts +6 -0
- package/dist/plugin/index.mjs +25 -11
- package/package.json +12 -12
package/dist/plugin/index.d.mts
CHANGED
package/dist/plugin/index.mjs
CHANGED
|
@@ -5563,16 +5563,13 @@ async function getWasmImports(asset, _opts) {
|
|
|
5563
5563
|
for (const moduleName of importNames) {
|
|
5564
5564
|
const importNames$1 = asset.imports[moduleName];
|
|
5565
5565
|
const importAlias = pkg.imports?.[moduleName] || pkg.imports?.[`#${moduleName}`];
|
|
5566
|
-
const resolved$1 = importAlias && typeof importAlias === "string" ? importAlias : resolveModulePath(moduleName, {
|
|
5567
|
-
from: asset.id,
|
|
5568
|
-
try: true
|
|
5569
|
-
});
|
|
5566
|
+
const resolved$1 = importAlias && typeof importAlias === "string" ? importAlias : resolveModulePath(moduleName, { from: asset.id });
|
|
5570
5567
|
const importName = "_imports_" + genSafeVariableName(moduleName);
|
|
5571
|
-
|
|
5568
|
+
imports.push(genImport(resolved$1, {
|
|
5572
5569
|
name: "*",
|
|
5573
5570
|
as: importName
|
|
5574
5571
|
}));
|
|
5575
|
-
importsObject[moduleName] = Object.fromEntries(importNames$1.map((name) => [name,
|
|
5572
|
+
importsObject[moduleName] = Object.fromEntries(importNames$1.map((name) => [name, `${importName}[${genString(name)}]`]));
|
|
5576
5573
|
}
|
|
5577
5574
|
return {
|
|
5578
5575
|
code: `${imports.join("\n")}\n\nconst _imports = ${genObjectFromRaw(importsObject)}`,
|
|
@@ -5800,12 +5797,22 @@ function unwasm(opts) {
|
|
|
5800
5797
|
async handler(code, id) {
|
|
5801
5798
|
if (!WASM_ID_RE.test(id)) return;
|
|
5802
5799
|
const buff = Buffer.from(code, "binary");
|
|
5803
|
-
|
|
5800
|
+
let isModule = id.endsWith("?module");
|
|
5804
5801
|
const name = `wasm/${basename(id.split("?")[0], ".wasm")}-${sha1(buff)}.wasm`;
|
|
5805
|
-
|
|
5806
|
-
imports:
|
|
5802
|
+
let parsed = {
|
|
5803
|
+
imports: {},
|
|
5807
5804
|
exports: ["default"]
|
|
5808
|
-
}
|
|
5805
|
+
};
|
|
5806
|
+
if (!isModule) try {
|
|
5807
|
+
parsed = parse(name, buff);
|
|
5808
|
+
} catch (error) {
|
|
5809
|
+
if (!opts.silent) this.warn({
|
|
5810
|
+
id,
|
|
5811
|
+
cause: error,
|
|
5812
|
+
message: "Failed to parse the WebAssembly module; falling back to module mode."
|
|
5813
|
+
});
|
|
5814
|
+
isModule = true;
|
|
5815
|
+
}
|
|
5809
5816
|
const asset = assets[name] = {
|
|
5810
5817
|
name,
|
|
5811
5818
|
id,
|
|
@@ -5814,7 +5821,14 @@ function unwasm(opts) {
|
|
|
5814
5821
|
exports: parsed.exports
|
|
5815
5822
|
};
|
|
5816
5823
|
return {
|
|
5817
|
-
code: isModule ? await getWasmModuleBinding(asset, opts) : await getWasmESMBinding(asset, opts)
|
|
5824
|
+
code: isModule ? await getWasmModuleBinding(asset, opts) : await getWasmESMBinding(asset, opts).catch((error) => {
|
|
5825
|
+
if (!opts.silent) this.warn({
|
|
5826
|
+
id,
|
|
5827
|
+
cause: error,
|
|
5828
|
+
message: "Failed to load the WebAssembly module; falling back to module mode: " + error.message
|
|
5829
|
+
});
|
|
5830
|
+
return getWasmModuleBinding(asset, opts);
|
|
5831
|
+
}),
|
|
5818
5832
|
map: { mappings: "" }
|
|
5819
5833
|
};
|
|
5820
5834
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unwasm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "WebAssembly tools for JavaScript",
|
|
5
5
|
"repository": "unjs/unwasm",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"test:types": "tsc --noEmit --skipLibCheck"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"exsolve": "^1.0.
|
|
32
|
+
"exsolve": "^1.0.8",
|
|
33
33
|
"knitwork": "^1.2.0",
|
|
34
34
|
"magic-string": "^0.30.21",
|
|
35
35
|
"mlly": "^1.8.0",
|
|
@@ -37,27 +37,27 @@
|
|
|
37
37
|
"pkg-types": "^2.3.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@prisma/client": "^6.
|
|
40
|
+
"@prisma/client": "^6.19.0",
|
|
41
41
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
42
|
-
"@types/node": "^24.10.
|
|
43
|
-
"@vitest/coverage-v8": "^4.0.
|
|
42
|
+
"@types/node": "^24.10.1",
|
|
43
|
+
"@vitest/coverage-v8": "^4.0.8",
|
|
44
44
|
"@webassemblyjs/wasm-parser": "^1.14.1",
|
|
45
45
|
"assemblyscript": "^0.28.9",
|
|
46
46
|
"automd": "^0.4.2",
|
|
47
47
|
"changelogen": "^0.6.2",
|
|
48
|
-
"esbuild": "^0.
|
|
48
|
+
"esbuild": "^0.27.0",
|
|
49
49
|
"eslint": "^9.39.1",
|
|
50
50
|
"eslint-config-unjs": "^0.5.0",
|
|
51
51
|
"exsolve": "^1.0.7",
|
|
52
52
|
"jiti": "^2.6.1",
|
|
53
|
-
"miniflare": "^4.
|
|
54
|
-
"obuild": "^0.
|
|
53
|
+
"miniflare": "^4.20251109.0",
|
|
54
|
+
"obuild": "^0.4.1",
|
|
55
55
|
"prettier": "^3.6.2",
|
|
56
|
-
"rollup": "^4.
|
|
56
|
+
"rollup": "^4.53.2",
|
|
57
57
|
"typescript": "^5.9.3",
|
|
58
|
-
"vite": "^7.
|
|
59
|
-
"vitest": "^4.0.
|
|
60
|
-
"wabt": "^1.0.
|
|
58
|
+
"vite": "^7.2.2",
|
|
59
|
+
"vitest": "^4.0.8",
|
|
60
|
+
"wabt": "^1.0.39"
|
|
61
61
|
},
|
|
62
62
|
"resolutions": {
|
|
63
63
|
"@webassemblyjs/helper-wasm-bytecode": "1.14.1",
|