diff options
author | Guy Bedford <guybedford@gmail.com> | 2019-09-26 23:21:52 -0400 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-09-28 11:56:39 -0700 |
commit | 2825e1183d87354507e2e847f0891116d48b1a38 (patch) | |
tree | 5a718ad2185a16baf80befcdf05ffdbf5b6ec5f5 | |
parent | f21818ec32b2e6a6acc010861742b451ce6fae1d (diff) | |
download | android-node-v8-2825e1183d87354507e2e847f0891116d48b1a38.tar.gz android-node-v8-2825e1183d87354507e2e847f0891116d48b1a38.tar.bz2 android-node-v8-2825e1183d87354507e2e847f0891116d48b1a38.zip |
module: move cjs type check behind flag
PR-URL: https://github.com/nodejs/node/pull/29732
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com>
-rw-r--r-- | lib/internal/modules/cjs/loader.js | 2 | ||||
-rw-r--r-- | test/es-module/test-esm-type-flag-errors.js | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 8ef01b4499..341163ef8c 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -953,7 +953,7 @@ Module.prototype._compile = function(content, filename) { // Native extension for .js Module._extensions['.js'] = function(module, filename) { - if (filename.endsWith('.js')) { + if (experimentalModules && filename.endsWith('.js')) { const pkg = readPackageScope(filename); if (pkg && pkg.type === 'module') { throw new ERR_REQUIRE_ESM(filename); diff --git a/test/es-module/test-esm-type-flag-errors.js b/test/es-module/test-esm-type-flag-errors.js index a54a018ad9..8725fb6232 100644 --- a/test/es-module/test-esm-type-flag-errors.js +++ b/test/es-module/test-esm-type-flag-errors.js @@ -1,3 +1,4 @@ +// Flags: --experimental-modules 'use strict'; const common = require('../common'); const assert = require('assert'); |