Skip to content

Commit

Permalink
module: move cjs type check behind flag
Browse files Browse the repository at this point in the history
PR-URL: #29732
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Jan Krems <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
  • Loading branch information
guybedford authored and targos committed Oct 1, 2019
1 parent b5c24df commit 3f02855
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/internal/modules/cjs/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions test/es-module/test-esm-type-flag-errors.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Flags: --experimental-modules
'use strict';
const common = require('../common');
const assert = require('assert');
Expand Down

0 comments on commit 3f02855

Please sign in to comment.