From 8fee4ae9c982b2dec6bbb31a8d5e88fa431edd61 Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Thu, 25 Jan 2018 14:32:43 -0800 Subject: [PATCH 1/3] 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` --- src/node.cc | 2 ++ test/es-module/test-esm-dynamic-import.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/node.cc b/src/node.cc index c82bd73348fe10..882d00e6b0f0ce 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3678,6 +3678,8 @@ static void ParseArgs(int* argc, config_preserve_symlinks = true; } else if (strcmp(arg, "--experimental-modules") == 0) { config_experimental_modules = true; + new_v8_argv[new_v8_argc] = "--harmony-dynamic-import"; + new_v8_argc += 1; } else if (strcmp(arg, "--experimental-vm-modules") == 0) { config_experimental_vm_modules = true; } else if (strcmp(arg, "--loader") == 0) { diff --git a/test/es-module/test-esm-dynamic-import.js b/test/es-module/test-esm-dynamic-import.js index 997eed289eb931..9c4d48aaf02da6 100644 --- a/test/es-module/test-esm-dynamic-import.js +++ b/test/es-module/test-esm-dynamic-import.js @@ -1,4 +1,4 @@ -// Flags: --experimental-modules --harmony-dynamic-import +// Flags: --experimental-modules 'use strict'; const common = require('../common'); const assert = require('assert'); From f1183ac64a6a9a4ab1d1951603e2676fd15ff057 Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Thu, 25 Jan 2018 15:14:32 -0800 Subject: [PATCH 2/3] fixup docs --- doc/api/esm.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/api/esm.md b/doc/api/esm.md index 0e86c381f1ab60..2cfafd1d9f24ab 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -33,8 +33,7 @@ node --experimental-modules my-app.mjs ### Supported Only the CLI argument for the main entry point to the program can be an entry -point into an ESM graph. Dynamic import can also be used with the flag -`--harmony-dynamic-import` to create entry points into ESM graphs at runtime. +point into an ESM graph. ### Unsupported From 6edbfde4f78561af77ae48d999642132e21620bc Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Thu, 25 Jan 2018 15:17:02 -0800 Subject: [PATCH 3/3] fixup one more doc tweak --- doc/api/esm.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/api/esm.md b/doc/api/esm.md index 2cfafd1d9f24ab..a02c8d32f235da 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -33,7 +33,8 @@ node --experimental-modules my-app.mjs ### Supported Only the CLI argument for the main entry point to the program can be an entry -point into an ESM graph. +point into an ESM graph. Dynamic import can also be used to create entry points +into ESM graphs at runtime. ### Unsupported