Skip to content

Commit

Permalink
generate indexes of namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Mar 10, 2021
1 parent 2f5a33f commit 9a83244
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 229 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ node_modules/
*.bak
*.swp

/packages/core-js/es/index.js
/packages/core-js/features/index.js
/packages/core-js/stable/index.js
/packages/core-js/LICENSE
/packages/core-js-builder/LICENSE
/packages/core-js-bundle/LICENSE
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"url": "https://github.com/zloirock/core-js.git"
},
"scripts": {
"init": "run-s clean-and-copy bootstrap build-compat",
"init": "run-p generate-indexes bootstrap && run-p clean-and-copy build-compat",
"clean-and-copy": "node scripts/clean-and-copy",
"bootstrap": "lerna bootstrap --hoist --no-ci && lerna link",
"build": "run-s init bundle-package",
Expand All @@ -78,6 +78,7 @@
"bundle-helpers": "webpack --entry ./tests/helpers/qunit-helpers.js --output-filename qunit-helpers.js",
"bundle-tests-global": "webpack --entry ./tests/tests/index.js --output-filename tests.js",
"bundle-tests-pure": "webpack --entry ./tests/pure/index.js --output-filename pure.js",
"generate-indexes": "node scripts/generate-indexes",
"lint": "run-s init test-lint",
"test-lint": "eslint ./",
"test-unit": "run-s test-unit-global test-unit-minified test-unit-pure",
Expand Down
214 changes: 0 additions & 214 deletions packages/core-js/es/index.js

This file was deleted.

3 changes: 0 additions & 3 deletions packages/core-js/features/index.js

This file was deleted.

7 changes: 1 addition & 6 deletions packages/core-js/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
require('./es');
require('./proposals');
require('./web');
var path = require('./internals/path');

module.exports = path;
module.exports = require('./features');
5 changes: 0 additions & 5 deletions packages/core-js/stable/index.js

This file was deleted.

20 changes: 20 additions & 0 deletions scripts/generate-indexes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';
const { writeFile } = require('fs').promises;
const compat = require('core-js-compat/src/data');

const modules = Object.keys(compat);

function generate(ns, filter) {
return writeFile(`./packages/core-js/${ ns }/index.js`, `${ modules
.filter(it => filter.test(it))
.map(it => `require('../modules/${ it }');\n`)
.join('') }\nmodule.exports = require('../internals/path');\n`);
}

(async () => {
await generate('es', /^es\./);
await generate('stable', /^(es|web)\./);
await generate('features', /^(es|esnext|web)\./);
// eslint-disable-next-line no-console -- output
console.log('\u001B[32mindexes generated\u001B[0m');
})();

0 comments on commit 9a83244

Please sign in to comment.