Registry / devops / ts-swc-rollup-plugin

ts-swc-rollup-plugin

JSON →
library2.4.0jsnpmunverified

A Rollup plugin that integrates swc (Speedy Web Compiler) for fast TypeScript/JavaScript transpilation leveraging ts-swc-transform. Current stable version is 2.4.0, with a maintenance release cadence. Key differentiators: performance-oriented alternative to @rollup/plugin-typescript or @rollup/plugin-babel; supports tsconfig resolution via get-tsconfig; ships TypeScript types; requires Node >=16. Suitable for bundling workflows that prioritize speed over full type-checking.

npm install ts-swc-rollup-plugin
INSTALL
IMPORT
SIG · TS-SWC-ROLLUP-PLUG
T
ts-swc-rollup-plugin
devopsjavascriptv2.4.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import swc from 'ts-swc-rollup-plugin'
const swc = require('ts-swc-rollup-plugin')
Package is ESM-only since v2. Default export is the plugin function.
RollupOptions.plugins
export default { plugins: [swc({ tsconfig: 'tsconfig.json' })] }
export default { plugins: [swc({ tsconfig: 'tsconfig.json' })] }
No type import needed; Rollup automatically merges plugin types. Plugin options object is optional.
type PluginOptions
import type { PluginOptions } from 'ts-swc-rollup-plugin'
import { PluginOptions } from 'ts-swc-rollup-plugin'
Export is a type only; value import is incorrect and will cause runtime error in some bundlers.

Minimal Rollup config using ts-swc-rollup-plugin to transpile TypeScript entry point, with optional SWC_ENV environment variable.

// rollup.config.js import swc from 'ts-swc-rollup-plugin'; process.env.SWC_ENV ??= process.env.NODE_ENV ?? 'development'; export default { input: 'src/index.ts', output: { file: 'dist/bundle.js', format: 'esm', }, plugins: [ swc({ // Optional: defaults shown cwd: process.cwd(), tsconfig: 'tsconfig.json', }), ], };
Debug
Known issues
breakingVersion 2.x requires Node >=16 and is ESM-only. CommonJS require() will fail.
fix
Update to Node >=16 and use import syntax. For CJS projects, consider dynamic import or use v1.x.
affects: >=2.0.0
deprecatedPassing tsconfig as a string path is deprecated in favor of using a resolved config object from get-tsconfig.
fix
Use getTsconfig() from get-tsconfig package: swc({ tsconfig: getTsconfig() }).
affects: >=2.0.0
gotchaPlugin does not perform type checking; swc is a transpiler only. Use tsc --noEmit separately for type safety.
fix
Add a separate tsc --noEmit script to your build pipeline.
affects: >=1.0.0
gotchaOptions object is mutable; do not reuse the same options object across multiple Rollup builds.
fix
Create a fresh options object per build configuration.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'ts-swc-rollup-plugin' or its corresponding type declarations.
Missing package install or incorrect TypeScript settings (e.g., no moduleResolution: 'node' or 'node16').
fix
npm install ts-swc-rollup-plugin --save-dev and ensure tsconfig.json has 'moduleResolution': 'node' or 'node16' (>= v2).
Error: swc is not a function
Using CommonJS require() with v2+ which is ESM-only.
fix
Use import swc from 'ts-swc-rollup-plugin' in an ES module context (type: 'module' in package.json or .mjs extension).
TypeError: Cannot read properties of undefined (reading 'transform')
Invalid or missing tsconfig causing ts-swc-transform to fail initialization.
fix
Ensure tsconfig.json exists and is valid JSON. Pass explicit tsconfig path: swc({ tsconfig: 'tsconfig.json' }).
Upgrade
Version history
2.4.0latest on npm
Audit
Dependencies
ts-swc-transformrequiredCore transform logic underlying the plugin
get-tsconfigoptionalUsed to resolve and parse tsconfig files; optional if passing tsconfig object directly
Agent activity
2 hits · last 30 days
node
2
Resources
ts-swc-rollup-plugin — npm install ts-swc-rollup-plugin · libregistry