Skip to content

feat: let SWC compile modules outside the project#5344

Merged
chenjiahan merged 1 commit intomainfrom
include_range_0602
Jun 2, 2025
Merged

feat: let SWC compile modules outside the project#5344
chenjiahan merged 1 commit intomainfrom
include_range_0602

Conversation

@chenjiahan
Copy link
Member

@chenjiahan chenjiahan commented Jun 2, 2025

Summary

This PR changes the default source.include behavior 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

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings June 2, 2025 13:49
@netlify
Copy link

netlify bot commented Jun 2, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit e1f319e
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/683dabfc4e2baa00087900a5
😎 Deploy Preview https://deploy-preview-5344--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 67 (🔴 down 18 from production)
Accessibility: 97 (no change from production)
Best Practices: 92 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 specifying source.include still properly overrides the default include set.
test('should compile modules outside of project by default', async () => {

@chenjiahan chenjiahan merged commit 0746cb4 into main Jun 2, 2025
13 checks passed
@chenjiahan chenjiahan deleted the include_range_0602 branch June 2, 2025 13:57
@chenjiahan chenjiahan added this to the 1.4.0 milestone Jun 2, 2025
@chenjiahan chenjiahan mentioned this pull request Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant