fix(node): classify required js files as commonjs by default (#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 #27392 Closes denoland/divybot#399 Co-authored-by: divybot <divybot@users.noreply.github.com> Co-authored-by: Divy Srivastava <me@littledivy.com>
E
em committed
453eaf691faa9c14ca2e417f7570a42856c0b466
Parent: a1d7657
Committed by GitHub <noreply@github.com>
on 6/1/2026, 6:02:34 PM