![JavaScript Leaders Demand Oracle Release the JavaScript Trademark](https://cdn.sanity.io/images/cgdhsj6q/production/0f098d751c5c76cf31e305286be5fed3575bf954-1024x1024.webp?w=400&fit=max&auto=format)
Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
rollup-plugin-swc3
Advanced tools
SWC is an extensible Rust-based platform for the next generation of fast developer tools. This plugin is designed to replace rollup-plugin-typescript2
, @rollup/plugin-typescript
, @rollup/plugin-babel
and rollup-plugin-terser
for you.
sukkaw/rollup-plugin-swc | mentaljam/rollup-plugin-swc | nicholasxjy/rollup-plugin-swc2 | |
---|---|---|---|
minify your bundle in one pass1 | Yes | No | No |
Standalone swcMinify plugin | Yes | No | No |
Config Intellisense2 | Yes | No | No |
Reads your tsconfig.json and jsconfig.json | Yes3 | No | No |
ESM export | Full | Partial4 | No |
TypeScrit declarations | Yes | Yes | Yes |
Has testing | Yes | No | No |
$ npm i @swc/core rollup-plugin-swc3
# If you prefer yarn
# yarn add @swc/core rollup-plugin-swc3
# If you prefer pnpm
# pnpm add @swc/core rollup-plugin-swc3
// rollup.config.js
import { swc } from 'rollup-plugin-swc3';
export default {
input: 'xxxx',
output: {},
plugin: [
swc({
// All options are optional
include: /\.[jt]sx?$/, // default
exclude: /node_modules/, // default
tsconfig: 'tsconfig.json', // default
// And add your swc configuration here!
// "filename" will be ignored since it is handled by rollup
jsc: {}
}),
];
}
If you want autocompletion in your IDE or type check:
import { swc, defineRollupSwcOption } from 'rollup-plugin-swc3';
export default {
input: 'xxxx',
output: {},
plugin: [
swc(defineRollupSwcOption({
// ... There goes the plugin's configuration
})),
];
}
// or
/** @type {imoprt('rollup-plugin-swc3').PluginOptions} */
const swcPluginConfig = {}
include
and exclude
can be String | RegExp | Array<String | RegExp>
, when supplied it will override default values.importHelpers
, experimentalDecorators
, emitDecoratorMetadata
, jsxFactory
, jsxFragmentFactory
, target
, baseUrl
and paths
options from your tsconfig.json
or jsconfig.json
as default values if your doesn't provide corresponding swc configuration.
rollup-plugin-swc
won't use esModuleInterop
from your tsconfig.json
as swc requires module.type
configuration when module.noInterop
is given.jsconfig.json
will be ignored if tsconfig.json
and jsconfig.json
both exist.baseUrl
and paths
will be passed to swc directly. They won't affect how rollup resolve your imports. Please use other plugins to resolve your imports' aliases (e.g., add rollup-plugin-typescript-paths or rollup-plugin-tsconfig-paths before @rollup/plugin-node-resolve
).If you only want to use swc
to minify your bundle:
import { minify } from 'rollup-plugin-swc3'
export default {
plugins: [minify({
// swc's minify option here
// mangle: {}
// compress: {}
})],
}
If you want autocompletion in your IDE or type check:
import { minify, defineRollupSwcMinifyOption } from 'rollup-plugin-swc3'
export default {
plugins: [minify(defineRollupSwcMinifyOption({
// swc's minify option here
// mangle: {}
// compress: {}
}))],
}
// or
/** @type {import('@swc/core').JsMinifyOptions} */
const swcMinifyConfig = {}
You can write your Rollup config file in rollup.config.ts
, and use the following command:
rollup --config rollup.config.ts --configPlugin swc3
There are serveral ways to generate declaration file:
tsc
with emitDeclarationOnly
, the slowest way but you get type checking, it doesn't bundle the .d.ts
files.rollup-plugin-dts
which generates and bundle .d.ts
, also does type checking. It is used by this plugin as well.You can either configure it in your tsconfig.json
or in your rollup.config.js
.
// Vue JSX
import vueJsx from 'rollup-plugin-vue-jsx-compat'
import { swc, defineRollupSwcOption } from 'rollup-plugin-swc3';
export default {
input: 'xxxx',
output: {},
plugin: [
vueJsx(),
swc(defineRollupSwcOption({
jsc: {
react: {
pragma: 'vueJsxCompat'
}
}
})),
];
}
// Preact
import { swc, defineRollupSwcOption } from 'rollup-plugin-swc3';
export default {
input: 'xxxx',
output: {},
plugin: [
vueJsx(),
swc(defineRollupSwcOption({
jsc: {
react: {
pragma: 'h',
pragmaFrag: 'Fragment'
// To use preact/jsx-runtime:
// importSource: 'preact',
// runtime: 'automatic'
}
}
})),
];
}
rollup-plugin-swc © Sukka, Released under the MIT License.
Inspired by egoist's rollup-plugin-esbuild.
Authored and maintained by Sukka with help from contributors (list).
Personal Website · Blog · GitHub @SukkaW · Telegram Channel @SukkaChannel · Twitter @isukkaw · Keybase @sukka
If minify is called in Rollup's transform
phase, every individual module processed will result in a minify call. However, if minify is called in Rollup's renderChunk
phase, the minify will only be called once in one whole pass before Rollup generates bundle, results in a faster build. ↩
Autocompletion and type checking in your IDE ↩
extends
is not supported. ↩
mentaljam/rollup-plugin-swc
has both main
and module
fields in package.json
, but has no exports
field. ↩
0.3.0
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.FAQs
Use SWC with Rollup to transform ESNext and TypeScript code.
The npm package rollup-plugin-swc3 receives a total of 24,613 weekly downloads. As such, rollup-plugin-swc3 popularity was classified as popular.
We found that rollup-plugin-swc3 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.