+19
-18
lines changedFilter options
+19
-18
lines changed Original file line number Diff line number Diff line change
@@ -713,13 +713,18 @@ into a new instance of `library.wasm`:
713
713
```js
714
714
import source libraryModule from './library.wasm';
715
715
716
-
const instance1 = await WebAssembly.instantiate(libraryModule, {
717
-
custom: import1,
718
-
});
716
+
const instance1 = await WebAssembly.instantiate(libraryModule, importObject1);
719
717
720
-
const instance2 = await WebAssembly.instantiate(libraryModule, {
721
-
custom: import2,
722
-
});
718
+
const instance2 = await WebAssembly.instantiate(libraryModule, importObject2);
719
+
```
720
+
721
+
In addition to the static source phase, there is also a dynamic variant of the
722
+
source phase via the `import.source` dynamic phase import syntax:
723
+
724
+
```js
725
+
const dynamicLibrary = await import.source('./library.wasm');
726
+
727
+
const instance = await WebAssembly.instantiate(dynamicLibrary, importObject);
723
728
```
724
729
725
730
<i id="esm_experimental_top_level_await"></i>
Original file line number Diff line number Diff line change
@@ -104,6 +104,7 @@ export default [
104
104
parser: babelEslintParser,
105
105
parserOptions: {
106
106
babelOptions: {
107
+
parserOpts: { createImportExpressions: true },
107
108
plugins: [
108
109
babelPluginProposalExplicitResourceManagement,
109
110
babelPluginSyntaxImportAttributes,
Original file line number Diff line number Diff line change
@@ -1065,10 +1065,8 @@ void ModuleWrap::SetImportModuleDynamicallyCallback(
1065
1065
realm->set_host_import_module_dynamically_callback(import_callback);
1066
1066
1067
1067
isolate->SetHostImportModuleDynamicallyCallback(ImportModuleDynamically);
1068
-
// TODO(guybedford): Enable this once
1069
-
// https://github.com/nodejs/node/pull/56842 lands.
1070
-
// isolate->SetHostImportModuleWithPhaseDynamicallyCallback(
1071
-
// ImportModuleDynamicallyWithPhase);
1068
+
isolate->SetHostImportModuleWithPhaseDynamicallyCallback(
1069
+
ImportModuleDynamicallyWithPhase);
1072
1070
}
1073
1071
1074
1072
void ModuleWrap::HostInitializeImportMetaObjectCallback(
Original file line number Diff line number Diff line change
@@ -124,8 +124,7 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>
124
124
strictEqual(code, 0);
125
125
});
126
126
127
-
// TODO: Enable this once https://github.com/nodejs/node/pull/56842 lands.
128
-
it.skip('should support dynamic source phase imports', async () => {
127
+
it('should support dynamic source phase imports', async () => {
129
128
const { code, stderr, stdout } = await spawnPromisified(execPath, [
130
129
'--no-warnings',
131
130
'--experimental-wasm-modules',
@@ -166,8 +165,7 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>
166
165
strictEqual(code, 0);
167
166
});
168
167
169
-
// TODO: Enable this once https://github.com/nodejs/node/pull/56842 lands.
170
-
it.skip('should not execute dynamic source phase imports', async () => {
168
+
it('should not execute dynamic source phase imports', async () => {
171
169
const { code, stderr, stdout } = await spawnPromisified(execPath, [
172
170
'--no-warnings',
173
171
'--experimental-wasm-modules',
@@ -181,8 +179,7 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>
181
179
strictEqual(code, 0);
182
180
});
183
181
184
-
// TODO: Enable this once https://github.com/nodejs/node/pull/56842 lands.
185
-
it.skip('should throw for dynamic source phase imports not defined', async () => {
182
+
it('should throw for dynamic source phase imports not defined', async () => {
186
183
const fileUrl = fixtures.fileURL('es-modules/wasm-source-phase.js');
187
184
const { code, stderr, stdout } = await spawnPromisified(execPath, [
188
185
'--no-warnings',
@@ -195,6 +192,7 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>
195
192
' strictEqual(e instanceof SyntaxError, true);',
196
193
' strictEqual(e.message.includes("Source phase import object is not defined for module"), true);',
197
194
` strictEqual(e.message.includes(${JSON.stringify(fileUrl)}), true);`,
195
+
` return true`,
198
196
'});',
199
197
].join('\n'),
200
198
]);
@@ -238,8 +236,7 @@ describe('ESM: WASM modules', { concurrency: !process.env.TEST_PARALLEL }, () =>
238
236
notStrictEqual(code, 0);
239
237
});
240
238
241
-
// TODO: Enable this once https://github.com/nodejs/node/pull/56842 lands.
242
-
it.skip('should throw for vm source phase dynamic import', async () => {
239
+
it('should throw for vm source phase dynamic import', async () => {
243
240
const { code, stderr, stdout } = await spawnPromisified(execPath, [
244
241
'--no-warnings',
245
242
'--experimental-wasm-modules',
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4