Skip to content

feat: add SWC transform and minify support#10201

Merged
GiveMe-A-Name merged 3 commits intomainfrom
feat/exports-javascript-compiler-api
Apr 27, 2025
Merged

feat: add SWC transform and minify support#10201
GiveMe-A-Name merged 3 commits intomainfrom
feat/exports-javascript-compiler-api

Conversation

@GiveMe-A-Name
Copy link
Copy Markdown
Member

@GiveMe-A-Name GiveMe-A-Name commented Apr 27, 2025

Summary

Consider upper layer (rslib, rsbuild or rspress) and js plugin need parse [t|j]s file or minify js. We should provide a compiler api to transform js & minify it.

So we reuse swc transform and minify feature.

  • Updated exports.ts to include SWC options in the experiments interface.

Related issue (if exists):

#8998

Checklist

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

- Updated `exports.ts` to include SWC options in the experiments interface.
@GiveMe-A-Name GiveMe-A-Name requested review from SyMind and Copilot April 27, 2025 03:00
@github-actions github-actions bot added team The issue/pr is created by the member of Rspack. release: feature release: feature related release(mr only) labels Apr 27, 2025
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 introduces support for SWC-based transformation and minification to provide a compiler API for transforming and minifying JavaScript. Key changes include:

  • Adding asynchronous functions (transform and minify) in packages/rspack/src/swc.ts.
  • Exposing SWC functionality via experiments in packages/rspack/src/exports.ts.
  • Implementing the corresponding native bindings and tasks in the Rust node binding (crates/node_binding).

Reviewed Changes

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

Show a summary per file
File Description
packages/rspack/src/swc.ts Introduces async transform and minify functions
packages/rspack/src/exports.ts Exposes SWC transform and minify in the experiments
crates/node_binding/src/swc.rs Implements async SWC tasks for transformation/minification
crates/node_binding/src/lib.rs Re-exports SWC functions
crates/node_binding/rspack.wasi.cjs & browser.js Exports SWC functions for WASI and browser targets
crates/node_binding/Cargo.toml Adds dependency on rspack_javascript_compiler
Comments suppressed due to low confidence (1)

packages/rspack/src/exports.ts:349

  • Please add tests covering the new SWC transform and minify functionality to ensure the experimental API behaves as expected.
swc: {

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 27, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit c96d282
🔍 Latest deploy log https://app.netlify.com/sites/rspack/deploys/680da5596eb1980008ddc283

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 27, 2025

CodSpeed Performance Report

Merging #10201 will not alter performance

Comparing feat/exports-javascript-compiler-api (c96d282) with main (eff503e)

🎉 Hooray! codspeed-node just leveled up to 4.0.1!

A heads-up, this is a breaking change and it might affect your current performance baseline a bit. But here's the exciting part - it's packed with new, cool features and promises improved result stability 🥳!
Curious about what's new? Visit our releases page to delve into all the awesome details about this new version.

Summary

✅ 11 untouched benchmarks

SyMind
SyMind previously approved these changes Apr 27, 2025
@GiveMe-A-Name GiveMe-A-Name merged commit 6679fec into main Apr 27, 2025
34 checks passed
@GiveMe-A-Name GiveMe-A-Name deleted the feat/exports-javascript-compiler-api branch April 27, 2025 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: feature release: feature 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.

3 participants