From a5a71223157f3a6f57d9ad9ca52bbd4664f7b955 Mon Sep 17 00:00:00 2001 From: Kevin Deng Date: Fri, 12 Jun 2026 18:59:02 +0900 Subject: [PATCH] chore: update snapshot --- tests/__snapshots__/init/browser.snap | 22 ++++-------- tests/__snapshots__/init/neutral.snap | 25 ++++--------- tests/__snapshots__/init/node.snap | 20 +++++------ tests/__snapshots__/rolldown.test.ts.snap | 44 +++++++++-------------- 4 files changed, 37 insertions(+), 74 deletions(-) diff --git a/tests/__snapshots__/init/browser.snap b/tests/__snapshots__/init/browser.snap index 26b53a4..64dc46a 100644 --- a/tests/__snapshots__/init/browser.snap +++ b/tests/__snapshots__/init/browser.snap @@ -3,37 +3,27 @@ // init.js //#region \0wasm-helpers.js function loadWasmModule(sync, filepath, src, imports) { - function instantiate(source, imports$1, stream) { - const instantiate$1 = stream ? WebAssembly.instantiateStreaming : WebAssembly.instantiate; - return instantiate$1(source, imports$1).then(({ instance }) => instance); + function instantiate(source, imports, stream) { + return (stream ? WebAssembly.instantiateStreaming : WebAssembly.instantiate)(source, imports).then(({ instance }) => instance); } let buf = null; - if (filepath) { - return instantiate(fetch(new URL(filepath, import.meta.url)), imports, true); - } + if (filepath) return instantiate(fetch(new URL(filepath, import.meta.url)), imports, true); const raw = globalThis.atob(src); const len = raw.length; buf = new Uint8Array(new ArrayBuffer(len)); - for (let i = 0; i < len; i++) { - buf[i] = raw.charCodeAt(i); - } + for (let i = 0; i < len; i++) buf[i] = raw.charCodeAt(i); if (sync) { const mod = new WebAssembly.Module(buf); return new WebAssembly.Instance(mod, imports); - } else { - return instantiate(buf, imports); - } + } else return instantiate(buf, imports); } - //#endregion //#region tests/fixtures/add.wasm?init function __wasm_init(imports) { return loadWasmModule(false, "assets/b62665e669ab1545.wasm", null, imports); } - //#endregion //#region tests/fixtures/init.js var init_default = __wasm_init; - //#endregion -export { init_default as default }; \ No newline at end of file +export { init_default as default }; diff --git a/tests/__snapshots__/init/neutral.snap b/tests/__snapshots__/init/neutral.snap index d1062d2..7d4c297 100644 --- a/tests/__snapshots__/init/neutral.snap +++ b/tests/__snapshots__/init/neutral.snap @@ -3,19 +3,15 @@ // init.js //#region \0wasm-helpers.js function loadWasmModule(sync, filepath, src, imports) { - function instantiate(source, imports$1, stream) { - const instantiate$1 = stream ? WebAssembly.instantiateStreaming : WebAssembly.instantiate; - return instantiate$1(source, imports$1).then(({ instance }) => instance); + function instantiate(source, imports, stream) { + return (stream ? WebAssembly.instantiateStreaming : WebAssembly.instantiate)(source, imports).then(({ instance }) => instance); } let buf = null; const isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null; if (filepath && isNode) { const { readFile } = process.getBuiltinModule("fs/promises"); - const path = process.getBuiltinModule("path"); - return readFile(path.resolve(import.meta.dirname, filepath)).then((buffer) => instantiate(buffer, imports)); - } else if (filepath) { - return instantiate(fetch(new URL(filepath, import.meta.url)), imports, true); - } + return readFile(process.getBuiltinModule("path").resolve(import.meta.dirname, filepath)).then((buffer) => instantiate(buffer, imports)); + } else if (filepath) return instantiate(fetch(new URL(filepath, import.meta.url)), imports, true); if (isNode) { const { Buffer } = process.getBuiltinModule("buffer"); buf = Buffer.from(src, "base64"); @@ -23,27 +19,20 @@ function loadWasmModule(sync, filepath, src, imports) { const raw = globalThis.atob(src); const len = raw.length; buf = new Uint8Array(new ArrayBuffer(len)); - for (let i = 0; i < len; i++) { - buf[i] = raw.charCodeAt(i); - } + for (let i = 0; i < len; i++) buf[i] = raw.charCodeAt(i); } if (sync) { const mod = new WebAssembly.Module(buf); return new WebAssembly.Instance(mod, imports); - } else { - return instantiate(buf, imports); - } + } else return instantiate(buf, imports); } - //#endregion //#region tests/fixtures/add.wasm?init function __wasm_init(imports) { return loadWasmModule(false, "assets/b62665e669ab1545.wasm", null, imports); } - //#endregion //#region tests/fixtures/init.js var init_default = __wasm_init; - //#endregion -export { init_default as default }; \ No newline at end of file +export { init_default as default }; diff --git a/tests/__snapshots__/init/node.snap b/tests/__snapshots__/init/node.snap index 39b1296..277a9ed 100644 --- a/tests/__snapshots__/init/node.snap +++ b/tests/__snapshots__/init/node.snap @@ -1,37 +1,33 @@ // assets/b62665e669ab1545.wasm [BINARY] // init.js +import "node:module"; +import.meta.url; +//#endregion //#region \0wasm-helpers.js function loadWasmModule(sync, filepath, src, imports) { - function instantiate(source, imports$1, stream) { - const instantiate$1 = stream ? WebAssembly.instantiateStreaming : WebAssembly.instantiate; - return instantiate$1(source, imports$1).then(({ instance }) => instance); + function instantiate(source, imports, stream) { + return (stream ? WebAssembly.instantiateStreaming : WebAssembly.instantiate)(source, imports).then(({ instance }) => instance); } let buf = null; if (filepath) { const { readFile } = process.getBuiltinModule("fs/promises"); - const path = process.getBuiltinModule("path"); - return readFile(path.resolve(import.meta.dirname, filepath)).then((buffer) => instantiate(buffer, imports)); + return readFile(process.getBuiltinModule("path").resolve(import.meta.dirname, filepath)).then((buffer) => instantiate(buffer, imports)); } const { Buffer } = process.getBuiltinModule("buffer"); buf = Buffer.from(src, "base64"); if (sync) { const mod = new WebAssembly.Module(buf); return new WebAssembly.Instance(mod, imports); - } else { - return instantiate(buf, imports); - } + } else return instantiate(buf, imports); } - //#endregion //#region tests/fixtures/add.wasm?init function __wasm_init(imports) { return loadWasmModule(false, "assets/b62665e669ab1545.wasm", null, imports); } - //#endregion //#region tests/fixtures/init.js var init_default = __wasm_init; - //#endregion -export { init_default as default }; \ No newline at end of file +export { init_default as default }; diff --git a/tests/__snapshots__/rolldown.test.ts.snap b/tests/__snapshots__/rolldown.test.ts.snap index 7ebda95..327db37 100644 --- a/tests/__snapshots__/rolldown.test.ts.snap +++ b/tests/__snapshots__/rolldown.test.ts.snap @@ -2,58 +2,47 @@ exports[`rolldown > init-sync.js 1`] = ` "// init-sync.js -import { loadWasmModule } from "\\u0000wasm-helpers.js"; - +import { loadWasmModule } from "\\0wasm-helpers.js"; //#region tests/fixtures/add.wasm?init&sync function __wasm_init(imports) { return loadWasmModule(true, null, "AGFzbQEAAAABh4CAgAABYAJ/fwF/A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mFmMjNiKQ==", imports); } - //#endregion //#region tests/fixtures/init-sync.js var init_sync_default = __wasm_init; - //#endregion -export { init_sync_default as default };" +export { init_sync_default as default }; +" `; exports[`rolldown > url.js 1`] = ` "// b62665e669ab1545.wasm [BINARY] // url.js -//#region tests/fixtures/add.wasm?url -var add_default = "b62665e669ab1545.wasm"; - //#endregion //#region tests/fixtures/url.js -var url_default = add_default; - +var url_default = "b62665e669ab1545.wasm"; //#endregion -export { url_default as default };" +export { url_default as default }; +" `; exports[`rolldown > wasm-module.js 1`] = ` "// b62665e669ab1545.wasm [BINARY] // wasm-module.js -import { loadWasmModule } from "\\u0000wasm-helpers.js"; - -//#region rolldown:runtime +import { loadWasmModule } from "\\0wasm-helpers.js"; +//#region \\0rolldown/runtime.js var __defProp = Object.defineProperty; -var __exportAll = (all, symbols) => { +var __exportAll = (all, no_symbols) => { let target = {}; - for (var name in all) { - __defProp(target, name, { - get: all[name], - enumerable: true - }); - } - if (symbols) { - __defProp(target, Symbol.toStringTag, { value: "Module" }); - } + for (var name in all) __defProp(target, name, { + get: all[name], + enumerable: true + }); + if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" }); return target; }; - //#endregion //#region tests/fixtures/add.wasm var add_exports = /* @__PURE__ */ __exportAll({ @@ -66,11 +55,10 @@ function __wasm_init(imports) { const instance = await __wasm_init({}); const memory = instance.exports.memory; const add = instance.exports.add; - //#endregion //#region tests/fixtures/wasm-module.js var wasm_module_default = add_exports; - //#endregion -export { wasm_module_default as default };" +export { wasm_module_default as default }; +" `; -- 2.51.2