Using swc as a replacement of RollUp in my project #1322
Replies: 2 comments
|
I'm sorry but currently plugin system is not implemented properly. (I think it will be fixed soon.) Currently only guide for writing plugin is https://swc.rs/blog/2019/11/30/announcing-swc-1.1.0#plugin but note that type definitions are bit outdated. |
|
Using SWC as a Rollup replacement is doable but worth understanding where the tools differ before committing: SWC is a transpiler/bundler, Rollup is a bundler/optimizer:
The common pattern — SWC + Rollup together: // rollup.config.js
import swc from 'rollup-plugin-swc3';
export default {
input: 'src/index.ts',
output: { file: 'dist/index.js', format: 'esm' },
plugins: [
swc({
jsc: { parser: { syntax: 'typescript' }, target: 'es2020' }
})
]
};This gives you SWC's speed for TypeScript/JSX transformation while keeping Rollup's tree shaking and output quality. When to use SWC as a full Rollup replacement: What's your specific build pipeline? That would help clarify which approach makes more sense. |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I am using RollUp to produce a bundle of React components. I used some plugins in Roll Up config. One of them is a plugin to transpile a library called Treat JS: https://github.com/seek-oss/treat.
Is there any guide on how to write a plugin for swc ? I intend to explore writing a plugin for Treat JS.
Thank you and Happy New Year :)
All reactions