diff options
author | Jan Krems <jan.krems@gmail.com> | 2019-07-23 21:25:24 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-07-31 13:33:46 -0700 |
commit | 61f3a5c60ad78506e9e0caae061a04ccab878ca1 (patch) | |
tree | 06ca06f666a4986f46d460295a3397f659275518 /test/fixtures | |
parent | 9d37013ef0e0f0f243da6057498a79fd43a2f784 (diff) | |
download | node-new-61f3a5c60ad78506e9e0caae061a04ccab878ca1.tar.gz |
module: unify package exports test for CJS and ESM
Refs: https://github.com/nodejs/modules/issues/358
PR-URL: https://github.com/nodejs/node/pull/28831
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'test/fixtures')
-rw-r--r-- | test/fixtures/node_modules/pkgexports/package.json | 1 | ||||
-rw-r--r-- | test/fixtures/pkgexports-missing.mjs | 11 | ||||
-rw-r--r-- | test/fixtures/pkgexports.mjs | 15 |
3 files changed, 12 insertions, 15 deletions
diff --git a/test/fixtures/node_modules/pkgexports/package.json b/test/fixtures/node_modules/pkgexports/package.json index b0c8867bb4..97f07da85e 100644 --- a/test/fixtures/node_modules/pkgexports/package.json +++ b/test/fixtures/node_modules/pkgexports/package.json @@ -2,7 +2,6 @@ "exports": { ".": "./asdf.js", "./space": "./sp%20ce.js", - "./asdf": "./asdf.js", "./valid-cjs": "./asdf.js", "./sub/": "./" } diff --git a/test/fixtures/pkgexports-missing.mjs b/test/fixtures/pkgexports-missing.mjs deleted file mode 100644 index 7d1d5b2e82..0000000000 --- a/test/fixtures/pkgexports-missing.mjs +++ /dev/null @@ -1,11 +0,0 @@ -export function loadMissing() { - return import('pkgexports/missing'); -} - -export function loadFromNumber() { - return import('pkgexports-number/hidden.js'); -} - -export function loadDot() { - return import('pkgexports'); -} diff --git a/test/fixtures/pkgexports.mjs b/test/fixtures/pkgexports.mjs index 8907ebcb0e..7d642c443e 100644 --- a/test/fixtures/pkgexports.mjs +++ b/test/fixtures/pkgexports.mjs @@ -1,3 +1,12 @@ -export { default as asdf } from 'pkgexports/asdf'; -export { default as asdf2 } from 'pkgexports/sub/asdf.js'; -export { default as space } from 'pkgexports/space'; +import { fileURLToPath } from 'url'; +import { createRequire } from 'module'; + +const rawRequire = createRequire(fileURLToPath(import.meta.url)); + +export async function requireFixture(specifier) { + return { default: rawRequire(specifier ) }; +} + +export function importFixture(specifier) { + return import(specifier); +} |