Registry / web-framework / rollup-plugin-lit-transformer

rollup-plugin-lit-transformer

JSON →
library0.3.3jsnpmunverified

A Rollup plugin that transforms lit-html templates at build time using SWC (Speedy Web Compiler). Current stable version is 0.3.3, released in early 2023, with low release cadence (last update over a year ago). It optimizes LitElement and lit-html templates by inlining static parts, reducing runtime overhead and bundle size. Key differentiators: uses SWC for fast transformation, supports custom elements and web components. Alternative tools like @open-wc/building-rollup or @lit/context exist, but this plugin is specifically for Rollup and SWC integration.

npm install rollup-plugin-lit-transformer
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-LIT-
R
rollup-plugin-lit-transformer
web-frameworkjavascriptv0.3.3
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.

default
✓ import litTransformer from 'rollup-plugin-lit-transformer'
✗ const litTransformer = require('rollup-plugin-lit-transformer')
Package is ESM-only; CommonJS require() will not work unless dynamic import is used.
litTransformer
✓ import litTransformer from 'rollup-plugin-lit-transformer'
Default export, same as the plugin function.
Plugin options (TypeScript)
✓ import type { Options } from 'rollup-plugin-lit-transformer'
✗ import { Options } from 'rollup-plugin-lit-transformer' (value import, but it's a type)
TypeScript users should use `import type` for Options interface.

Shows basic Rollup config using litTransformer plugin with SWC for transforming Lit templates in a TypeScript project.

// rollup.config.js import litTransformer from 'rollup-plugin-lit-transformer'; import { swcPlugin } from 'rollup-plugin-swc3'; // or similar SWC plugin export default { input: 'src/index.js', output: { dir: 'dist', format: 'es' }, plugins: [ litTransformer(), // must be before SWC or other transform plugins swcPlugin({ jsc: { parser: { syntax: 'typescript' }, transform: {}, // any transforms needed } }) ] };
Debug
Known issues
deprecatedPackage has not been updated since early 2023; consider using official Lit build tools like @lit/rollup-plugin-lit-html.
fix
Switch to @lit/rollup-plugin-lit-html or @open-wc/building-rollup for better maintenance.
affects: all
gotchaPlugin must be placed before other transform plugins (like SWC) in the Rollup plugins array.
fix
Order plugins: litTransformer() first, then transpilers (e.g., swcPlugin).
affects: all
breakingBreaking change: In version 0.3.0, the export changed from named to default. Previously used `import { litTransformer }` now throws.
fix
Use default import `import litTransformer from 'rollup-plugin-lit-transformer'`.
affects: <0.3.0
Errors
Common errors & fixes
Error: Cannot find module '@swc/core'
Missing peer dependency @swc/core.
fix
Install @swc/core with `npm install @swc/core`.
SyntaxError: Unexpected token 'export' (or import)
Using require() on an ESM-only package.
fix
Switch to ESM (use import) or dynamic import: `const litTransformer = (await import('rollup-plugin-lit-transformer')).default`.
Upgrade
Version history
0.3.3latest on npm
Audit
Dependencies
@swc/corerequiredSWC transpiler for code transformation at build time
litrequiredLit library for which templates are transformed; must be present in project
Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-lit-transformer — npm install rollup-plugin-lit-transformer · libregistry