- 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-swc3enable decorators by default (with decorator version2022-03), otherwise it is depended byexperimentalDecoratorsfromtsconfig.json(and decorator version2021-12will be used). See #65
-
New feature
viteMinifyto 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-swc3only handled relativecompilerOptions.baseUrlwhencompilerOptions.pathsis specified. It is fixed in #64, nowrollup-plugin-swc3will handle relativecompilerOptions.baseUrlas long as it is specified.
- Previously,
- Fix #58
rollup-plugin-swc3now will only perform module resolution inside the files specified inincludeandexcludeoptions.
- Replace
rollup-swc-preserve-directiveswithrollup-preserve-directives
- Bump
rollup-swc-preserve-directivesto 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-swc3now will always providebaseUrl(resolve to an absolute path) to swc as long as thepathsis specified in thetsconfig.jsonorjsconfig.jsonbeing read.
- Fix #41
rollup-plugin-swc3now will resolvebaseUrlto an absolute path against thetsconfig.jsonandjsconfig.jsonbeing 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 previouspreserveUseDirectivenamed 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
includeandexcludeoption (#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-swcnow supports both Rollup 2 and Rollup 3.
- Supports
extendsfromtsconfig.json/jsconfig.json. - Supports passing a full path of a
tsconfig.json/jsconfig.jsonfile totsconfigoption. - When finding the nearest
tsconfig.json/jsconfig.jsonfrom the source file that is currently being transpiled,rollup-plugin-swc's behavior is now aligned withtsc.
rollup-plugin-swcnow also respectsjsxoption fromtsconfig.jsonwhen no corresponding swc option is provided.jsxImportSourcefromtsconfig.jsonwill be passed to swc'sjsc.transform.react.importSource- if
tsconfig.jsonspecifiesjsx: react-jsxorjsx: react-jsxdev,rollup-plugin-swcwill setjsx.tramsform.react.runtimetoautomatic, otherwise it will beclassic.- Currently, swc doesn't support preserving JSX, and will always transpile JSX into javascript code.
rollup-plugin-swcwill also setjsx.tramsform.react.developmenttotrueiftsconfig.jsonspecifiesjsx: react-jsxdev.
- Remove unused dependency (@huozhi #20)
- Fix some minor issues.
- Automatically pass rollup's file
idto swc'sfilenameoption.- It should help swc find the
.swcrc, and also enables some other swc's functionality
- It should help swc find the
- Automatically mapping
.ts/.tsxto.mjs/.js/.cjs/.jsx.- When using native ESM, import path requires
.js/.jsxextension 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
transformphase.- Now all minify will be done in rollup's
renderChunkphase, 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
peerDependenciesof 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
baseUrlandpathsfrom 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
.mjsextension support - Export a
defaultfor 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.jsonas welljsconfig.jsonwill be ignored iftsconfig.jsonandjsconfig.jsonboth exists.
- Add
.npmignoreto reduce the size of the package. - Use
deepmergeto merge plugin options config with your giventsconfig.json.
The first release.