Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated packages.md and added --experimental-detect-module flag #51089

Merged
merged 5 commits into from
Dec 9, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 that contains syntax that
only parses successfully as [ES modules][], such as `import` or `export`
shubherthi-mitra marked this conversation as resolved.
Show resolved Hide resolved
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.

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