rollup-plugin-lwc-typescript
raw JSON → 1.0.1 verified Mon Apr 27 auth: no javascript deprecated
Rollup plugin to transform TypeScript files to JavaScript for Lightning Web Components (LWC). Current stable version is 1.0.1 (deprecated view; the broader ecosystem moved to lwc-services 3.x and LWC 2.x). Release cadence is low; no updates since 2020. Differentiator: specifically tailored for LWC TypeScript compilation, using the TypeScript compiler directly. Alternatives: use LWC's official webpack-based compilation or the lwc-services CLI.
Common errors
error Cannot find module 'rollup-plugin-lwc-typescript' ↓
cause Package not installed or outdated npm cache.
fix
npm install rollup-plugin-lwc-typescript --save-dev
error TypeError: lwcTypescript is not a function ↓
cause Incorrect import style; used named import instead of default.
fix
Use: import lwcTypescript from 'rollup-plugin-lwc-typescript';
Warnings
deprecated Package is deprecated and no longer maintained. ↓
fix Migrate to LWC's official webpack-based build system or use lwc-services CLI.
breaking LWC 2.x upgraded to @lwc/engine-dom from @lwc/engine; this plugin was not updated and may produce incompatible code. ↓
fix Use lwc-services 3.x or higher which supports LWC 2.x.
Install
npm install rollup-plugin-lwc-typescript yarn add rollup-plugin-lwc-typescript pnpm add rollup-plugin-lwc-typescript Imports
- default wrong
import { lwcTypescript } from 'rollup-plugin-lwc-typescript'correctimport lwcTypescript from 'rollup-plugin-lwc-typescript' - rollupPluginLwcTypescript (CommonJS) wrong
const { lwcTypescript } = require('rollup-plugin-lwc-typescript')correctconst lwcTypescript = require('rollup-plugin-lwc-typescript') - TypeScriptConfig
import type { TypeScriptConfig } from 'rollup-plugin-lwc-typescript'
Quickstart
// rollup.config.js
import lwcTypescript from 'rollup-plugin-lwc-typescript';
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
export default {
input: 'src/component.ts',
output: {
file: 'dist/component.js',
format: 'esm'
},
plugins: [
resolve(),
commonjs(),
lwcTypescript()
]
};