{"id":22480,"library":"ts-swc-rollup-plugin","title":"ts-swc-rollup-plugin","description":"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.","status":"active","version":"2.4.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/kmalakoff/ts-swc-rollup-plugin","tags":["javascript","swc","rollup","plugin","ts-swc-transform","typescript"],"install":[{"cmd":"npm install ts-swc-rollup-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add ts-swc-rollup-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add ts-swc-rollup-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core transform logic underlying the plugin","package":"ts-swc-transform","optional":false},{"reason":"Used to resolve and parse tsconfig files; optional if passing tsconfig object directly","package":"get-tsconfig","optional":true}],"imports":[{"note":"Package is ESM-only since v2. Default export is the plugin function.","wrong":"const swc = require('ts-swc-rollup-plugin')","symbol":"default","correct":"import swc from 'ts-swc-rollup-plugin'"},{"note":"No type import needed; Rollup automatically merges plugin types. Plugin options object is optional.","wrong":"export default { plugins: [swc({ tsconfig: 'tsconfig.json' })] }","symbol":"RollupOptions.plugins","correct":"export default { plugins: [swc({ tsconfig: 'tsconfig.json' })] }"},{"note":"Export is a type only; value import is incorrect and will cause runtime error in some bundlers.","wrong":"import { PluginOptions } from 'ts-swc-rollup-plugin'","symbol":"type PluginOptions","correct":"import type { PluginOptions } from 'ts-swc-rollup-plugin'"}],"quickstart":{"code":"// rollup.config.js\nimport swc from 'ts-swc-rollup-plugin';\n\nprocess.env.SWC_ENV ??= process.env.NODE_ENV ?? 'development';\n\nexport default {\n  input: 'src/index.ts',\n  output: {\n    file: 'dist/bundle.js',\n    format: 'esm',\n  },\n  plugins: [\n    swc({\n      // Optional: defaults shown\n      cwd: process.cwd(),\n      tsconfig: 'tsconfig.json',\n    }),\n  ],\n};\n","lang":"typescript","description":"Minimal Rollup config using ts-swc-rollup-plugin to transpile TypeScript entry point, with optional SWC_ENV environment variable."},"warnings":[{"fix":"Update to Node >=16 and use import syntax. For CJS projects, consider dynamic import or use v1.x.","message":"Version 2.x requires Node >=16 and is ESM-only. CommonJS require() will fail.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use getTsconfig() from get-tsconfig package: swc({ tsconfig: getTsconfig() }).","message":"Passing tsconfig as a string path is deprecated in favor of using a resolved config object from get-tsconfig.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Add a separate tsc --noEmit script to your build pipeline.","message":"Plugin does not perform type checking; swc is a transpiler only. Use tsc --noEmit separately for type safety.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Create a fresh options object per build configuration.","message":"Options object is mutable; do not reuse the same options object across multiple Rollup builds.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"npm install ts-swc-rollup-plugin --save-dev and ensure tsconfig.json has 'moduleResolution': 'node' or 'node16' (>= v2).","cause":"Missing package install or incorrect TypeScript settings (e.g., no moduleResolution: 'node' or 'node16').","error":"Cannot find module 'ts-swc-rollup-plugin' or its corresponding type declarations."},{"fix":"Use import swc from 'ts-swc-rollup-plugin' in an ES module context (type: 'module' in package.json or .mjs extension).","cause":"Using CommonJS require() with v2+ which is ESM-only.","error":"Error: swc is not a function"},{"fix":"Ensure tsconfig.json exists and is valid JSON. Pass explicit tsconfig path: swc({ tsconfig: 'tsconfig.json' }).","cause":"Invalid or missing tsconfig causing ts-swc-transform to fail initialization.","error":"TypeError: Cannot read properties of undefined (reading 'transform')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}