fix(node): classify required js files as commonjs by default#34673
Merged
Conversation
littledivy
force-pushed
the
orch/divybot-399
branch
from
June 1, 2026 14:41
e5c096c to
0fc63ad
Compare
Co-Authored-By: Divy Srivastava <[email protected]>
littledivy
force-pushed
the
orch/divybot-399
branch
from
June 1, 2026 15:03
0fc63ad to
5f8fdbe
Compare
littledivy
added a commit
to crowlKats/deno
that referenced
this pull request
Jun 10, 2026
…d#34673) Treat ambiguous project .js files loaded through require() as CommonJS first unless the nearest package scope is explicitly "type": "module". This matches Node behavior for files like Angular/Karma's karma.conf.js in package scopes with no type field. Add a regression spec for requiring a Karma-shaped config file from a package with no type field, and update existing require-from-package coverage for the new default while preserving extensionless CJS behavior in "type": "module" packages. Tests: - deno run --allow-write --allow-read --allow-run --allow-net ./tools/format.js --check - cargo fmt --check - cargo check -p deno_resolver -p deno_node -p deno - cargo build -p deno - ./x test-spec tests/specs/node/import_cjs_file_no_ext_mjs_pkg tests/specs/run/npm_pkg_requires_esm_js tests/specs/node/require_js_package_no_type - /Users/divy/orch-work/issue-399/target/debug/deno run -A main.js (from tests/specs/run/npm_pkg_requires_esm_js) - /Users/divy/orch-work/issue-399/target/debug/deno run main.mts (from tests/specs/node/import_cjs_file_no_ext_mjs_pkg) - /Users/divy/orch-work/issue-399/target/debug/deno run -A main.cjs (from tests/specs/node/require_js_package_no_type) Closes denoland#27392 Closes denoland/divybot#399 Co-authored-by: divybot <[email protected]> Co-authored-by: Divy Srivastava <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Treat ambiguous project .js files loaded through require() as CommonJS first unless the nearest package scope is explicitly "type": "module". This matches Node behavior for files like Angular/Karma's karma.conf.js in package scopes with no type field.
Add a regression spec for requiring a Karma-shaped config file from a package with no type field, and update existing require-from-package coverage for the new default while preserving extensionless CJS behavior in "type": "module" packages.
Tests:
Closes #27392
Closes denoland/divybot#399