Skip to content

Commit

Permalink
fixup! module: clarify CJS global-like variables not defined error me…
Browse files Browse the repository at this point in the history
…ssage
  • Loading branch information
aduh95 committed Mar 25, 2021
1 parent cef31c9 commit 8798fb3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
34 changes: 17 additions & 17 deletions test/es-module/test-esm-undefined-cjs-global-like-variables.js
Expand Up @@ -6,37 +6,37 @@ const { pathToFileURL } = require('url');

assert.rejects(
import('data:text/javascript,require;'),
/require is not defined in ES module scope, you can use import instead/
).then(common.mustCall());

assert.rejects(
import('data:text/javascript,require_custom;'),
/^(?!use import instead).*$/
/require is not defined in ES module scope, you can use import instead$/
).then(common.mustCall());
assert.rejects(
import('data:text/javascript,exports={};'),
/^(?!use import instead).*$/
/exports is not defined in ES module scope$/
).then(common.mustCall());

assert.rejects(
import('data:text/javascript,require;//.js'),
// eslint-disable-next-line node-core/no-unescaped-regexp-dot
/^(?!use the .\.cjs. file extension).*$/
import('data:text/javascript,require_custom;'),
/^(?!in ES module scope)(?!use import instead).*$/
).then(common.mustCall());

const pkgUrl = pathToFileURL(fixtures.path('/es-modules/package-type-module/'));
assert.rejects(
import(new URL('./cjs.js', pkgUrl)),
// eslint-disable-next-line node-core/no-unescaped-regexp-dot
/use the .\.cjs. file extension/
/use the '\.cjs' file extension/
).then(common.mustCall());
assert.rejects(
import(new URL('./nested-inherited-type/cjs.js', pkgUrl)),
// eslint-disable-next-line node-core/no-unescaped-regexp-dot
/use the .\.cjs. file extension/
import(new URL('./cjs.js#target', pkgUrl)),
/use the '\.cjs' file extension/
).then(common.mustCall());
assert.rejects(
import(new URL('./cjs.js?foo=bar', pkgUrl)),
/use the '\.cjs' file extension/
).then(common.mustCall());
assert.rejects(
import(new URL('./cjs.js?foo=bar#target', pkgUrl)),
// eslint-disable-next-line node-core/no-unescaped-regexp-dot
/use the .\.cjs. file extension/
/use the '\.cjs' file extension/
).then(common.mustCall());

assert.rejects(
import('data:text/javascript,require;//.js'),
/^(?!use the '\.cjs' file extension).*$/
).then(common.mustCall());

This file was deleted.

0 comments on commit 8798fb3

Please sign in to comment.