Skip to content

Commit

Permalink
doc: add note regarding --experimental-detect-module
Browse files Browse the repository at this point in the history
PR-URL: #51089
Fixes: #51057
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Jacob Smith <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
  • Loading branch information
shubherthi-mitra authored and RafaelGSS committed Dec 15, 2023
1 parent 087fb09 commit 637ffce
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions doc/api/packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ expressions:
* Strings passed in as an argument to `--eval`, or piped to `node` via `STDIN`,
with the flag `--input-type=module`.

* Code that contains syntax that only parses successfully as [ES modules][],
such as `import` or `export` statements or `import.meta`, when the code has no
explicit marker of how it should be interpreted. Explicit markers are `.mjs`
or `.cjs` extensions, `package.json` `"type"` fields with either `"module"` or
`"commonjs"` values, or `--input-type` or `--experimental-default-type` flags.
Dynamic `import()` expressions are supported in either CommonJS or ES modules
and would not cause a file to be treated as an ES module.
* When using [`--experimental-detect-module`][], code containing syntax only
successfully parsed as [ES modules][], such as `import` or `export`
statements or `import.meta`, having no explicit marker of how it should be
interpreted. Explicit markers are `.mjs` or `.cjs` extensions, `package.json`
`"type"` fields with either `"module"` or `"commonjs"` values, or
`--input-type` or `--experimental-default-type` flags. Dynamic `import()`
expressions are supported in either CommonJS or ES modules and would not
cause a file to be treated as an ES module.

Node.js will treat the following as [CommonJS][] when passed to `node` as the
initial input, or when referenced by `import` statements or `import()`
Expand Down Expand Up @@ -1362,6 +1363,7 @@ This field defines [subpath imports][] for the current package.
[`"type"`]: #type
[`--conditions` / `-C` flag]: #resolving-user-conditions
[`--experimental-default-type`]: cli.md#--experimental-default-typetype
[`--experimental-detect-module`]: cli.md#--experimental-detect-module
[`--no-addons` flag]: cli.md#--no-addons
[`ERR_PACKAGE_PATH_NOT_EXPORTED`]: errors.md#err_package_path_not_exported
[`esm`]: https://github.com/standard-things/esm#readme
Expand Down

0 comments on commit 637ffce

Please sign in to comment.