Skip to content

Commit ba3d55a

Browse files
committed
module: enable dynamic import flag for esmodules
currently if you want to use dynamic import you must use both the `--experimental-modules` and the `--harmony-dynamic-imports` flags. Chrome is currently shipping dynamic import unflagged, the flag only remains in V8 to guard embedders who have not set the appropriate callback from throwing an unhandled rejection when the feature is used. As such it is reasonable to enable the flag by default for `--experimental-modules` PR-URL: #18387 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent 6bcd31f commit ba3d55a

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

doc/api/esm.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ node --experimental-modules my-app.mjs
3333
### Supported
3434

3535
Only the CLI argument for the main entry point to the program can be an entry
36-
point into an ESM graph. Dynamic import can also be used with the flag
37-
`--harmony-dynamic-import` to create entry points into ESM graphs at runtime.
36+
point into an ESM graph. Dynamic import can also be used to create entry points
37+
into ESM graphs at runtime.
3838

3939
### Unsupported
4040

src/node.cc

+2
Original file line numberDiff line numberDiff line change
@@ -3678,6 +3678,8 @@ static void ParseArgs(int* argc,
36783678
config_preserve_symlinks = true;
36793679
} else if (strcmp(arg, "--experimental-modules") == 0) {
36803680
config_experimental_modules = true;
3681+
new_v8_argv[new_v8_argc] = "--harmony-dynamic-import";
3682+
new_v8_argc += 1;
36813683
} else if (strcmp(arg, "--experimental-vm-modules") == 0) {
36823684
config_experimental_vm_modules = true;
36833685
} else if (strcmp(arg, "--loader") == 0) {

test/es-module/test-esm-dynamic-import.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Flags: --experimental-modules --harmony-dynamic-import
1+
// Flags: --experimental-modules
22
'use strict';
33
const common = require('../common');
44
const assert = require('assert');

0 commit comments

Comments
 (0)