This repository was archived by the owner on Jul 6, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-19
lines changed Expand file tree Collapse file tree 2 files changed +16
-19
lines changed Original file line number Diff line number Diff line change 1
1
import type { Config } from 'aleph/types'
2
- import wasm from './wasm_loader.ts'
2
+ import wasmLoader from './wasm_loader.ts'
3
3
4
- export default ( ) : Config => ( {
5
- plugins : [ wasm ( ) ]
6
- } )
4
+ export default < Config > {
5
+ plugins : [ wasmLoader ]
6
+ }
Original file line number Diff line number Diff line change 1
1
import type { Plugin } from 'aleph/types.ts'
2
2
3
- export default ( ) : Plugin => ( {
3
+ export default < Plugin > {
4
4
name : 'wasm-loader' ,
5
- setup ( aleph ) {
6
- aleph . addModuleLoader ( {
7
- test : / \. w a s m $ / i,
8
- load : async ( { specifier } , aleph ) => {
9
- const { content } = await aleph . fetchModule ( specifier )
10
- return {
11
- code : [
12
- `const wasmBytes = new Uint8Array([${ content . join ( ',' ) } ])` ,
13
- 'const wasmModule = new WebAssembly.Module(wasmBytes)' ,
14
- 'const { exports } = new WebAssembly.Instance(wasmModule)' ,
15
- 'export default exports' ,
16
- ] . join ( '\n' )
17
- }
5
+ setup : aleph => {
6
+ aleph . onLoad ( / \. w a s m $ / i, async ( { specifier } ) => {
7
+ const { content } = await aleph . fetchModuleSource ( specifier )
8
+ return {
9
+ code : [
10
+ `const wasmBytes = new Uint8Array([${ content . join ( ',' ) } ])` ,
11
+ 'const wasmModule = new WebAssembly.Module(wasmBytes)' ,
12
+ 'const { exports } = new WebAssembly.Instance(wasmModule)' ,
13
+ 'export default exports' ,
14
+ ] . join ( '\n' )
18
15
}
19
16
} )
20
17
}
21
- } )
18
+ }
You can’t perform that action at this time.
0 commit comments