Skip to content

Commit

Permalink
get rid of modules list in core-js-builder/config
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Dec 26, 2018
1 parent 85d1f4d commit 127b9d3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 301 deletions.
11 changes: 6 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ Contributions are always welcome. If you don't know what how you can help, you c
## How to add a new polyfill

- The polyfill implementation should be added to the [`packages/core-js/modules`](./packages/core-js/modules) directory.
- If the implementation for the `pure` version should differ from the global version, it should be added to [`packages/core-js-pure/override`](./packages/core-js-pure/override) directory. The rest of `core-js-pure` will be copied from `core-js` package.
- For export the polyfill, in almost all cases should be used `_export` helper.
- The polyfill should be added to the [list of polyfills](./packages/core-js-builder/config.js) and to entry points, where it's required: [`packages/core-js/index.js`](./packages/core-js/index.js), directories [`packages/core-js/features`](./packages/core-js/features), [`packages/core-js/es`](./packages/core-js/es), [`packages/core-js/esnext`](./packages/core-js/esnext) and [`packages/core-js/web`](./packages/core-js/web).
- Any shared helpers should be added to the [`packages/core-js/internals`](./packages/core-js/internals) directory.
- If the implementation for the `pure` version differs from the global version, add it to [`packages/core-js-pure/override`](./packages/core-js-pure/override) directory. The rest parts of `core-js-pure` will be copied from `core-js` package.
- For export the polyfill, in almost all cases use `internals/export` helper.
- Add feature detection of the polyfill to [`tests/compat/tests.js`](./tests/compat/tests.js) and compatibility data to [`packages/core-js-compat/src/data.js`](./packages/core-js-compat/src/data.js) (this data also used for getting default list of polyfills at bundling).
- Add it to entry points where it's required: directories [`packages/core-js/features`](./packages/core-js/features), [`packages/core-js/es`](./packages/core-js/es), [`packages/core-js/proposals`](./packages/core-js/proposals), [`packages/core-js/stage`](./packages/core-js/stage) and [`packages/core-js/web`](./packages/core-js/web).
- Add unit tests to [`tests/tests`](./tests/tests) and [`tests/pure`](./tests/pure).
- Add feature detection of the polyfill to [`tests/compat/tests.js`](./tests/compat/tests.js) and compatibility data to [`packages/core-js-compat/src/data.js`](./packages/core-js-compat/src/data.js).
- Add tests of entry points to [`tests/commonjs.js`](./tests/commonjs).
- Add it to [README.md](./README.md).
- Add documentation to [README.md](./README.md).

## Style and standards

