Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/susnux/webpack-plugin-corejs
⚡ bundle core-js polyfills for webpack projects
https://github.com/susnux/webpack-plugin-corejs
corejs nodejs polyfill webpack webpack-plugin webpack5
Last synced: about 1 month ago
JSON representation
⚡ bundle core-js polyfills for webpack projects
- Host: GitHub
- URL: https://github.com/susnux/webpack-plugin-corejs
- Owner: susnux
- Created: 2023-01-03T20:51:53.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-31T01:25:29.000Z (about 2 months ago)
- Last Synced: 2024-10-31T02:22:11.937Z (about 2 months ago)
- Topics: corejs, nodejs, polyfill, webpack, webpack-plugin, webpack5
- Language: TypeScript
- Homepage:
- Size: 301 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSES/CC0-1.0.txt
Awesome Lists containing this project
README
[![GitHub package.json version (main branch)](https://img.shields.io/github/package-json/v/susnux/webpack-plugin-corejs)](https://github.com/susnux/webpack-plugin-corejs/releases)
[![GitHub Workflow Status (main branch)](https://img.shields.io/github/actions/workflow/status/susnux/webpack-plugin-corejs/node.yml?branch=main)](https://github.com/susnux/webpack-plugin-corejs/actions/workflows/node.yml)
[![license](https://img.shields.io/npm/l/webpack-plugin-corejs?color=blue)](https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12)# webpack-plugin-corejs
A webpack plugin for injecting [core-js](https://github.com/zloirock/core-js) polyfills based
on your browserslist configuration.This plugin is essentially a wrapper for core-js-builder for webpack.
One usecase is that you are not using babel, but [esbuild](https://github.com/privatenumber/esbuild-loader)
for transpiling, e.g. using the [ESBuildMinifyPlugin](https://github.com/privatenumber/esbuild-loader#js-minification-eg-terser)
with your supported browsers is much faster then using Babel, but it only transpiles the syntax and does not add any polyfills.
So you would need to add e.g. *core-js* polyfills manually... or... use this plugin.### Compatibility
This version should work with *webpack 4* as well as with *webpack 5*.## Getting started
### 🚀 Installation```shell
npm i -D webpack-plugin-corejs
```### 🔧 Configuration
In your `webpack.config.js`:
```js
const CoreJSPlugin = require('webpack-plugin-corejs')module.exports = {
//...
plugins: [
new CoreJSPlugin({
// Options
}),
// ...
]
// ...
}
```Or in your `webpack.config.mjs`:
```js
import { CoreJSPlugin } from 'webpack-plugin-corejs'export default {
//...
plugins: [
new CoreJSPlugin({
// Options
}),
// ...
]
// ...
}
```### 🛠️ Options
All options are optionally, if no options are given the default is to use `{ modules: 'core-js/es' }`.You can omit setting `targets` in this case browserslist is used (`package.json` or `.browserslistrc`).
```ts
{
/** CoreJS modules to use, defaults to 'core-js/es' */
modules?: string | readonly string[] | readonly RegExp[],
/** CoreJS modules to exclude */
exclude?: string | readonly string[] | readonly RegExp[],
/** Overide browserslist targets */
targets?: string | readonly string[] | Record
/** Add comment which modules are used within bundle */
summary?: {
size: boolean
modules: boolean
}
}
```## Changelog
See [CHANGELOG](CHANGELOG.md)## License
[EUPL-1.2](LICENSES/EUPL-1.2.txt)