-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
module: clarify CJS global-like variables not defined error message
Fixes: #33741
- Loading branch information
Showing
2 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
test/es-module/test-esm-undefined-cjs-global-like-variables.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const fixtures = require('../common/fixtures'); | ||
const assert = require('assert'); | ||
|
||
assert.rejects( | ||
import('data:text/javascript,require;'), | ||
// eslint-disable-next-line node-core/no-unescaped-regexp-dot | ||
/use .await import. instead/ | ||
).then(common.mustCall()); | ||
|
||
assert.rejects( | ||
import('data:text/javascript,exports={};'), | ||
// eslint-disable-next-line node-core/no-unescaped-regexp-dot | ||
/^(?!use .await import. instead).*$/ | ||
).then(common.mustCall()); | ||
|
||
assert.rejects( | ||
import('data:text/javascript,require;//.js'), | ||
// eslint-disable-next-line node-core/no-unescaped-regexp-dot | ||
/^(?!It seems you are trying to load a file using `.js` extension).*$/ | ||
).then(common.mustCall()); | ||
|
||
assert.rejects( | ||
import(fixtures.path('/es-modules/package-type-module/cjs.js')), | ||
// eslint-disable-next-line node-core/no-unescaped-regexp-dot | ||
/use the .\.cjs. extension to load the file as a CommonJS module/ | ||
).then(common.mustCall()); |