# @lwc/compiler

> LWC compiler

Latest version **9.4.3** (published 2026-09-02) · MIT license · 248.4K weekly downloads

## Install

```sh
npm install @lwc/compiler
pnpm add @lwc/compiler
yarn add @lwc/compiler
bun add @lwc/compiler
```

## Health

**Score 85/100 (A)** — status: active.

Positive: moderate downloads; has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

## Facts

| | |
|---|---|
| Version | 9.4.3 |
| Published | 2026-09-02 |
| First published | 2018-12-12 |
| Weekly downloads | 248.4K |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=16.6.0 |
| Dependencies | 12 |
| Unpacked size | 56.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1791 |
| Maintainers | lwc-admin, caridy, jye-sf, ravi.jayaramappa, jodarove, abdulsattar, rax-it1, lpomerleau |
| Keywords | lwc |

## Links

- npm: https://www.npmjs.com/package/@lwc/compiler
- Repository: https://github.com/salesforce/lwc
- Homepage: https://lwc.dev
- Issues: https://github.com/salesforce/lwc/issues
- npm.io page: https://npm.io/package/@lwc/compiler

## Dependencies (12)

- [@babel/core](https://npm.io/package/@babel/core.md) 7.29.7
- [@lwc/errors](https://npm.io/package/@lwc/errors.md) 9.4.3
- [@lwc/shared](https://npm.io/package/@lwc/shared.md) 9.4.3
- [@lwc/ssr-compiler](https://npm.io/package/@lwc/ssr-compiler.md) 9.4.3
- [@lwc/style-compiler](https://npm.io/package/@lwc/style-compiler.md) 9.4.3
- [@lwc/template-compiler](https://npm.io/package/@lwc/template-compiler.md) 9.4.3
- [@lwc/babel-plugin-component](https://npm.io/package/@lwc/babel-plugin-component.md) 9.4.3
- [@babel/plugin-transform-class-properties](https://npm.io/package/@babel/plugin-transform-class-properties.md) 7.29.7
- [@babel/plugin-transform-async-to-generator](https://npm.io/package/@babel/plugin-transform-async-to-generator.md) 7.29.7
- [@babel/plugin-transform-object-rest-spread](https://npm.io/package/@babel/plugin-transform-object-rest-spread.md) 7.29.7
- [@locker/babel-plugin-transform-unforgeables](https://npm.io/package/@locker/babel-plugin-transform-unforgeables.md) 0.22.0
- [@babel/plugin-transform-async-generator-functions](https://npm.io/package/@babel/plugin-transform-async-generator-functions.md) 7.29.7

## Recent versions

- 9.4.3 (latest) — 2026-09-02
- 9.4.6-alpha.1 (canary) — 2026-09-22
- 9.3.10 (winter27) — 2026-09-21
- 9.1.5 (summer26) — 2026-04-28
- 8.25.1 (spring26) — 2025-11-19
- 8.20.6 (winter26) — 2025-10-20
- 8.16.5 (summer25) — 2025-05-05
- 8.10.3 (spring25) — 2025-01-09
- 7.1.5 (winter25) — 2024-10-10
- 7.0.1-alpha.0 (next) — 2024-06-21
- 6.4.5 (summer24) — 2024-06-05
- 5.0.10 (spring24) — 2024-03-20
- 3.0.4 (winter24) — 2023-10-02
- 2.40.2-lbc (lbc-avante-garde) — 2023-03-21
- 2.31.8 (spring23) — 2023-03-20
- … 876 more at https://npm.io/package/@lwc/compiler/versions

## README

# LWC Compiler

## Summary

@lwc/compiler is an open source project that enables developers to take full control of processing a single Lightning Web Components module for runtime consumption.

## Installation

```sh
npm install @lwc/compiler
```

## APIs

### `transformSync`

Transform the content of individual file.

```js
import { transformSync } from '@lwc/compiler';

const source = `
    import { LightningElement } from 'lwc';
    export default class App extends LightningElement {}
`;

const filename = 'app.js';

const options = {
    namespace: 'c',
    name: 'app',
};

const { code } = transformSync(source, filename, options);
```

**Parameters:**

- `source` (string, required) - the source to be transformed. Can be the content of a JavaScript, HTML, or CSS file.
- `filename` (string, required) - the source filename with extension.
- `options` (object, required) - the transformation options. The `name` and the `namespace` of the component is a minimum required for transformation.
    - `name` (type: `string`, required) - name of the component, e.g. `foo` in `x/foo`.
    - `namespace` (type: `string`, required) - namespace of the component, e.g. `x` in `x/foo`.
    - `stylesheetConfig` (type: `object`, default: `{}`) - Deprecated. Ignored by compiler.
    - `dynamicImports` (type: `DynamicImportConfig`, default: `null`) - The configuration to pass to `@lwc/compiler`.
    - `experimentalDynamicDirective` (type: `boolean`, default: `false`) - The configuration to pass to `@lwc/template-compiler` to enable deprecated dynamic components.
    - `enableDynamicComponents` (type: `boolean`, default: `false`) - The configuration to pass to `@lwc/template-compiler` to enable dynamic components.
    - `outputConfig` (type: `object`, optional) - see below:
        - `sourcemap` (type: `boolean` | `'inline'`, optional) - if `true`, a sourcemap is generated for the transformed file. If `'inline'`, an inline sourcemap is generated and appended to the transformed file.
        - `minify` (type: `boolean`, optional, deprecated) - this option has no effect.
    - `experimentalComplexExpressions` (type: `boolean`, optional) - set to true to enable use of (a subset of) JavaScript expressions in place of template bindings. Passed to `@lwc/template-compiler`.
    - `isExplicitImport` (type: `boolean`, optional) - true if this is an explicit import, passed to `@lwc/babel-plugin-component`.
    - `preserveHtmlComments` (type: `boolean`, default: `false`) - The configuration to pass to the `@lwc/template-compiler`.
    - `scopedStyles` (type: `boolean`, optional) - True if the CSS file being compiled is a scoped stylesheet. Passed to `@lwc/style-compiler`.
    - `enableStaticContentOptimization` (type: `boolean`, optional) - True if the static content optimization should be enabled. Passed to `@lwc/template-compiler`.
    - `customRendererConfig` (type: `object`, optional) - custom renderer config to pass to `@lwc/template-compiler`. See that package's README for details.
    - `enableLightningWebSecurityTransforms` (type: `boolean`, default: `false`) - The configuration to enable Lighting Web Security specific transformations.
    - `enableLwcSpread` (boolean, optional, `true` by default) - Deprecated. Ignored by compiler. `lwc:spread` is always enabled.
    - `disableSyntheticShadowSupport` (type: `boolean`, default: `false`) - Set to true if synthetic shadow DOM support is not needed, which can result in smaller/faster output.
    - `enablePrivateMethods` (type: `boolean`, default: `false`) - Enable the private method round-trip transform. When false or omitted, private methods pass through to standard Babel handling.
    - `instrumentation` (type: `InstrumentationObject`, optional) - instrumentation object to gather metrics and non-error logs for internal use. See the `@lwc/errors` package for details on the interface.
    - `apiVersion` (type: `number`, optional) - API version to associate with the compiled module.

**Return**

- `code` (string) - the compiled source code.
- `map` (object) - the generated source map.
- `warnings` (array, optional) - the array of diagnostic warnings, if any.
- `cssScopeTokens` (array, optional) - String tokens used for style scoping in synthetic shadow DOM and `*.scoped.css` (as either attributes or classes), if any.

### `transform` (deprecated)

Deprecated asynchronous equivalent of `transformSync`.

### `version`

```js
import { version } from '@lwc/compiler';

console.log(version);
```

**Return**

- `version` (string) - the current version of the compiler ex: `0.25.1`.

---
_Source: https://npm.io/package/@lwc/compiler · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
