Use SWC with Rollup to transform / minify ESNext and TypeScript code.
MIT License
Bot releases are visible (Hide)
New feature viteMinify
to use swc's minification in Vite.
import { defineConfig } from 'vite';
import { viteMinify } from 'rollup-plugin-swc3'
export default defineConfig({
plugins: [
viteMinify({
// swc's minify option here
// mangle: {}
// compress: {}
}),
],
})
Published by SukkaW 6 months ago
Published by SukkaW about 1 year ago
Published by SukkaW about 1 year ago
rollup-plugin-swc3
now will always provide baseUrl
(resolve to an absolute path) to swc as long as the paths
is specified in the tsconfig.json
or jsconfig.json
being read.Published by SukkaW about 1 year ago
rollup-plugin-swc3
now will resolve baseUrl
to an absolute path against the tsconfig.json
and jsconfig.json
being read.swc
: https://github.com/swc-project/swc/issues/7799 and https://github.com/swc-project/swc/issues/7800.Published by SukkaW over 1 year ago
The support for 'use client'
and 'use server'
has been separated into a standalone rollup plugin rollup-swc-preserve-directives
, maintained by @huozhi and me. The previous preserveUseDirective
named export is retained for the backward compatibility.
Published by SukkaW over 1 year ago
Add support for bundling library for React Server Component with the proper 'use client'
and 'use server'
directives handling:
rollup.config.js
:// rollup.config.js
// Import `preserveUseDirective` from `rollup-plugin-swc3`...
- import { swc } from 'rollup-plugin-swc3';
+ import { swc, preserveUseDirective } from 'rollup-plugin-swc3';
export default {
input: 'xxxx',
output: {},
plugins: [
swc(),
+ preserveUseDirective()
];
}
Published by SukkaW over 1 year ago
Published by SukkaW over 1 year ago
Published by SukkaW almost 2 years ago
extensions
.
include
/ exclude
, this provides a granular way to specify the files that will be processed by the plugin.Published by SukkaW about 2 years ago
rollup-plugin-swc
now supports both Rollup 2 and Rollup 3.Published by SukkaW about 2 years ago
extends
from tsconfig.json
/jsconfig.json
.tsconfig.json
/jsconfig.json
file to tsconfig
option.tsconfig.json
/jsconfig.json
from the source file that is currently being transpiled, rollup-plugin-swc
's behavior is now aligned with tsc
.Published by SukkaW about 2 years ago
rollup-plugin-swc
now also respects jsx
option from tsconfig.json
when no corresponding swc option is provided.
jsxImportSource
from tsconfig.json
will be passed to swc's jsc.transform.react.importSource
tsconfig.json
specifies jsx: react-jsx
or jsx: react-jsxdev
, rollup-plugin-swc
will set jsx.tramsform.react.runtime
to automatic
, otherwise it will be classic
.
rollup-plugin-swc
will also set jsx.tramsform.react.development
to true
if tsconfig.json
specifies jsx: react-jsxdev
.Published by SukkaW about 2 years ago
Remove unused dependency (@huozhi #20)
Published by SukkaW about 2 years ago
Published by SukkaW about 2 years ago
id
to swc's filename
option.
.swcrc
, and also enables some other swc's functionality.ts/.tsx
to .mjs/.js/.cjs/.jsx
.
.js/.jsx
extension for TypeScript with "moduleResolution": "Node16"
. So rollup-plugin-swc will now try all possible extensions.import Foo from 'foo.jsx'
, rollup-plugin-swc will search for foo.ts
, foo.tsx
, foo.mjs
, foo.js
, foo.jsx
.Published by SukkaW over 2 years ago
transform
phase.
renderChunk
phase, which is a one-pass process, resulting in even faster build performance.peerDependencies
of swc has been updated to >=1.2.165
. You will need to bump the version of swc to 1.2.165 or higher after this release.Published by SukkaW over 2 years ago
baseUrl
and paths
from your tsconfig.json
(and jsconfig.json
).
@rollup/plugin-node-resolve
).Published by SukkaW almost 3 years ago
.mjs
extension supportdefault
for use with rollup's --configPlugin