Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Nov 24, 2020
2 parents 2015802 + e3b7484 commit 5269afa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ It does not work with some features. Also, if you change the default behaviour,

### Custom build[](#index)

For some cases could be useful adding a blacklist of features or generation a polyfill for target engines. You could use [`core-js-builder`](/packages/core-js-builder) package for that.
For some cases could be useful adding a _exclude_ of features or generation a polyfill for target engines. You could use [`core-js-builder`](/packages/core-js-builder) package for that.

### Compatibility data[](#index)

Expand Down
15 changes: 9 additions & 6 deletions packages/core-js-builder/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
For some cases could be useful adding a blacklist of features or generation a polyfill for target engines. This API helps conditionally include or exclude certain parts of [`core-js`](https://github.com/zloirock/core-js), use `browserslist` queries from [`core-js-compat`](https://github.com/zloirock/core-js/tree/master/packages/core-js-compat) package.
For some cases could be useful adding a _exclude_ list of features or generation a polyfill for target engines. This API helps conditionally include or exclude certain parts of [`core-js`](https://github.com/zloirock/core-js), use `browserslist` queries from [`core-js-compat`](https://github.com/zloirock/core-js/tree/master/packages/core-js-compat) package.

> **NOTE:**
> `blacklist` parameter is now deprecated in favor of `exclude`. And will be removed in the next major version. You can't use both parameters since `blacklist` has precedence.
```js
require('core-js-builder')({
modules: ['es', 'esnext.reflect', 'web'], // modules / namespaces, by default - all `core-js` modules
blacklist: ['es.math', 'es.number.constructor'], // blacklist of modules / namespaces, by default - empty list
targets: '> 0.5%', // optional browserslist query
filename: './my-core-js-bundle.js', // optional target filename, if it's missed a file will not be created
}).then(code => { // code of result polyfill
modules: ['es', 'esnext.reflect', 'web'], // modules / namespaces, by default - all `core-js` modules
exclude: ['es.math', 'es.number.constructor'], // exclude of modules / namespaces, by default - empty list
targets: '> 0.5%', // optional browserslist query
filename: './my-core-js-bundle.js', // optional target filename, if it's missed a file will not be created
}).then(code => { // code of result polyfill
// ...
}).catch(error => {
// ...
Expand Down
10 changes: 8 additions & 2 deletions packages/core-js-builder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ const compat = require('core-js-compat/compat');
const modulesList = require('core-js-compat/modules');
const { banner } = require('./config');

module.exports = async function ({ blacklist = [], modules = modulesList.slice(), targets, filename } = {}) {
module.exports = async function ({
blacklist, // TODO: Remove from `core-js@4`
exclude = [],
modules = modulesList.slice(),
targets,
filename,
} = {}) {
const set = new Set();

function filter(method, list) {
Expand All @@ -28,7 +34,7 @@ module.exports = async function ({ blacklist = [], modules = modulesList.slice()
}

filter('add', modules);
filter('delete', blacklist);
filter('delete', blacklist || exclude);

modules = modulesList.filter(it => set.has(it));

Expand Down

0 comments on commit 5269afa

Please sign in to comment.