From 0d185f7930107b29ee87c2d788b1caaa7434e63e Mon Sep 17 00:00:00 2001 From: Bradley Farias Date: Mon, 30 Nov 2020 10:03:30 -0600 Subject: [PATCH] esm: support https remotely and http locally under flag Co-authored-by: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com> Co-authored-by: James M Snell Co-authored-by: Jordan Harband Co-authored-by: James Sumners PR-URL: https://github.com/nodejs/node/pull/36328 Backport-PR-URL: https://github.com/nodejs/node/pull/42726 Reviewed-By: Matteo Collina Reviewed-By: Geoffrey Booth --- doc/api/cli.md | 11 + doc/api/errors.md | 17 ++ doc/api/esm.md | 65 ++++ doc/node.1 | 3 + lib/internal/errors.js | 11 +- lib/internal/main/check_syntax.js | 6 +- lib/internal/modules/esm/fetch_module.js | 286 ++++++++++++++++++ lib/internal/modules/esm/formats.js | 65 ++++ lib/internal/modules/esm/get_format.js | 93 +++--- lib/internal/modules/esm/get_source.js | 25 +- .../modules/esm/initialize_import_meta.js | 25 +- lib/internal/modules/esm/load.js | 6 +- lib/internal/modules/esm/loader.js | 27 +- lib/internal/modules/esm/resolve.js | 168 +++++++++- lib/internal/policy/manifest.js | 36 +++ lib/repl.js | 2 +- src/node_options.cc | 4 + src/node_options.h | 1 + test/common/index.mjs | 2 + test/es-module/test-esm-dynamic-import.js | 4 +- .../test-esm-import-assertion-errors.js | 4 +- .../test-esm-import-assertion-errors.mjs | 2 +- test/es-module/test-esm-invalid-data-urls.js | 15 +- .../test-esm-loader-resolve-type.mjs | 3 +- test/es-module/test-esm-loader-search.js | 4 +- test/es-module/test-esm-resolve-type.js | 17 +- test/es-module/test-http-imports.mjs | 170 +++++++++++ .../builtin-named-exports-loader.mjs | 4 +- .../es-module-loaders/hook-resolve-type.mjs | 8 +- .../es-module-loaders/loader-with-dep.mjs | 4 +- .../es-module-loaders/mock-loader.mjs | 14 +- test/parallel/test-bootstrap-modules.js | 36 ++- test/pummel/test-policy-integrity-dep.js | 1 + 33 files changed, 995 insertions(+), 144 deletions(-) create mode 100644 lib/internal/modules/esm/fetch_module.js create mode 100644 lib/internal/modules/esm/formats.js create mode 100644 test/es-module/test-http-imports.mjs diff --git a/doc/api/cli.md b/doc/api/cli.md index 2d1e6c2d6963b7..ae0dde8630099a 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -291,6 +291,16 @@ added: v9.0.0 Specify the `module` of a custom experimental [ECMAScript module loader][]. `module` may be any string accepted as an [`import` specifier][]. +### `--experimental-network-imports` + + + +> Stability: 1 - Experimental + +Enable experimental support for the `https:` protocol in `import` specifiers. + ### `--experimental-policy`