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 11const fs = require ( 'fs' ) ;
22const { buildSync } = require ( 'esbuild' ) ;
3+ const path = require ( 'path/posix' )
34
45const { EXTERNAL_PATH } = process . env ;
56const MINIFY = ! EXTERNAL_PATH ;
@@ -22,7 +23,7 @@ buildSync({
2223 } ,
2324 define : EXTERNAL_PATH ? {
2425 WASM_BINARY : 'undefined' ,
25- EXTERNAL_PATH : `'${ EXTERNAL_PATH } '` ,
26+ EXTERNAL_PATH : `'${ path . join ( EXTERNAL_PATH , 'lib/lexer.wasm' ) } '` ,
2627 } : {
2728 WASM_BINARY : `'${ wasmBuffer . toString ( 'base64' ) } '` ,
2829 EXTERNAL_PATH : 'undefined'
@@ -36,7 +37,7 @@ if (EXTERNAL_PATH) {
3637let lazy;
3738async function init () {
3839 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')));
4041 }
4142 module.exports = lazy;
4243 return lazy.init();
Original file line number Diff line number Diff line change @@ -91,11 +91,7 @@ function copyLE (src, outBuf16) {
9191}
9292
9393const 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 ) ;
9995} ) ) || ( async ( ) => {
10096 const binary = WASM_BINARY
10197 if ( typeof window !== "undefined" && typeof atob === "function" ) {
You can’t perform that action at this time.
0 commit comments