File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
packages/core/typescript/itk-wasm/src/pipeline/internal Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 1
1
import fs from 'fs'
2
2
import EmscriptenModule from '../itk-wasm-emscripten-module.js'
3
3
import { pathToFileURL } from 'url'
4
+ import { ZSTDDecoder } from '@thewtex/zstddec'
4
5
5
- async function loadEmscriptenModuleNode (
6
+ const zstdDecoder = new ZSTDDecoder ( )
7
+ await zstdDecoder . init ( )
8
+
9
+ async function loadEmscriptenModuleNode (
6
10
modulePath : string
7
11
) : Promise < EmscriptenModule > {
8
12
let modulePrefix = modulePath
@@ -12,8 +16,12 @@ async function loadEmscriptenModuleNode (
12
16
if ( modulePath . endsWith ( '.wasm' ) ) {
13
17
modulePrefix = modulePath . substring ( 0 , modulePath . length - 5 )
14
18
}
15
- const wasmBinaryPath = `${ modulePrefix } .wasm`
16
- const wasmBinary = fs . readFileSync ( wasmBinaryPath )
19
+ if ( modulePath . endsWith ( '.wasm.zst' ) ) {
20
+ modulePrefix = modulePath . substring ( 0 , modulePath . length - 9 )
21
+ }
22
+ const compressedWasmBinaryPath = `${ modulePrefix } .wasm.zst`
23
+ const compressedWasmBinary = fs . readFileSync ( compressedWasmBinaryPath )
24
+ const wasmBinary = zstdDecoder . decode ( new Uint8Array ( compressedWasmBinary ) )
17
25
const fullModulePath = pathToFileURL ( `${ modulePrefix } .js` ) . href
18
26
const result = await import (
19
27
/* webpackIgnore: true */ /* @vite -ignore */ fullModulePath
You can’t perform that action at this time.
0 commit comments