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