Skip to content

Commit 637ffce

Browse files
shubherthi-mitraRafaelGSS
authored andcommitted
doc: add note regarding --experimental-detect-module
PR-URL: #51089 Fixes: #51057 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 087fb09 commit 637ffce

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

doc/api/packages.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ expressions:
6969
* Strings passed in as an argument to `--eval`, or piped to `node` via `STDIN`,
7070
with the flag `--input-type=module`.
7171

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

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

0 commit comments

Comments
 (0)