Compare commits
No commits in common. "3cdb14fc96f2e5cea7fd5f981dab4a12e4566447" and "2cca297bcc2d28bc11ff7c3e67c15f0895238333" have entirely different histories.
3cdb14fc96
...
2cca297bcc
@ -92,6 +92,9 @@ async function main() {
|
|||||||
// Ask rollup to build bundles.
|
// Ask rollup to build bundles.
|
||||||
await run(['pnpm', 'build:bundle']);
|
await run(['pnpm', 'build:bundle']);
|
||||||
await run(['pnpm', 'exec', 'prettier', '--ignore-path', '', '-w', 'dist/loader.d.ts']);
|
await run(['pnpm', 'exec', 'prettier', '--ignore-path', '', '-w', 'dist/loader.d.ts']);
|
||||||
|
await replaceFileByRegex(path.join(wasmDistDir, 'loader.mjs'), [
|
||||||
|
['fetch(filepath)', 'fetch(new URL(filepath, import.meta.url))'],
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@unlock-music/crypto",
|
"name": "@unlock-music/crypto",
|
||||||
"version": "0.0.0-alpha.6",
|
"version": "0.0.0-alpha.5",
|
||||||
"description": "Project Unlock Music: 加解密支持库",
|
"description": "Project Unlock Music: 加解密支持库",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "node build.js",
|
"build": "node build.js",
|
||||||
|
@ -8,15 +8,14 @@ function loader() {
|
|||||||
initSync({ module: umWasm() });
|
initSync({ module: umWasm() });
|
||||||
return Promise.resolve(true);
|
return Promise.resolve(true);
|
||||||
} else {
|
} else {
|
||||||
const url = new URL('um_wasm_bg.wasm', import.meta.url);
|
/** @type {Promise<Buffer>|undefined} */
|
||||||
const wasm =
|
let wasm = undefined;
|
||||||
url.protocol === 'file:'
|
if (typeof document === 'undefined') {
|
||||||
? import('node:f' + 's/promises')
|
// node
|
||||||
.then((fs) => fs.readFile(url))
|
wasm = import('node:f' + 's/promises').then((fs) =>
|
||||||
.catch((err) => {
|
fs.readFile(new URL('../pkg/um_wasm_bg.wasm', import.meta.url)),
|
||||||
console.log('read wasm failed', err);
|
);
|
||||||
})
|
}
|
||||||
: undefined;
|
|
||||||
return __wbg_init({ module_or_path: wasm }).then(() => true);
|
return __wbg_init({ module_or_path: wasm }).then(() => true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user