Skip to content

Commit

Permalink
fix: Use pathToFileURL for loading js module on Windows
Browse files Browse the repository at this point in the history
Required for loading a module on Windows in Node 18.
  • Loading branch information
thewtex committed May 7, 2023
1 parent ec03462 commit 01b9c95
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/internal/loadEmscriptenModuleNode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from 'fs'
import EmscriptenModule from '../ITKWasmEmscriptenModule.js'
import { pathToFileURL } from 'url'

async function loadEmscriptenModuleNode (modulePath: string): Promise<EmscriptenModule> {
let modulePrefix = modulePath
Expand All @@ -11,7 +12,7 @@ async function loadEmscriptenModuleNode (modulePath: string): Promise<Emscripten
}
const wasmBinaryPath = `${modulePrefix}.wasm`
const wasmBinary = fs.readFileSync(wasmBinaryPath)
const fullModulePath = `${modulePrefix}.js`
const fullModulePath = pathToFileURL(`${modulePrefix}.js`).href
const result = await import(/* webpackIgnore: true */ /* @vite-ignore */ fullModulePath)
const instantiated = result.default({ wasmBinary }) as EmscriptenModule
return instantiated
Expand Down

0 comments on commit 01b9c95

Please sign in to comment.