Expand Down
287 changes: 0 additions & 287 deletions packages/core-js-builder/config.js
Original file line number Diff line number Diff line change
@@ -1,292 +1,5 @@
'use strict';
module.exports = {
list: [
'es.symbol',
'es.symbol.async-iterator',
'es.symbol.description',
'es.symbol.has-instance',
'es.symbol.is-concat-spreadable',
'es.symbol.iterator',
'es.symbol.match',
'es.symbol.replace',
'es.symbol.search',
'es.symbol.species',
'es.symbol.split',
'es.symbol.to-primitive',
'es.symbol.to-string-tag',
'es.symbol.unscopables',
'es.object.assign',
'es.object.create',
'es.object.define-property',
'es.object.define-properties',
'es.object.entries',
'es.object.freeze',
'es.object.get-own-property-descriptor',
'es.object.get-own-property-descriptors',
'es.object.get-own-property-names',
'es.object.get-prototype-of',
'es.object.is',
'es.object.is-extensible',
'es.object.is-frozen',
'es.object.is-sealed',
'es.object.keys',
'es.object.prevent-extensions',
'es.object.seal',
'es.object.set-prototype-of',
'es.object.values',
'es.object.to-string',
'es.object.define-getter',
'es.object.define-setter',
'es.object.lookup-getter',
'es.object.lookup-setter',
'es.function.bind',
'es.function.name',
'es.function.has-instance',
'es.array.from',
'es.array.is-array',
'es.array.of',
'es.array.concat',
'es.array.copy-within',
'es.array.every',
'es.array.fill',
'es.array.filter',
'es.array.find',
'es.array.find-index',
'es.array.for-each',
'es.array.includes',
'es.array.index-of',
'es.array.join',
'es.array.last-index-of',
'es.array.map',
'es.array.reduce',
'es.array.reduce-right',
'es.array.reverse',
'es.array.slice',
'es.array.some',
'es.array.sort',
'es.array.splice',
'es.array.species',
'es.array.iterator',
'es.string.from-code-point',
'es.string.raw',
'es.string.code-point-at',
'es.string.ends-with',
'es.string.includes',
'es.string.match',
'es.string.pad-end',
'es.string.pad-start',
'es.string.repeat',
'es.string.replace',
'es.string.search',
'es.string.split',
'es.string.starts-with',
'es.string.trim',
'es.string.iterator',
'es.string.anchor',
'es.string.big',
'es.string.blink',
'es.string.bold',
'es.string.fixed',
'es.string.fontcolor',
'es.string.fontsize',
'es.string.italics',
'es.string.link',
'es.string.small',
'es.string.strike',
'es.string.sub',
'es.string.sup',
'es.regexp.constructor',
'es.regexp.exec',
'es.regexp.flags',
'es.regexp.to-string',
'es.parse-int',
'es.parse-float',
'es.number.constructor',
'es.number.epsilon',
'es.number.is-finite',
'es.number.is-integer',
'es.number.is-nan',
'es.number.is-safe-integer',
'es.number.max-safe-integer',
'es.number.min-safe-integer',
'es.number.parse-float',
'es.number.parse-int',
'es.number.to-fixed',
'es.number.to-precision',
'es.math.acosh',
'es.math.asinh',
'es.math.atanh',
'es.math.cbrt',
'es.math.clz32',
'es.math.cosh',
'es.math.expm1',
'es.math.fround',
'es.math.hypot',
'es.math.imul',
'es.math.log10',
'es.math.log1p',
'es.math.log2',
'es.math.sign',
'es.math.sinh',
'es.math.tanh',
'es.math.to-string-tag',
'es.math.trunc',
'es.date.now',
'es.date.to-json',
'es.date.to-iso-string',
'es.date.to-string',
'es.date.to-primitive',
'es.json.to-string-tag',
'es.promise',
'es.promise.finally',
'es.map',
'es.set',
'es.weak-map',
'es.weak-set',
'es.array-buffer.constructor',
'es.array-buffer.is-view',
'es.array-buffer.slice',
'es.data-view',
'es.typed-array.int8-array',
'es.typed-array.uint8-array',
'es.typed-array.uint8-clamped-array',
'es.typed-array.int16-array',
'es.typed-array.uint16-array',
'es.typed-array.int32-array',
'es.typed-array.uint32-array',
'es.typed-array.float32-array',
'es.typed-array.float64-array',
'es.typed-array.from',
'es.typed-array.of',
'es.typed-array.copy-within',
'es.typed-array.every',
'es.typed-array.fill',
'es.typed-array.filter',
'es.typed-array.find',
'es.typed-array.find-index',
'es.typed-array.for-each',
'es.typed-array.includes',
'es.typed-array.index-of',
'es.typed-array.iterator',
'es.typed-array.join',
'es.typed-array.last-index-of',
'es.typed-array.map',
'es.typed-array.reduce',
'es.typed-array.reduce-right',
'es.typed-array.reverse',
'es.typed-array.set',
'es.typed-array.slice',
'es.typed-array.some',
'es.typed-array.sort',
'es.typed-array.subarray',
'es.typed-array.to-locale-string',
'es.typed-array.to-string',
'es.reflect.apply',
'es.reflect.construct',
'es.reflect.define-property',
'es.reflect.delete-property',
'es.reflect.get',
'es.reflect.get-own-property-descriptor',
'es.reflect.get-prototype-of',
'es.reflect.has',
'es.reflect.is-extensible',
'es.reflect.own-keys',
'es.reflect.prevent-extensions',
'es.reflect.set',
'es.reflect.set-prototype-of',
'esnext.array.flat',
'esnext.array.flat-map',
'esnext.array.last-index',
'esnext.array.last-item',
'esnext.composite-key',
'esnext.composite-symbol',
'esnext.global-this',
'esnext.map.from',
'esnext.map.group-by',
'esnext.map.key-by',
'esnext.map.of',
'esnext.map.delete-all',
'esnext.map.every',
'esnext.map.filter',
'esnext.map.find',
'esnext.map.find-key',
'esnext.map.includes',
'esnext.map.key-of',
'esnext.map.map-keys',
'esnext.map.map-values',
'esnext.map.merge',
'esnext.map.reduce',
'esnext.map.some',
'esnext.math.clamp',
'esnext.math.deg-per-rad',
'esnext.math.degrees',
'esnext.math.fscale',
'esnext.math.iaddh',
'esnext.math.isubh',
'esnext.math.imulh',
'esnext.math.seeded-prng',
'esnext.math.rad-per-deg',
'esnext.math.radians',
'esnext.math.scale',
'esnext.math.signbit',
'esnext.math.umulh',
'esnext.number.from-string',
'esnext.object.from-entries',
'esnext.observable',
'esnext.promise.all-settled',
'esnext.promise.try',
'esnext.reflect.define-metadata',
'esnext.reflect.delete-metadata',
'esnext.reflect.get-metadata',
'esnext.reflect.get-metadata-keys',
'esnext.reflect.get-own-metadata',
'esnext.reflect.get-own-metadata-keys',
'esnext.reflect.has-metadata',
'esnext.reflect.has-own-metadata',
'esnext.reflect.metadata',
'esnext.set.from',
'esnext.set.of',
'esnext.set.add-all',
'esnext.set.delete-all',
'esnext.set.every',
'esnext.set.difference',
'esnext.set.filter',
'esnext.set.find',
'esnext.set.intersection',
'esnext.set.is-disjoint-with',
'esnext.set.is-subset-of',
'esnext.set.is-superset-of',
'esnext.set.join',
'esnext.set.map',
'esnext.set.reduce',
'esnext.set.some',
'esnext.set.symmetric-difference',
'esnext.set.union',
'esnext.string.at',
'esnext.string.code-points',
'esnext.string.match-all',
'esnext.string.replace-all',
'esnext.string.trim-left',
'esnext.string.trim-right',
'esnext.symbol.dispose',
'esnext.symbol.observable',
'esnext.symbol.pattern-match',
'esnext.weak-map.from',
'esnext.weak-map.of',
'esnext.weak-map.delete-all',
'esnext.weak-set.add-all',
'esnext.weak-set.delete-all',
'esnext.weak-set.from',
'esnext.weak-set.of',
'web.dom-collections.for-each',
'web.dom-collections.iterator',
'web.immediate',
'web.queue-microtask',
'web.timers',
'web.url',
'web.url.to-json',
'web.url-search-params',
],
/* eslint-disable prefer-template */
banner: '/**\n' +
' * core-js ' + require('./package').version + '\n' +
Expand Down
18 changes: 9 additions & 9 deletions packages/core-js-builder/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict';
const config = require('./config');
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const temp = require('temp');
const compat = require('core-js-compat');
const list = config.list;
const modulesList = Object.keys(require('core-js-compat/data'));
const { banner } = require('./config');

module.exports = ({ blacklist = [], modules = list.slice(), targets }) => {
module.exports = ({ blacklist = [], modules = modulesList.slice(), targets }) => {
return new Promise((resolve, reject) => {
const filter = modules.reduce((memo, it) => {
memo[it] = true;
Expand All @@ -16,8 +16,8 @@ module.exports = ({ blacklist = [], modules = list.slice(), targets }) => {

for (const ns in filter) {
if (filter[ns]) {
for (let i = 0, length = list.length; i < length; ++i) {
const name = list[i];
for (let i = 0, length = modulesList.length; i < length; ++i) {
const name = modulesList[i];
if (name.indexOf(`${ ns }.`) === 0) {
filter[name] = true;
}
Expand All @@ -27,15 +27,15 @@ module.exports = ({ blacklist = [], modules = list.slice(), targets }) => {

for (let i = 0, length1 = blacklist.length; i < length1; ++i) {
const ns = blacklist[i];
for (let j = 0, length2 = list.length; j < length2; ++j) {
const name = list[j];
for (let j = 0, length2 = modulesList.length; j < length2; ++j) {
const name = modulesList[j];
if (name === ns || name.indexOf(`${ ns }.`) === 0) {
filter[name] = false;
}
}
}

modules = list.filter(it => filter[it]);
modules = modulesList.filter(it => filter[it]);

if (targets) modules = compat({ targets, filter: modules }).list;

Expand All @@ -59,7 +59,7 @@ module.exports = ({ blacklist = [], modules = list.slice(), targets }) => {
if (err2) return reject(err2);
fs.unlink(tempFile, err3 => {
if (err3) return reject(err3);
resolve(`${ config.banner }\n!function (undefined) { 'use strict'; ${ script } }();`);
resolve(`${ banner }\n!function (undefined) { 'use strict'; ${ script } }();`);
});
});
});
Expand Down

0 comments on commit 127b9d3

Please sign in to comment.