- Fix: respect legacy decorators. See #67
- The minimum required version has been bumped from 12 to 16.
- Now when TypeScript 5 is detected in your projects will
rollup-plugin-swc3
enable decorators by default (with decorator version2022-03
), otherwise it is depended byexperimentalDecorators
fromtsconfig.json
(and decorator version2021-12
will be used). See #65
-
New feature
viteMinify
to use swc's minification in Vite.- When used, it will disable Vite's built-in minification and use swc's minification instead.
import { defineConfig } from 'vite'; import { viteMinify } from 'rollup-plugin-swc3' export default defineConfig({ plugins: [ viteMinify({ // swc's minify option here // mangle: {} // compress: {} }), ], })
- Fix #63
- Previously,
rollup-plugin-swc3
only handled relativecompilerOptions.baseUrl
whencompilerOptions.paths
is specified. It is fixed in #64, nowrollup-plugin-swc3
will handle relativecompilerOptions.baseUrl
as long as it is specified.
- Previously,
- Fix #58
rollup-plugin-swc3
now will only perform module resolution inside the files specified ininclude
andexclude
options.
- Replace
rollup-swc-preserve-directives
withrollup-preserve-directives
- Bump
rollup-swc-preserve-directives
to the latest version
- Pass correct options to
@swc/core
(#54 by @kdy1)
- Add warning message when tsconfig is invalid
- Add rollup 4 official support
- Fix #41
rollup-plugin-swc3
now will always providebaseUrl
(resolve to an absolute path) to swc as long as thepaths
is specified in thetsconfig.json
orjsconfig.json
being read.
- Fix #41
rollup-plugin-swc3
now will resolvebaseUrl
to an absolute path against thetsconfig.json
andjsconfig.json
being read.- This is to align with the behavior change of the
swc
: swc-project/swc#7799 and swc-project/swc#7800.
- The support for
'use client'
and'use server'
has been separated into a standalone rollup pluginrollup-swc-preserve-directives
, maintained by @huozhi and me. The previouspreserveUseDirective
named export is retained for the backward compatibility.
-
Add support for bundling library for React Server Component with the proper
'use client'
and'use server'
directives handling:- Merge duplicated directives in the final bundles
- Multiple output chunks will have their own separated directives, useful when bundling client only code and server only code in different bundles.
- Not enabled by default. manually opt-in by changing two lines of code in your
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() ]; }
- Enable CI auto publish release + npm provenance
- Fix TypeScript declaration of
include
andexclude
option (#32)
- Add new option
extensions
.- Along with
include
/exclude
, this provides a granular way to specify the files that will be processed by the plugin. - For extensionless imports the plugin will search and resolve files for extensions in the order specified.
- Along with
- Add Rollup 3.0.0 support.
rollup-plugin-swc
now supports both Rollup 2 and Rollup 3.
- Supports
extends
fromtsconfig.json
/jsconfig.json
. - Supports passing a full path of a
tsconfig.json
/jsconfig.json
file totsconfig
option. - When finding the nearest
tsconfig.json
/jsconfig.json
from the source file that is currently being transpiled,rollup-plugin-swc
's behavior is now aligned withtsc
.
rollup-plugin-swc
now also respectsjsx
option fromtsconfig.json
when no corresponding swc option is provided.jsxImportSource
fromtsconfig.json
will be passed to swc'sjsc.transform.react.importSource
- if
tsconfig.json
specifiesjsx: react-jsx
orjsx: react-jsxdev
,rollup-plugin-swc
will setjsx.tramsform.react.runtime
toautomatic
, otherwise it will beclassic
.- Currently, swc doesn't support preserving JSX, and will always transpile JSX into javascript code.
rollup-plugin-swc
will also setjsx.tramsform.react.development
totrue
iftsconfig.json
specifiesjsx: react-jsxdev
.
- Remove unused dependency (@huozhi #20)
- Fix some minor issues.
- Automatically pass rollup's file
id
to swc'sfilename
option.- It should help swc find the
.swcrc
, and also enables some other swc's functionality
- It should help swc find the
- Automatically mapping
.ts/.tsx
to.mjs/.js/.cjs/.jsx
.- When using native ESM, import path requires
.js/.jsx
extension for TypeScript with"moduleResolution": "Node16"
. So rollup-plugin-swc will now try all possible extensions. - E.g. if you write
import Foo from 'foo.jsx'
, rollup-plugin-swc will search forfoo.ts
,foo.tsx
,foo.mjs
,foo.js
,foo.jsx
. - PRs are welcome if you want to make rollup-plugin-swc more spec compliant.
- When using native ESM, import path requires
- Completely disable swc minify during rollup's
transform
phase.- Now all minify will be done in rollup's
renderChunk
phase, which is a one-pass process, resulting in even faster build performance.
- Now all minify will be done in rollup's
- Remove the workaround for rollup's virtual module that is introduced in 0.1.2 (#1)
- swc has fixed the issue, and the corresponding test case has been added in swc-project/swc#4255
- The
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.
- Standalone minify plugin
- Support reading
baseUrl
andpaths
from yourtsconfig.json
(andjsconfig.json
).- These fields 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
).
- These fields 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
- Add
.mjs
extension support - Export a
default
for use with rollup's--configPlugin
- Fix a bug caused by the workaround introduced in 0.1.2
- Fix transform failed when rollup virtual module is involved.
- Support read default config from
jsconfig.json
as welljsconfig.json
will be ignored iftsconfig.json
andjsconfig.json
both exists.
- Add
.npmignore
to reduce the size of the package. - Use
deepmerge
to merge plugin options config with your giventsconfig.json
.
The first release.