From b8ab5332a9195179056b9ac328343d646b73cf7f Mon Sep 17 00:00:00 2001 From: Geoffrey Booth Date: Mon, 2 Dec 2024 14:43:55 -0800 Subject: [PATCH] module: remove --experimental-default-type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/56092 Reviewed-By: Yagiz Nizipli Reviewed-By: Matteo Collina Reviewed-By: Michaël Zasso Reviewed-By: Jacob Smith --- doc/api/cli.md | 49 +---- doc/api/esm.md | 14 +- doc/api/module.md | 3 +- doc/api/packages.md | 53 +++--- doc/node.1 | 5 - lib/internal/main/check_syntax.js | 4 +- lib/internal/main/eval_stdin.js | 3 +- lib/internal/main/eval_string.js | 3 +- lib/internal/main/run_main_module.js | 20 +-- lib/internal/modules/esm/formats.js | 4 +- lib/internal/modules/esm/get_format.js | 98 ++++------ lib/internal/modules/esm/load.js | 6 +- lib/internal/modules/run_main.js | 29 +-- lib/internal/process/execution.js | 2 +- src/node_options.cc | 11 -- src/node_options.h | 1 - test/es-module/test-esm-detect-ambiguous.mjs | 13 -- .../test-esm-extensionless-esm-and-wasm.mjs | 1 - .../test-esm-type-flag-cli-entry.mjs | 96 ---------- test/es-module/test-esm-type-flag-errors.mjs | 103 ----------- .../test-esm-type-flag-loose-files.mjs | 75 -------- .../test-esm-type-flag-package-scopes.mjs | 167 ------------------ .../test-esm-type-flag-string-input.mjs | 46 ----- test/es-module/test-typescript-commonjs.mjs | 13 -- test/es-module/test-typescript-module.mjs | 38 ---- test/es-module/test-typescript.mjs | 91 +--------- test/fixtures/es-modules/loose.js | 3 - .../es-modules/package-without-type/noext-esm | 1 - test/parallel/test-runner-module-mocking.js | 3 +- 29 files changed, 86 insertions(+), 869 deletions(-) delete mode 100644 test/es-module/test-esm-type-flag-cli-entry.mjs delete mode 100644 test/es-module/test-esm-type-flag-errors.mjs delete mode 100644 test/es-module/test-esm-type-flag-loose-files.mjs delete mode 100644 test/es-module/test-esm-type-flag-package-scopes.mjs delete mode 100644 test/es-module/test-esm-type-flag-string-input.mjs diff --git a/doc/api/cli.md b/doc/api/cli.md index 11f1e4cb3cde36..412cf187d340fb 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -25,16 +25,14 @@ For more info about `node inspect`, see the [debugger][] documentation. The program entry point is a specifier-like string. If the string is not an absolute path, it's resolved as a relative path from the current working -directory. That path is then resolved by [CommonJS][] module loader, or by the -[ES module loader][Modules loaders] if [`--experimental-default-type=module`][] -is passed. If no corresponding file is found, an error is thrown. +directory. That path is then resolved by [CommonJS][] module loader. If no +corresponding file is found, an error is thrown. If a file is found, its path will be passed to the [ES module loader][Modules loaders] under any of the following conditions: * The program was started with a command-line flag that forces the entry - point to be loaded with ECMAScript module loader, such as `--import` or - [`--experimental-default-type=module`][]. + point to be loaded with ECMAScript module loader, such as `--import`. * The file has an `.mjs` extension. * The file does not have a `.cjs` extension, and the nearest parent `package.json` file contains a top-level [`"type"`][] field with a value of @@ -47,9 +45,8 @@ Otherwise, the file is loaded using the CommonJS module loader. See When loading, the [ES module loader][Modules loaders] loads the program entry point, the `node` command will accept as input only files with `.js`, -`.mjs`, or `.cjs` extensions; with `.wasm` extensions when -[`--experimental-wasm-modules`][] is enabled; and with no extension when -[`--experimental-default-type=module`][] is passed. +`.mjs`, or `.cjs` extensions; and with `.wasm` extensions when +[`--experimental-wasm-modules`][] is enabled. ## Options @@ -910,38 +907,6 @@ flows within the application. As such, it is presently recommended to be sure your application behaviour is unaffected by this change before using it in production. -### `--experimental-default-type=type` - - - -> Stability: 1.0 - Early development - -Define which module system, `module` or `commonjs`, to use for the following: - -* String input provided via `--eval` or STDIN, if `--input-type` is unspecified. - -* Files ending in `.js` or with no extension, if there is no `package.json` file - present in the same folder or any parent folder. - -* Files ending in `.js` or with no extension, if the nearest parent - `package.json` field lacks a `"type"` field; unless the `package.json` folder - or any parent folder is inside a `node_modules` folder. - -In other words, `--experimental-default-type=module` flips all the places where -Node.js currently defaults to CommonJS to instead default to ECMAScript modules, -with the exception of folders and subfolders below `node_modules`, for backward -compatibility. - -Under `--experimental-default-type=module` and `--experimental-wasm-modules`, -files with no extension will be treated as WebAssembly if they begin with the -WebAssembly magic number (`\0asm`); otherwise they will be treated as ES module -JavaScript. - ### `--experimental-transform-types`