Skip to content

Commit 3f02855

Browse files
guybedfordtargos
authored andcommitted
module: move cjs type check behind flag
PR-URL: #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>
1 parent b5c24df commit 3f02855

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/internal/modules/cjs/loader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ Module.prototype._compile = function(content, filename) {
952952

953953
// Native extension for .js
954954
Module._extensions['.js'] = function(module, filename) {
955-
if (filename.endsWith('.js')) {
955+
if (experimentalModules && filename.endsWith('.js')) {
956956
const pkg = readPackageScope(filename);
957957
if (pkg && pkg.type === 'module') {
958958
throw new ERR_REQUIRE_ESM(filename);

test/es-module/test-esm-type-flag-errors.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Flags: --experimental-modules
12
'use strict';
23
const common = require('../common');
34
const assert = require('assert');

0 commit comments

Comments
 (0)