Skip to content

fix: should validate options of builtin swc loader#10055

Merged
LingyuCoder merged 4 commits intomainfrom
fix/validate-builtin-swc-loader-options
Apr 17, 2025
Merged

fix: should validate options of builtin swc loader#10055
LingyuCoder merged 4 commits intomainfrom
fix/validate-builtin-swc-loader-options

Conversation

@LingyuCoder
Copy link
Copy Markdown
Contributor

@LingyuCoder LingyuCoder commented Apr 16, 2025

Summary

fix #8180

Should validate options of builtin:swc-loader

This should be a breaking change to those projects that use incorrect swc options.

Checklist

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

@LingyuCoder LingyuCoder requested a review from Copilot April 16, 2025 09:42
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 16, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit dc171b4
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/680074de65623c0008cbb68b

Copy link
Copy Markdown
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 pull request fixes the validation logic for options passed to the built‑in swc‑loader. It adjusts the signature and return values of the validate function, adds dedicated swc‑loader validation within the rule set configurations, and updates related tests to verify the behavior.

  • Updated the validate function in util/validate.ts to include an optional output flag and adjust its error handling.
  • Integrated swc‑loader option validation via new Zod cross‑checker patterns in config/zod.ts.
  • Added a new Zod schema for plugin import configuration and corresponding tests.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/rspack/src/util/validate.ts Modified validate() signature and adjusted error return values for improved swc-loader options validation.
packages/rspack/src/config/zod.ts Introduced swc-loader validation in rule set options with dedicated cross-checker patterns.
packages/rspack/src/config/utils.ts Updated the signature for cross-field validation tests.
packages/rspack/src/builtin-loader/swc/pluginImport.ts Added a new Zod schema for swc-loader plugin import configuration.
packages/rspack-test-tools/tests/configCases/builtin-swc-loader/validate/rspack.config.js Provided a test case to verify the swc-loader options validation.
packages/rspack-test-tools/tests/configCases/builtin-swc-loader/validate/errors.js Defined expected error messages for invalid swc-loader options.

@github-actions github-actions bot added release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack. labels Apr 16, 2025
@LingyuCoder LingyuCoder force-pushed the fix/validate-builtin-swc-loader-options branch from 94dfa3d to bbcfa80 Compare April 16, 2025 11:34
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 16, 2025

CodSpeed Performance Report

Merging #10055 will not alter performance

Comparing fix/validate-builtin-swc-loader-options (dc171b4) with main (c5c10eb)

Summary

✅ 11 untouched benchmarks

@LingyuCoder LingyuCoder marked this pull request as ready for review April 17, 2025 02:58
@LingyuCoder LingyuCoder requested a review from chenjiahan as a code owner April 17, 2025 02:58
Copy link
Copy Markdown
Member

@chenjiahan chenjiahan left a comment

Choose a reason for hiding this comment

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

Can you run ecosystem CI to see if this PR will break downstream projects

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 17, 2025

📝 Ecosystem CI detail: Open

suite result
modernjs ❌ failure
rspress ✅ success
devserver ❌ failure
rsdoctor ❌ failure
examples ✅ success
rslib ✅ success
lynx-stack ❌ failure
nuxt ✅ success
rsbuild ✅ success
plugin ✅ success

@LingyuCoder
Copy link
Copy Markdown
Contributor Author

📝 Ecosystem CI detail: Open

suite result
modernjs ❌ failure
rspress ✅ success
devserver ❌ failure
rsdoctor ❌ failure
examples ✅ success
rslib ✅ success
lynx-stack ❌ failure
nuxt ✅ success
rsbuild ✅ success
plugin ✅ success

According to the eco-ci result of latest main here, the only difference is rsdoctor which fails because of using options.sourceMap

Copy link
Copy Markdown
Member

@chenjiahan chenjiahan left a comment

Choose a reason for hiding this comment

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

LGTM

@LingyuCoder LingyuCoder merged commit d383318 into main Apr 17, 2025
44 checks passed
@LingyuCoder LingyuCoder deleted the fix/validate-builtin-swc-loader-options branch April 17, 2025 06:27
@colinaaa colinaaa mentioned this pull request May 25, 2025
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: rspack serve fails with InvalidArg if Rule.options has function in it

4 participants