feat: let SWC compile modules outside the project#5344
Merged
chenjiahan merged 1 commit intomainfrom Jun 2, 2025
Merged
Conversation
✅ Deploy Preview for rsbuild ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adjusts the default SWC compilation scope so modules outside the project root are included, updates affected tests and snapshots, and simplifies the applyScriptCondition API by removing the context parameter.
- Removed the implicit root‐directory include filter in
applyScriptCondition - Updated snapshots across multiple plugins to reflect the new include behavior
- Revised the end-to-end test to assert that external modules compile by default
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/core/src/plugins/swc.ts | Dropped context parameter and removed root‐path restriction |
| e2e/cases/source/source-include/index.test.ts | Changed test to expect default compilation of external modules |
Multiple __snapshots__/*.snap files |
Snapshot updates for removed include-and wrappers |
Comments suppressed due to low confidence (2)
packages/core/src/plugins/swc.ts:44
- The comment still mentions "app directory" even though the code now applies to all modules. Update it to reflect the new behavior, e.g., "compile all modules except those in node_modules".
// compile all modules in the app directory, exclude node_modules
e2e/cases/source/source-include/index.test.ts:5
- The test suite no longer covers customizing
source.include. Consider adding a test case to verify that specifyingsource.includestill properly overrides the default include set.
test('should compile modules outside of project by default', async () => {
This was referenced Jun 2, 2025
Merged
Merged
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.

Summary
This PR changes the default
source.includebehavior to make SWC compile modules outside the project, which ensures that JavaScript modules in the monorepo can be compiled correctly to avoid compatibility issues.While this may slightly increase compile times in certain cases within a monorepo, it can help to improve the stability and browser compatibility of web apps.
Checklist