From f594cc85b7dd80530dd65013da91c45c7b4a907d Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Tue, 4 Oct 2022 02:44:08 -0700 Subject: [PATCH] esm: remove specifier resolution flag PR-URL: https://github.com/nodejs/node/pull/44859 Reviewed-By: Jacob Smith Reviewed-By: Antoine du Hamel Reviewed-By: James M Snell Reviewed-By: Jan Krems Reviewed-By: Guy Bedford --- doc/api/cli.md | 18 ---- doc/api/esm.md | 29 +------ doc/node.1 | 3 - lib/internal/modules/esm/formats.js | 18 +--- lib/internal/modules/esm/get_format.js | 35 ++++---- lib/internal/modules/esm/loader.js | 12 --- lib/internal/modules/esm/resolve.js | 68 +-------------- lib/internal/modules/run_main.js | 4 - lib/repl.js | 6 +- src/node_options.cc | 15 +--- src/node_options.h | 1 - .../test-esm-experimental-warnings.mjs | 1 - .../es-module/test-esm-specifiers-symlink.mjs | 40 --------- test/es-module/test-esm-specifiers.mjs | 82 ------------------- .../dir-with-main/main.js | 1 - .../dir-with-main/package.json | 3 - .../package-type-commonjs/a.js | 1 - .../package-type-commonjs/b.mjs | 1 - .../package-type-commonjs/c.cjs | 5 -- .../package-type-commonjs/index.mjs | 21 ----- .../package-type-commonjs/package.json | 3 - .../package-type-module/a.js | 1 - .../package-type-module/b.mjs | 1 - .../package-type-module/c.cjs | 5 -- .../package-type-module/index.js | 21 ----- .../package-type-module/package.json | 3 - 26 files changed, 24 insertions(+), 374 deletions(-) delete mode 100644 test/es-module/test-esm-specifiers-symlink.mjs delete mode 100644 test/es-module/test-esm-specifiers.mjs delete mode 100644 test/fixtures/es-module-specifiers/dir-with-main/main.js delete mode 100644 test/fixtures/es-module-specifiers/dir-with-main/package.json delete mode 100644 test/fixtures/es-module-specifiers/package-type-commonjs/a.js delete mode 100644 test/fixtures/es-module-specifiers/package-type-commonjs/b.mjs delete mode 100644 test/fixtures/es-module-specifiers/package-type-commonjs/c.cjs delete mode 100644 test/fixtures/es-module-specifiers/package-type-commonjs/index.mjs delete mode 100644 test/fixtures/es-module-specifiers/package-type-commonjs/package.json delete mode 100644 test/fixtures/es-module-specifiers/package-type-module/a.js delete mode 100644 test/fixtures/es-module-specifiers/package-type-module/b.mjs delete mode 100644 test/fixtures/es-module-specifiers/package-type-module/c.cjs delete mode 100644 test/fixtures/es-module-specifiers/package-type-module/index.js delete mode 100644 test/fixtures/es-module-specifiers/package-type-module/package.json diff --git a/doc/api/cli.md b/doc/api/cli.md index 6dbc33ebd07547..02408b493ce1e4 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -427,23 +427,6 @@ added: REPLACEME Use this flag to enable [ShadowRealm][] support. -### `--experimental-specifier-resolution=mode` - - - -Sets the resolution algorithm for resolving ES module specifiers. Valid options -are `explicit` and `node`. - -The default is `explicit`, which requires providing the full path to a -module. The `node` mode enables support for optional file extensions and -the ability to import a directory that has an index file. - -See [customizing ESM specifier resolution][] for example usage. - ### `--experimental-vm-modules` @@ -1583,6 +1561,7 @@ success! [`string`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String [`util.TextDecoder`]: util.md#class-utiltextdecoder [cjs-module-lexer]: https://github.com/nodejs/cjs-module-lexer/tree/1.2.2 +[commonjs-extension-resolution-loader]: https://github.com/nodejs/loaders-test/tree/main/commonjs-extension-resolution-loader [custom https loader]: #https-loader [load hook]: #loadurl-context-nextload [percent-encoded]: url.md#percent-encoding-in-urls diff --git a/doc/node.1 b/doc/node.1 index 3e2602673a83e4..376f1a3b37dcda 100644 --- a/doc/node.1 +++ b/doc/node.1 @@ -171,9 +171,6 @@ Disable exposition of the Web Crypto API on the global scope. .It Fl -no-experimental-repl-await Disable top-level await keyword support in REPL. . -.It Fl -experimental-specifier-resolution -Select extension resolution algorithm for ES Modules; either 'explicit' (default) or 'node'. -. .It Fl -experimental-vm-modules Enable experimental ES module support in VM module. . diff --git a/lib/internal/modules/esm/formats.js b/lib/internal/modules/esm/formats.js index f71e6ae689c277..9853dc160d3566 100644 --- a/lib/internal/modules/esm/formats.js +++ b/lib/internal/modules/esm/formats.js @@ -5,7 +5,6 @@ const { } = primordials; const { getOptionValue } = require('internal/options'); - const experimentalWasmModules = getOptionValue('--experimental-wasm-modules'); const extensionFormatMap = { @@ -16,17 +15,8 @@ const extensionFormatMap = { '.mjs': 'module', }; -const legacyExtensionFormatMap = { - '__proto__': null, - '.cjs': 'commonjs', - '.js': 'commonjs', - '.json': 'commonjs', - '.mjs': 'module', - '.node': 'commonjs', -}; - if (experimentalWasmModules) { - extensionFormatMap['.wasm'] = legacyExtensionFormatMap['.wasm'] = 'wasm'; + extensionFormatMap['.wasm'] = 'wasm'; } /** @@ -45,13 +35,7 @@ function mimeToFormat(mime) { return null; } -function getLegacyExtensionFormat(ext) { - return legacyExtensionFormatMap[ext]; -} - module.exports = { extensionFormatMap, - getLegacyExtensionFormat, - legacyExtensionFormatMap, mimeToFormat, }; diff --git a/lib/internal/modules/esm/get_format.js b/lib/internal/modules/esm/get_format.js index a7329d279bb075..a3be03ffdc8de9 100644 --- a/lib/internal/modules/esm/get_format.js +++ b/lib/internal/modules/esm/get_format.js @@ -11,14 +11,11 @@ const { getOptionValue } = require('internal/options'); const { fetchModule } = require('internal/modules/esm/fetch_module'); const { extensionFormatMap, - getLegacyExtensionFormat, mimeToFormat, } = require('internal/modules/esm/formats'); const experimentalNetworkImports = getOptionValue('--experimental-network-imports'); -const experimentalSpecifierResolution = - getOptionValue('--experimental-specifier-resolution'); const { getPackageType, getPackageScopeConfig } = require('internal/modules/esm/resolve'); const { URL, fileURLToPath } = require('internal/url'); const { ERR_UNKNOWN_FILE_EXTENSION } = require('internal/errors').codes; @@ -61,25 +58,21 @@ function getFileProtocolModuleFormat(url, context, ignoreErrors) { const format = extensionFormatMap[ext]; if (format) return format; - if (experimentalSpecifierResolution !== 'node') { - // Explicit undefined return indicates load hook should rerun format check - if (ignoreErrors) return undefined; - let suggestion = ''; - if (getPackageType(url) === 'module' && ext === '') { - const config = getPackageScopeConfig(url); - const fileBasename = basename(filepath); - const relativePath = StringPrototypeSlice(relative(config.pjsonPath, filepath), 1); - suggestion = 'Loading extensionless files is not supported inside of ' + - '"type":"module" package.json contexts. The package.json file ' + - `${config.pjsonPath} caused this "type":"module" context. Try ` + - `changing ${filepath} to have a file extension. Note the "bin" ` + - 'field of package.json can point to a file with an extension, for example ' + - `{"type":"module","bin":{"${fileBasename}":"${relativePath}.js"}}`; - } - throw new ERR_UNKNOWN_FILE_EXTENSION(ext, filepath, suggestion); + // Explicit undefined return indicates load hook should rerun format check + if (ignoreErrors) { return undefined; } + let suggestion = ''; + if (getPackageType(url) === 'module' && ext === '') { + const config = getPackageScopeConfig(url); + const fileBasename = basename(filepath); + const relativePath = StringPrototypeSlice(relative(config.pjsonPath, filepath), 1); + suggestion = 'Loading extensionless files is not supported inside of ' + + '"type":"module" package.json contexts. The package.json file ' + + `${config.pjsonPath} caused this "type":"module" context. Try ` + + `changing ${filepath} to have a file extension. Note the "bin" ` + + 'field of package.json can point to a file with an extension, for example ' + + `{"type":"module","bin":{"${fileBasename}":"${relativePath}.js"}}`; } - - return getLegacyExtensionFormat(ext) ?? null; + throw new ERR_UNKNOWN_FILE_EXTENSION(ext, filepath, suggestion); } /** diff --git a/lib/internal/modules/esm/loader.js b/lib/internal/modules/esm/loader.js index d247f5327eda8b..46f86bb26927ab 100644 --- a/lib/internal/modules/esm/loader.js +++ b/lib/internal/modules/esm/loader.js @@ -89,8 +89,6 @@ const { getOptionValue } = require('internal/options'); // [2] `validate...()`s throw the wrong error -let emittedSpecifierResolutionWarning = false; - /** * A utility function to iterate through a hook chain, track advancement in the * chain, and generate and supply the `next` argument to the custom @@ -241,16 +239,6 @@ class ESMLoader { if (getOptionValue('--experimental-network-imports')) { emitExperimentalWarning('Network Imports'); } - if ( - !emittedSpecifierResolutionWarning && - getOptionValue('--experimental-specifier-resolution') === 'node' - ) { - process.emitWarning( - 'The Node.js specifier resolution flag is experimental. It could change or be removed at any time.', - 'ExperimentalWarning' - ); - emittedSpecifierResolutionWarning = true; - } } /** diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js index 91ac345e96df86..f3a3503cdbd813 100644 --- a/lib/internal/modules/esm/resolve.js +++ b/lib/internal/modules/esm/resolve.js @@ -5,7 +5,6 @@ const { ArrayPrototypeConcat, ArrayPrototypeJoin, ArrayPrototypeShift, - JSONParse, JSONStringify, ObjectFreeze, ObjectGetOwnPropertyNames, @@ -37,7 +36,7 @@ const { getOptionValue } = require('internal/options'); const policy = getOptionValue('--experimental-policy') ? require('internal/process/policy') : null; -const { sep, relative, resolve } = require('path'); +const { sep, relative } = require('path'); const preserveSymlinks = getOptionValue('--preserve-symlinks'); const preserveSymlinksMain = getOptionValue('--preserve-symlinks-main'); const experimentalNetworkImports = @@ -60,7 +59,6 @@ const { } = require('internal/errors').codes; const { Module: CJSModule } = require('internal/modules/cjs/loader'); -const packageJsonReader = require('internal/modules/package_json_reader'); const { getPackageConfig, getPackageScopeConfig } = require('internal/modules/esm/package_config'); /** @@ -234,50 +232,6 @@ function legacyMainResolve(packageJSONUrl, packageConfig, base) { fileURLToPath(new URL('.', packageJSONUrl)), fileURLToPath(base)); } -/** - * @param {URL} search - * @returns {URL | undefined} - */ -function resolveExtensionsWithTryExactName(search) { - if (fileExists(search)) return search; - return resolveExtensions(search); -} - -const extensions = ['.js', '.json', '.node', '.mjs']; - -/** - * @param {URL} search - * @returns {URL | undefined} - */ -function resolveExtensions(search) { - for (let i = 0; i < extensions.length; i++) { - const extension = extensions[i]; - const guess = new URL(`${search.pathname}${extension}`, search); - if (fileExists(guess)) return guess; - } - return undefined; -} - -/** - * @param {URL} search - * @returns {URL | undefined} - */ -function resolveDirectoryEntry(search) { - const dirPath = fileURLToPath(search); - const pkgJsonPath = resolve(dirPath, 'package.json'); - if (fileExists(pkgJsonPath)) { - const pkgJson = packageJsonReader.read(pkgJsonPath); - if (pkgJson.containsKeys) { - const { main } = JSONParse(pkgJson.string); - if (main != null) { - const mainUrl = pathToFileURL(resolve(dirPath, main)); - return resolveExtensionsWithTryExactName(mainUrl); - } - } - } - return resolveExtensions(new URL('index', search)); -} - const encodedSepRegEx = /%2F|%5C/i; /** * @param {URL} resolved @@ -291,25 +245,7 @@ function finalizeResolution(resolved, base, preserveSymlinks) { resolved.pathname, 'must not include encoded "/" or "\\" characters', fileURLToPath(base)); - let path = fileURLToPath(resolved); - if (getOptionValue('--experimental-specifier-resolution') === 'node') { - let file = resolveExtensionsWithTryExactName(resolved); - - // Directory - if (file === undefined) { - file = StringPrototypeEndsWith(path, '/') ? - (resolveDirectoryEntry(resolved) || resolved) : resolveDirectoryEntry(new URL(`${resolved}/`)); - - if (file === resolved) return file; - - if (file === undefined) { - throw new ERR_MODULE_NOT_FOUND( - resolved.pathname, fileURLToPath(base), 'module'); - } - } - - path = file; - } + const path = fileURLToPath(resolved); const stats = tryStatSync(StringPrototypeEndsWith(path, '/') ? StringPrototypeSlice(path, -1) : path); diff --git a/lib/internal/modules/run_main.js b/lib/internal/modules/run_main.js index daaa153516c424..1a64906c721ebb 100644 --- a/lib/internal/modules/run_main.js +++ b/lib/internal/modules/run_main.js @@ -40,10 +40,6 @@ function shouldUseESMLoader(mainPath) { const userImports = getOptionValue('--import'); if (userLoaders.length > 0 || userImports.length > 0) return true; - const esModuleSpecifierResolution = - getOptionValue('--experimental-specifier-resolution'); - if (esModuleSpecifierResolution === 'node') - return true; // Determine the module format of the main if (mainPath && StringPrototypeEndsWith(mainPath, '.mjs')) return true; diff --git a/lib/repl.js b/lib/repl.js index f2996d660d8d6f..256d910d17e454 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -180,7 +180,6 @@ const { const history = require('internal/repl/history'); const { extensionFormatMap, - legacyExtensionFormatMap, } = require('internal/modules/esm/formats'); let nextREPLResourceNumber = 1; @@ -1377,10 +1376,7 @@ function complete(line, callback) { if (this.allowBlockingCompletions) { const subdir = match[2] || ''; // File extensions that can be imported: - const extensions = ObjectKeys( - getOptionValue('--experimental-specifier-resolution') === 'node' ? - legacyExtensionFormatMap : - extensionFormatMap); + const extensions = ObjectKeys(extensionFormatMap); // Only used when loading bare module specifiers from `node_modules`: const indexes = ArrayPrototypeMap(extensions, (ext) => `index${ext}`); diff --git a/src/node_options.cc b/src/node_options.cc index e5daab80196ae3..e2eb8c01623983 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -113,14 +113,6 @@ void EnvironmentOptions::CheckOptions(std::vector* errors) { } } - if (!experimental_specifier_resolution.empty()) { - if (experimental_specifier_resolution != "node" && - experimental_specifier_resolution != "explicit") { - errors->push_back( - "invalid value for --experimental-specifier-resolution"); - } - } - if (syntax_check_only && has_eval_string) { errors->push_back("either --check or --eval can be used, not both"); } @@ -444,11 +436,8 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { "set module type for string input", &EnvironmentOptions::module_type, kAllowedInEnvironment); - AddOption("--experimental-specifier-resolution", - "Select extension resolution algorithm for es modules; " - "either 'explicit' (default) or 'node'", - &EnvironmentOptions::experimental_specifier_resolution, - kAllowedInEnvironment); + AddOption( + "--experimental-specifier-resolution", "", NoOp{}, kAllowedInEnvironment); AddAlias("--es-module-specifier-resolution", "--experimental-specifier-resolution"); AddOption("--deprecation", diff --git a/src/node_options.h b/src/node_options.h index bd0799829a9aa4..5211dc39cbf2f9 100644 --- a/src/node_options.h +++ b/src/node_options.h @@ -112,7 +112,6 @@ class EnvironmentOptions : public Options { bool experimental_global_customevent = false; bool experimental_global_web_crypto = true; bool experimental_https_modules = false; - std::string experimental_specifier_resolution; bool experimental_wasm_modules = false; bool experimental_import_meta_resolve = false; std::string module_type; diff --git a/test/es-module/test-esm-experimental-warnings.mjs b/test/es-module/test-esm-experimental-warnings.mjs index fc167c63584b87..85b458258b6134 100644 --- a/test/es-module/test-esm-experimental-warnings.mjs +++ b/test/es-module/test-esm-experimental-warnings.mjs @@ -27,7 +27,6 @@ describe('ESM: warn for obsolete hooks provided', { concurrency: true }, () => { const [experiment, arg] of [ [/Custom ESM Loaders/, `--experimental-loader=${fileURL('es-module-loaders', 'hooks-custom.mjs')}`], [/Network Imports/, '--experimental-network-imports'], - [/specifier resolution/, '--experimental-specifier-resolution=node'], ] ) { it(`should print for ${experiment.toString().replaceAll('/', '')}`, async () => { diff --git a/test/es-module/test-esm-specifiers-symlink.mjs b/test/es-module/test-esm-specifiers-symlink.mjs deleted file mode 100644 index 9c60c1da89706f..00000000000000 --- a/test/es-module/test-esm-specifiers-symlink.mjs +++ /dev/null @@ -1,40 +0,0 @@ -import * as common from '../common/index.mjs'; -import path from 'path'; -import fs from 'fs/promises'; -import tmpdir from '../common/tmpdir.js'; -import { spawn } from 'child_process'; -import assert from 'assert'; - -tmpdir.refresh(); -const tmpDir = tmpdir.path; - -// Create the following file structure: -// ├── index.mjs -// ├── subfolder -// │ ├── index.mjs -// │ └── node_modules -// │ └── package-a -// │ └── index.mjs -// └── symlink.mjs -> ./subfolder/index.mjs -const entry = path.join(tmpDir, 'index.mjs'); -const symlink = path.join(tmpDir, 'symlink.mjs'); -const real = path.join(tmpDir, 'subfolder', 'index.mjs'); -const packageDir = path.join(tmpDir, 'subfolder', 'node_modules', 'package-a'); -const packageEntry = path.join(packageDir, 'index.mjs'); -try { - await fs.symlink(real, symlink); -} catch (err) { - if (err.code !== 'EPERM') throw err; - common.skip('insufficient privileges for symlinks'); -} -await fs.mkdir(packageDir, { recursive: true }); -await Promise.all([ - fs.writeFile(entry, 'import "./symlink.mjs";'), - fs.writeFile(real, 'export { a } from "package-a/index.mjs"'), - fs.writeFile(packageEntry, 'export const a = 1;'), -]); - -spawn(process.execPath, ['--experimental-specifier-resolution=node', entry], - { stdio: 'inherit' }).on('exit', common.mustCall((code) => { - assert.strictEqual(code, 0); -})); diff --git a/test/es-module/test-esm-specifiers.mjs b/test/es-module/test-esm-specifiers.mjs deleted file mode 100644 index 692db968141997..00000000000000 --- a/test/es-module/test-esm-specifiers.mjs +++ /dev/null @@ -1,82 +0,0 @@ -import { spawnPromisified } from '../common/index.mjs'; -import * as fixtures from '../common/fixtures.mjs'; -import { match, strictEqual } from 'node:assert'; -import { execPath } from 'node:process'; -import { describe, it } from 'node:test'; - - -describe('ESM: specifier-resolution=node', { concurrency: true }, () => { - it(async () => { - const { code, stderr, stdout } = await spawnPromisified(execPath, [ - '--no-warnings', - '--experimental-specifier-resolution=node', - '--input-type=module', - '--eval', - [ - 'import { strictEqual } from "node:assert";', - // CommonJS index.js - `import commonjs from ${JSON.stringify(fixtures.fileURL('es-module-specifiers/package-type-commonjs'))};`, - // ESM index.js - `import module from ${JSON.stringify(fixtures.fileURL('es-module-specifiers/package-type-module'))};`, - // Directory entry with main.js - `import main from ${JSON.stringify(fixtures.fileURL('es-module-specifiers/dir-with-main'))};`, - // Notice the trailing slash - `import success, { explicit, implicit, implicitModule } from ${JSON.stringify(fixtures.fileURL('es-module-specifiers/'))};`, - 'strictEqual(commonjs, "commonjs");', - 'strictEqual(module, "module");', - 'strictEqual(main, "main");', - 'strictEqual(success, "success");', - 'strictEqual(explicit, "esm");', - 'strictEqual(implicit, "cjs");', - 'strictEqual(implicitModule, "cjs");', - ].join('\n'), - ]); - - strictEqual(stderr, ''); - strictEqual(stdout, ''); - strictEqual(code, 0); - }); - - it('should throw when the file doesn\'t exist', async () => { - const { code, stderr, stdout } = await spawnPromisified(execPath, [ - '--no-warnings', - fixtures.path('es-module-specifiers/do-not-exist.js'), - ]); - - match(stderr, /Cannot find module/); - strictEqual(stdout, ''); - strictEqual(code, 1); - }); - - it('should throw when the omitted file extension is .mjs (legacy loader doesn\'t support it)', async () => { - const { code, stderr, stdout } = await spawnPromisified(execPath, [ - '--no-warnings', - '--experimental-specifier-resolution=node', - '--input-type=module', - '--eval', - `import whatever from ${JSON.stringify(fixtures.fileURL('es-module-specifiers/implicit-main-type-commonjs'))};`, - ]); - - match(stderr, /ERR_MODULE_NOT_FOUND/); - strictEqual(stdout, ''); - strictEqual(code, 1); - }); - - for ( - const item of [ - 'package-type-commonjs', - 'package-type-module', - '/', - '/index', - ] - ) it('should ', async () => { - const { code } = await spawnPromisified(execPath, [ - '--no-warnings', - '--experimental-specifier-resolution=node', - '--es-module-specifier-resolution=node', - fixtures.path('es-module-specifiers', item), - ]); - - strictEqual(code, 0); - }); -}); diff --git a/test/fixtures/es-module-specifiers/dir-with-main/main.js b/test/fixtures/es-module-specifiers/dir-with-main/main.js deleted file mode 100644 index dfdd47b877319c..00000000000000 --- a/test/fixtures/es-module-specifiers/dir-with-main/main.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 'main'; diff --git a/test/fixtures/es-module-specifiers/dir-with-main/package.json b/test/fixtures/es-module-specifiers/dir-with-main/package.json deleted file mode 100644 index 2a4fe3630817ab..00000000000000 --- a/test/fixtures/es-module-specifiers/dir-with-main/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "main": "./main.js" -} diff --git a/test/fixtures/es-module-specifiers/package-type-commonjs/a.js b/test/fixtures/es-module-specifiers/package-type-commonjs/a.js deleted file mode 100644 index 2e7700bc63e659..00000000000000 --- a/test/fixtures/es-module-specifiers/package-type-commonjs/a.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 'a'; diff --git a/test/fixtures/es-module-specifiers/package-type-commonjs/b.mjs b/test/fixtures/es-module-specifiers/package-type-commonjs/b.mjs deleted file mode 100644 index 137b8ce6429ac5..00000000000000 --- a/test/fixtures/es-module-specifiers/package-type-commonjs/b.mjs +++ /dev/null @@ -1 +0,0 @@ -export const b = 'b'; diff --git a/test/fixtures/es-module-specifiers/package-type-commonjs/c.cjs b/test/fixtures/es-module-specifiers/package-type-commonjs/c.cjs deleted file mode 100644 index 2d5312952fef87..00000000000000 --- a/test/fixtures/es-module-specifiers/package-type-commonjs/c.cjs +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - one: 1, - two: 2, - three: 3 -}; diff --git a/test/fixtures/es-module-specifiers/package-type-commonjs/index.mjs b/test/fixtures/es-module-specifiers/package-type-commonjs/index.mjs deleted file mode 100644 index ef2b30b19b61c5..00000000000000 --- a/test/fixtures/es-module-specifiers/package-type-commonjs/index.mjs +++ /dev/null @@ -1,21 +0,0 @@ -// js file that is common.js -import a from './a.js'; -// ESM with named export -import {b} from './b.mjs'; -// import 'c.cjs'; -import cjs from './c.cjs'; -// proves cross boundary fun bits -import jsAsEsm from '../package-type-module/a.js'; - -// named export from core -import {strictEqual, deepStrictEqual} from 'assert'; - -strictEqual(a, jsAsEsm); -strictEqual(b, 'b'); -deepStrictEqual(cjs, { - one: 1, - two: 2, - three: 3 -}); - -export default 'commonjs'; diff --git a/test/fixtures/es-module-specifiers/package-type-commonjs/package.json b/test/fixtures/es-module-specifiers/package-type-commonjs/package.json deleted file mode 100644 index 5bbefffbabee39..00000000000000 --- a/test/fixtures/es-module-specifiers/package-type-commonjs/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "commonjs" -} diff --git a/test/fixtures/es-module-specifiers/package-type-module/a.js b/test/fixtures/es-module-specifiers/package-type-module/a.js deleted file mode 100644 index 90bd54cd7f2e6d..00000000000000 --- a/test/fixtures/es-module-specifiers/package-type-module/a.js +++ /dev/null @@ -1 +0,0 @@ -export default 'a' diff --git a/test/fixtures/es-module-specifiers/package-type-module/b.mjs b/test/fixtures/es-module-specifiers/package-type-module/b.mjs deleted file mode 100644 index 137b8ce6429ac5..00000000000000 --- a/test/fixtures/es-module-specifiers/package-type-module/b.mjs +++ /dev/null @@ -1 +0,0 @@ -export const b = 'b'; diff --git a/test/fixtures/es-module-specifiers/package-type-module/c.cjs b/test/fixtures/es-module-specifiers/package-type-module/c.cjs deleted file mode 100644 index 2d5312952fef87..00000000000000 --- a/test/fixtures/es-module-specifiers/package-type-module/c.cjs +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - one: 1, - two: 2, - three: 3 -}; diff --git a/test/fixtures/es-module-specifiers/package-type-module/index.js b/test/fixtures/es-module-specifiers/package-type-module/index.js deleted file mode 100644 index a8baacb7c998c0..00000000000000 --- a/test/fixtures/es-module-specifiers/package-type-module/index.js +++ /dev/null @@ -1,21 +0,0 @@ -// ESM with only default -import a from './a.js'; -// ESM with named export -import {b} from './b.mjs'; -// import 'c.cjs'; -import cjs from './c.cjs'; -// import across boundaries -import jsAsCjs from '../package-type-commonjs/a.js' - -// named export from core -import {strictEqual, deepStrictEqual} from 'assert'; - -strictEqual(a, jsAsCjs); -strictEqual(b, 'b'); -deepStrictEqual(cjs, { - one: 1, - two: 2, - three: 3 -}); - -export default 'module'; diff --git a/test/fixtures/es-module-specifiers/package-type-module/package.json b/test/fixtures/es-module-specifiers/package-type-module/package.json deleted file mode 100644 index 3dbc1ca591c055..00000000000000 --- a/test/fixtures/es-module-specifiers/package-type-module/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "type": "module" -}