Skip to content

fix: support cjs files in compileDependencies (fix #7181)#7183

Open
scrollDynasty wants to merge 1 commit into
alibaba:masterfrom
scrollDynasty:fix-compile-dependencies-cjs
Open

fix: support cjs files in compileDependencies (fix #7181)#7183
scrollDynasty wants to merge 1 commit into
alibaba:masterfrom
scrollDynasty:fix-compile-dependencies-cjs

Conversation

@scrollDynasty

Copy link
Copy Markdown

Summary

This PR adds .cjs support to compileDependencies.

The Problem

Previously, .cjs dependency files were excluded from the compilation matching logic. As a result, packages resolving to .cjs entry points could ship modern syntax (like optional chaining) without being transpiled for older targets, causing runtime errors.

Changes

  • Added .cjs support: Included the extension in the dependency compilation matching logic.
  • Cross-engine update: Updated both Webpack and Rspack compilation paths.
  • Regression Testing: Added coverage for .cjs files used through compileDependencies.
  • Backward Compatibility: Kept existing behavior unchanged for .js, .jsx, .ts, .tsx, and .mjs.

Verification

Ran the targeted regression test suite:

pnpm exec vitest run packages/shared-config/tests/compileDependencies.test.ts 

Results:

@CLAassistant

CLAassistant commented May 13, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

希望支持.cjs 扩展名的编译

2 participants