X Tutup
Skip to content

doc: remove extensionless CJS exception for type:module#62176

Open
mcollina wants to merge 1 commit intonodejs:mainfrom
mcollina:doc/remove-extensionless-cjs-exception
Open

doc: remove extensionless CJS exception for type:module#62176
mcollina wants to merge 1 commit intonodejs:mainfrom
mcollina:doc/remove-extensionless-cjs-exception

Conversation

@mcollina
Copy link
Member

The CJS documentation has included an exception since v16 (added in #41383) stating that extensionless files in type: "module" packages are recognized as CommonJS when included via require(). This exception conflicts with the ESM resolution specification which states that extensionless files within a package scope with an explicit type field follow the format of the type field.

Since #61600, the behavior on main already matches the ESM spec: extensionless files respect the type field. This change aligns the CJS documentation accordingly by removing the contradicting exception.

For v25.x, #62083 restores the documented exception as a targeted fix to avoid breaking packages like yargs v17 that relied on the old behavior.

Refs: #61600
Refs: #62083
Refs: #61971

Remove the documented exception that extensionless files in
type: "module" packages are recognized as CommonJS when included
via require(). This exception conflicted with the ESM resolution
specification which states that extensionless files within a
package scope with an explicit type field follow the format of
the type field.

The behavior on main already matches the ESM spec since nodejs#61600,
this change aligns the CJS documentation accordingly.

Refs: nodejs#61600
Refs: nodejs#62083
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/loaders

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. module Issues and PRs related to the module subsystem. labels Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Issues and PRs related to the documentations. module Issues and PRs related to the module subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

X Tutup