You're viewing docs for an older version of Lit. Click here for the latest version.

Publish a component

This page describes how to publish a LitElement component to npm.

We recommend publishing JavaScript modules in standard ES2017. If you're writing your element in standard ES2017, you don't need to transpile for publication. If you're using TypeScript, or ES2017+ features such as decorators or class fields, you will need to transpile your element for publication.

To publish your component to npm, see the instructions on contributing npm packages.

Your package.json configuration should have both the main and module fields:


You should also create a README describing how to consume your component. A basic guide to consuming LitElement components is documented at Use a component.

When compiling your code from TypeScript to JavaScript, we recommend targeting ES2017 with Node.js module resolution.

The following JSON sample is a partial tsconfig.json that uses recommended options for targeting ES2017:

See the tsconfig.json documentation for more information.

To transpile a LitElement component that uses proposed JavaScript features, use Babel.

Install Babel and the Babel plugins you need. For example:

Configure Babel. For example:


You can run Babel via a bundler plugin such as rollup-plugin-babel, or from the command line. See the Babel documentation for more information.