Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Update compiling with babel section #1298

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions packages/lit-dev-content/site/docs/v3/tools/publishing.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,29 +78,30 @@ To compile a Lit component that uses proposed JavaScript features not yet includ
Install Babel and the Babel plugins you need. For example:

```sh
npm install --save-dev @babel/core
npm install --save-dev @babel/plugin-proposal-class-properties
npm install --save-dev @babel/plugin-proposal-decorators
npm install --save-dev \
@babel/core \
@babel/cli \
@babel/preset-env \
@babel/plugin-proposal-decorators
```

Configure Babel. For example:

**babel.config.js**
**babel.config.json**

```js
const assumptions = {
"setPublicClassFields": true
};

const plugins = [
['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true } ],
["@babel/plugin-proposal-class-properties"],

];

module.exports = { assumptions, plugins };
```json
{
"presets": [
["@babel/preset-env", {"targets": "defaults"}]
],
"plugins": [
["@babel/plugin-proposal-decorators", {"version": "2023-05"}]
]
}
```

You can adjust the `"targets"` option to target browsers you wish to support. See [`@babel/preset-env`](https://babeljs.io/docs/babel-preset-env) for available options.

You can run Babel via a bundler plugin such as [@rollup/plugin-babel](https://www.npmjs.com/package/@rollup/plugin-babel), or from the command line. See the [Babel documentation](https://babeljs.io/docs/en/) for more information.

## Publishing best practices
Expand Down
Loading