File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 1
1
const fs = require ( 'fs' ) ;
2
2
const { buildSync } = require ( 'esbuild' ) ;
3
- const path = require ( 'path/posix' )
4
3
5
4
const { EXTERNAL_PATH } = process . env ;
6
5
const MINIFY = ! EXTERNAL_PATH ;
@@ -23,7 +22,7 @@ buildSync({
23
22
} ,
24
23
define : EXTERNAL_PATH ? {
25
24
WASM_BINARY : 'undefined' ,
26
- EXTERNAL_PATH : `'${ path . join ( EXTERNAL_PATH , 'lib/lexer.wasm' ) } '` ,
25
+ EXTERNAL_PATH : `'${ EXTERNAL_PATH } '` ,
27
26
} : {
28
27
WASM_BINARY : `'${ wasmBuffer . toString ( 'base64' ) } '` ,
29
28
EXTERNAL_PATH : 'undefined'
@@ -37,7 +36,7 @@ if (EXTERNAL_PATH) {
37
36
let lazy;
38
37
async function init () {
39
38
if (!lazy) {
40
- lazy = await import(require('node:url').pathToFileURL(require('node:module').createRequire('${ path . join ( EXTERNAL_PATH , ' dist/lexer.js' ) } ').resolve('./lexer.mjs')));
39
+ lazy = await import(require('node:url').pathToFileURL(require('node:module').createRequire('${ EXTERNAL_PATH } / dist/lexer.js').resolve('./lexer.mjs')));
41
40
}
42
41
module.exports = lazy;
43
42
return lazy.init();
Original file line number Diff line number Diff line change @@ -91,7 +91,11 @@ function copyLE (src, outBuf16) {
91
91
}
92
92
93
93
const loadWasm = ( typeof EXTERNAL_PATH === "string" && ( async ( ) => {
94
- return ( await import ( 'node:fs/promises' ) ) . readFile ( EXTERNAL_PATH ) ;
94
+ const { readFile } = await import ( 'node:fs/promises' ) ;
95
+ const { fileURLToPath } = await import ( 'node:url' ) ;
96
+ return readFile ( fileURLToPath (
97
+ import . meta. resolve ( "undefined/dist/lexer.wasm" )
98
+ ) ) ;
95
99
} ) ) || ( async ( ) => {
96
100
const binary = WASM_BINARY
97
101
if ( typeof window !== "undefined" && typeof atob === "function" ) {
You can’t perform that action at this time.
0 commit comments