diff options
author | Guy Bedford <guybedford@gmail.com> | 2019-09-26 23:21:52 -0400 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2019-10-01 14:37:21 +0200 |
commit | 3f028551a8f679882b7ddc4d40788150fe27c168 (patch) | |
tree | 2ac384210b0c0079510298eb4244e091ec8916b1 | |
parent | b5c24dfbe8a80cfd6f1716a007724e56c98f426b (diff) | |
download | node-new-3f028551a8f679882b7ddc4d40788150fe27c168.tar.gz |
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 5056a698b3..034938e56a 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -952,7 +952,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'); |