-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
module: support Wasm without file extension within
module
scope
- Loading branch information
1 parent
500ea04
commit d78a9da
Showing
5 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { strictEqual } from 'assert'; | ||
|
||
export function jsFn () { | ||
state = 'WASM JS Function Executed'; | ||
return 42; | ||
} | ||
|
||
export let state = 'JS Function Executed'; | ||
|
||
export function jsInitFn () { | ||
strictEqual(state, 'JS Function Executed'); | ||
state = 'WASM Start Executed'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Flags: --experimental-wasm-modules | ||
import { mustCall } from '../common/index.mjs'; | ||
import { path } from '../common/fixtures.mjs'; | ||
import { strictEqual } from 'assert'; | ||
import { spawn } from 'child_process'; | ||
|
||
{ | ||
const entry = path('/es-modules/package-type-module/noext-wasm'); | ||
|
||
// Run a module that does not have extension. | ||
// This is to ensure that "type": "module" applies to extensionless files. | ||
|
||
const child = spawn(process.execPath, ['--experimental-wasm-modules', entry]); | ||
|
||
let stdout = ''; | ||
child.stdout.setEncoding('utf8'); | ||
child.stdout.on('data', (data) => { | ||
stdout += data; | ||
}); | ||
child.on('close', mustCall((code, signal) => { | ||
strictEqual(code, 0); | ||
strictEqual(signal, null); | ||
strictEqual(stdout, ''); | ||
})); | ||
} |