Registry / web-framework / lit-swc-transpiler

lit-swc-transpiler

JSON →
library1.0.0jsnpmunverified

A fast SWC-based transpiler for LitElement and other custom elements. Version 1.0.0 focuses on converting decorator and template syntax to standard JavaScript with minimal overhead. Ships TypeScript types for better DX. Compared to Babel-based alternatives, it leverages SWC's Rust core for up to 20x faster compilation. Ideal for large web component projects and build pipelines. Currently in early release, no stable release cadence yet.

npm install lit-swc-transpiler
INSTALL
IMPORT
SIG · LIT-SWC-TRANSPILER
L
lit-swc-transpiler
web-frameworkjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

transpile
import { transpile } from 'lit-swc-transpiler'
const { transpile } = require('lit-swc-transpiler')
Library is ESM-only; CommonJS require is not supported.
TransformOptions
import type { TransformOptions } from 'lit-swc-transpiler'
import { TransformOptions } from 'lit-swc-transpiler'
Type import only; runtime use will cause error.
transformSync
import { transformSync } from 'lit-swc-transpiler'
Synchronous version of transpile; use only in build scripts.

Shows basic usage: transpile a LitElement with decorators and TypeScript, outputting standard JS.

import { transpile } from 'lit-swc-transpiler'; const code = ` import { LitElement, html, css } from 'lit'; class MyElement extends LitElement { static styles = css\`p { color: red; }\`; @property() name = 'World'; render() { return html\`<p>Hello, \${this.name}!</p>\`; } } customElements.define('my-element', MyElement); `; const result = transpile(code, { filename: 'my-element.ts', decorators: true, ts: true }); console.log(result.code);
Debug
Known issues
breakingDecorator syntax is only supported in TypeScript mode; plain JavaScript files cannot use decorators without a separate parser.
fix
Enable TypeScript mode by setting `ts: true` option, or pre-process with a decorator transformer.
affects: >=1.0.0
deprecatedThe `transform` function is deprecated in favor of `transpile`.
fix
Use `transpile` instead. `transform` will be removed in v2.
affects: >=1.0.0
gotchaThe library does not handle `css` tagged template literal polyfills; ensure Lit's `css` helper is imported.
fix
Add `import { css } from 'lit';` in your source files.
affects: >=1.0.0
gotchaSource maps are not generated by default; enable with `sourceMaps: true` option.
fix
Pass `sourceMaps: true` in options to get inline source maps.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'lit-swc-transpiler'
Package not installed or wrong import path.
fix
Run `npm install lit-swc-transpiler` and ensure import path is correct.
TypeError: transpile is not a function
Using CommonJS require instead of ESM import.
fix
Change `const { transpile } = require('lit-swc-transpiler')` to `import { transpile } from 'lit-swc-transpiler'`.
SyntaxError: Unexpected token (5:10) - Decorators are not valid here.
Decorator syntax in a file not recognized as TypeScript.
fix
Either rename file to .ts or pass `ts: true` in options.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
@swc/corerequiredCore SWC compiler engine for transpilation
litrequiredRuntime for LitElement decorators and templates
Agent activity
4 hits · last 30 days
node
4
Resources
lit-swc-transpiler — npm install lit-swc-transpiler · libregistry