unwasm 0.3.3 → 0.3.4
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.cjs +4 -4
- package/dist/plugin.mjs +4 -4
- package/package.json +1 -1
package/dist/plugin.cjs
CHANGED
|
@@ -16,6 +16,7 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
16
16
|
const MagicString__default = /*#__PURE__*/_interopDefaultCompat(MagicString);
|
|
17
17
|
|
|
18
18
|
const UNWASM_EXTERNAL_PREFIX = "\0unwasm:external:";
|
|
19
|
+
const UNWASM_EXTERNAL_RE = /(\0|\\0)unwasm:external:([^"']+)/gu;
|
|
19
20
|
const UMWASM_HELPERS_ID = "\0unwasm:helpers";
|
|
20
21
|
function sha1(source) {
|
|
21
22
|
return node_crypto.createHash("sha1").update(source).digest("hex").slice(0, 16);
|
|
@@ -271,7 +272,7 @@ const unplugin = unplugin$1.createUnplugin((opts) => {
|
|
|
271
272
|
if (!opts.esmImport) {
|
|
272
273
|
return;
|
|
273
274
|
}
|
|
274
|
-
if (!(chunk.moduleIds.some((id) => id.endsWith(".wasm")) || chunk.imports.some((id) => id.endsWith(".wasm")))
|
|
275
|
+
if (!(chunk.moduleIds.some((id) => id.endsWith(".wasm")) || chunk.imports.some((id) => id.endsWith(".wasm")))) {
|
|
275
276
|
return;
|
|
276
277
|
}
|
|
277
278
|
const s = new MagicString__default(code);
|
|
@@ -290,9 +291,8 @@ const unplugin = unplugin$1.createUnplugin((opts) => {
|
|
|
290
291
|
asset
|
|
291
292
|
};
|
|
292
293
|
};
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
const resolved = resolveImport(match[1]);
|
|
294
|
+
for (const match of code.matchAll(UNWASM_EXTERNAL_RE)) {
|
|
295
|
+
const resolved = resolveImport(match[2]);
|
|
296
296
|
const index = match.index;
|
|
297
297
|
const len = match[0].length;
|
|
298
298
|
if (!resolved || !index) {
|
package/dist/plugin.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { parseWasm } from './tools.mjs';
|
|
|
8
8
|
import '@webassemblyjs/wasm-parser';
|
|
9
9
|
|
|
10
10
|
const UNWASM_EXTERNAL_PREFIX = "\0unwasm:external:";
|
|
11
|
+
const UNWASM_EXTERNAL_RE = /(\0|\\0)unwasm:external:([^"']+)/gu;
|
|
11
12
|
const UMWASM_HELPERS_ID = "\0unwasm:helpers";
|
|
12
13
|
function sha1(source) {
|
|
13
14
|
return createHash("sha1").update(source).digest("hex").slice(0, 16);
|
|
@@ -263,7 +264,7 @@ const unplugin = createUnplugin((opts) => {
|
|
|
263
264
|
if (!opts.esmImport) {
|
|
264
265
|
return;
|
|
265
266
|
}
|
|
266
|
-
if (!(chunk.moduleIds.some((id) => id.endsWith(".wasm")) || chunk.imports.some((id) => id.endsWith(".wasm")))
|
|
267
|
+
if (!(chunk.moduleIds.some((id) => id.endsWith(".wasm")) || chunk.imports.some((id) => id.endsWith(".wasm")))) {
|
|
267
268
|
return;
|
|
268
269
|
}
|
|
269
270
|
const s = new MagicString(code);
|
|
@@ -282,9 +283,8 @@ const unplugin = createUnplugin((opts) => {
|
|
|
282
283
|
asset
|
|
283
284
|
};
|
|
284
285
|
};
|
|
285
|
-
const
|
|
286
|
-
|
|
287
|
-
const resolved = resolveImport(match[1]);
|
|
286
|
+
for (const match of code.matchAll(UNWASM_EXTERNAL_RE)) {
|
|
287
|
+
const resolved = resolveImport(match[2]);
|
|
288
288
|
const index = match.index;
|
|
289
289
|
const len = match[0].length;
|
|
290
290
|
if (!resolved || !index) {
|