Skip to content

fix(plugin-svelte): should transpile JS code in .svelte files#5270

Merged
chenjiahan merged 2 commits intomainfrom
svelte_transpile_0519
May 19, 2025
Merged

fix(plugin-svelte): should transpile JS code in .svelte files#5270
chenjiahan merged 2 commits intomainfrom
svelte_transpile_0519

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

Summary

Use swc-loader to transpile JavaScript code in .svelte files to ensure that the compiled JS code can be downgraded as expected.

More test cases will be added in later PRs.

Related Links

https://discord.com/channels/977448667919286283/1167025132905173063/1373701903644622878

Checklist

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

Copilot AI review requested due to automatic review settings May 19, 2025 05:46
@netlify
Copy link
Copy Markdown

netlify bot commented May 19, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit 979bd50
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/682ac6c601d4a400088d3ca2
😎 Deploy Preview https://deploy-preview-5270--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: 86 (no change 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
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 PR enables transpilation of JavaScript inside .svelte files by reusing the existing SWC loader when targeting Svelte v5.

  • Pull SWC loader config from the JS rule and apply it to the Svelte rule if svelte5 is enabled
  • Ensure the Svelte loader chain is properly terminated with .end()
  • Exclude Svelte-generated JS/TS files from the main JS rule to avoid double-processing
Comments suppressed due to low confidence (2)

packages/plugin-svelte/src/index.ts:123

  • There are no tests covering the new code path for svelte5 JS transpilation in .svelte files. Add unit tests to prevent regressions.
if (svelte5 && jsRule) {

packages/plugin-svelte/src/index.ts:114

  • Update the function’s JSDoc or README to document the new SWC-based JS transpilation behavior for .svelte files when svelte5 is enabled.
export function pluginSvelte(options: PluginSvelteOptions = {}): RsbuildPlugin {

@chenjiahan chenjiahan merged commit 800682f into main May 19, 2025
11 checks passed
@chenjiahan chenjiahan deleted the svelte_transpile_0519 branch May 19, 2025 05:56
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.

2 participants