Skip to content
Back to skills

Swc Compiler Transform

ASecurity

SWC (Speedy Web Compiler) Rust-based JS/TS transforms. Programmatic transpilation, custom plugins via WASM, minification, module format conversion, and performance-sensitive parse pipelines. Sources: swc-project/swc (Apache-2.0).

  • 10 stars
  • 0 votes
  • 0 copies
  • 7 views
  • Added September 9, 2026
ai-agentsjavascripttypescriptrustjavanodeapiperformance

Works with

  • api

Security analysis

A100/100

Scanned September 9, 2026

npx -y skills add yanacuti1121/Yana-AI --skill swc-compiler-transform --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Swc Compiler Transform?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Swc Compiler Transform
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/yanacuti1121-swc-compiler-transform/badge)](https://www.skillsdirectory.com/skills/yanacuti1121-swc-compiler-transform)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: swc-compiler-transform
description: SWC (Speedy Web Compiler) Rust-based JS/TS transforms. Programmatic transpilation, custom plugins via WASM, minification, module format conversion, and performance-sensitive parse pipelines. Sources: swc-project/swc (Apache-2.0).
origin: yana-ai — synthesized from swc-project/swc (Apache-2.0)
license: Apache-2.0
version: 1.0.0
compatibility: yana-ai >= 1.3.49
---

# /swc-compiler-transform

## When to Use

- Parse/transform large TypeScript codebases where Babel is too slow (10–70× faster)
- CI pipelines: batch transpile thousands of files before analysis
- Module conversion: CJS → ESM, TypeScript → JS, JSX → createElement
- Minification without Terser in build-critical pipelines

## Do NOT use for

- Custom AST visitor plugins in pure JS (use [[babel-ast-transform]])
- When SWC's WASM plugin SDK is overkill — Babel plugins are simpler to write

---

## Basic transform (TS → JS)

```javascript
import { transformSync } from '@swc/core'

const result = transformSync(`
  const greet = (name: string): string => \`Hello, \${name}!\`
  export default greet
`, {
  filename:  'greet.ts',
  sourceMaps: true,
  jsc: {
    parser:  { syntax: 'typescript', tsx: false },
    target:  'es2019',
    transform: {
      legacyDecorator: true,
    },
  },
  module: { type: 'es6' },   // 'commonjs' | 'es6' | 'umd'
})

console.log(result.code)    // transpiled JS
console.log(result.map)     // source map JSON string
```

---

## Async transform (preferred for large files)

```javascript
import { transform } from '@swc/core'
import { readFile, writeFile } from 'fs/promises'
import { globby } from 'globby'

async function batchTransform(pattern: string, outDir: string) {
  const files = await globby(pattern)

  await Promise.all(files.map(async (file) => {
    const source = await readFile(file, 'utf8')
    const { code, map } = await transform(source, {
      filename: file,
      sourceMaps: true,
      jsc: {
        parser: { syntax: 'typescript', tsx: file.endsWith('.tsx') },
        target: 'es2020',
      },
      module: { type: 'commonjs' },
    })

    const outFile = file.replace('src/', outDir + '/').replace(/\.tsx?$/, '.js')
    await writeFile(outFile, code)
    if (map) await writeFile(outFile + '.map', map)
  }))
}
```

---

## Minify (production build)

```javascript
import { minify } from '@swc/core'

const { code } = await minify(sourceCode, {
  compress: {
    unused:          true,
    dead_code:       true,
    drop_console:    true,
    passes:          2,
  },
  mangle:  { toplevel: false },
  format:  { comments: false },
  sourceMap: false,
})
```

---

## Parse only (AST extraction)

```javascript
import { parse } from '@swc/core'

const ast = await parse(`
  export function add(a: number, b: number) { return a + b }
`, {
  syntax:    'typescript',
  comments:  false,
  script:    false,
})

// ast is SWC's own AST (not ESTree — use estree-compat layer if needed)
const firstExport = ast.body[0]
// firstExport.type === 'ExportDeclaration'
```

---

## Anti-Fake-Pass Checklist

```
❌ Using transformSync in async Node server → blocks event loop on large files
❌ jsc.target: 'es5' without specifying externalHelpers: true → bloated output (helpers inlined per file)
❌ SWC AST !== ESTree — don't pass SWC ast to ESLint/Babel APIs directly
❌ sourceMaps: true without writing .map file → source maps referenced but missing
❌ tsx: false for .tsx files → JSX syntax errors
❌ SWC WASM plugins require @swc/wasm-typescript — not bundled by default
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.