core-js-builder 3.25.5 → 3.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -8
- package/index.js +34 -25
- package/package.json +15 -10
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
5
|
-
[](https://opencollective.com/core-js) [](https://github.com/zloirock/core-js/blob/master/CONTRIBUTING.md) [](https://www.npmjs.com/package/core-js-builder)
|
|
5
|
+
[](https://opencollective.com/core-js) [](https://github.com/zloirock/core-js/blob/master/CONTRIBUTING.md) [](https://www.npmjs.com/package/core-js-builder)
|
|
6
6
|
|
|
7
7
|
</div>
|
|
8
8
|
|
|
@@ -12,13 +12,23 @@ For some cases could be useful to exclude some `core-js` features or generate a
|
|
|
12
12
|
import builder from 'core-js-builder';
|
|
13
13
|
|
|
14
14
|
const bundle = await builder({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
// entry / module / namespace / an array of them, by default - all `core-js` modules
|
|
16
|
+
modules: ['core-js/actual', /^esnext\.reflect\./],
|
|
17
|
+
// a blacklist of entries / modules / namespaces, by default - empty list
|
|
18
|
+
exclude: [/^es\.math\./, 'es.number.constructor'],
|
|
19
|
+
// optional browserslist or core-js-compat format query
|
|
20
|
+
targets: '> 0.5%, not dead, ie 9-11',
|
|
21
|
+
// shows summary for the bundle, disabled by default
|
|
22
|
+
summary: {
|
|
23
|
+
// in the console, you could specify required parts or set `true` for enable all of them
|
|
24
|
+
console: { size: true, modules: false },
|
|
25
|
+
// in the comment in the target file, similarly to `summary.console`
|
|
26
|
+
comment: { size: false, modules: true },
|
|
21
27
|
},
|
|
22
|
-
|
|
28
|
+
// output format, 'bundle' by default, can be 'cjs' or 'esm', and in this case
|
|
29
|
+
// the result will not be bundled and will contain imports of required modules
|
|
30
|
+
format: 'bundle',
|
|
31
|
+
// optional target filename, if it's missed a file will not be created
|
|
32
|
+
filename: PATH_TO_MY_COREJS_BUNDLE,
|
|
23
33
|
});
|
|
24
34
|
```
|
package/index.js
CHANGED
|
@@ -29,44 +29,53 @@ module.exports = async function ({
|
|
|
29
29
|
blacklist = null, // TODO: Obsolete, remove from `core-js@4`
|
|
30
30
|
exclude = [],
|
|
31
31
|
targets = null,
|
|
32
|
+
format = 'bundle',
|
|
32
33
|
filename = null,
|
|
33
34
|
summary = {},
|
|
34
35
|
} = {}) {
|
|
36
|
+
if (!['bundle', 'cjs', 'esm'].includes(format)) throw TypeError('Incorrect output type');
|
|
35
37
|
summary = { comment: normalizeSummary(summary.comment), console: normalizeSummary(summary.console) };
|
|
36
38
|
|
|
37
39
|
const TITLE = filename != null ? filename : '`core-js`';
|
|
38
40
|
let script = banner;
|
|
39
|
-
let code = '';
|
|
41
|
+
let code = '\n';
|
|
40
42
|
|
|
41
43
|
const { list, targets: compatTargets } = compat({ targets, modules, exclude: exclude || blacklist });
|
|
42
44
|
|
|
43
45
|
if (list.length) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
if (format === 'bundle') {
|
|
47
|
+
const tempFileName = `core-js-${ Math.random().toString(36).slice(2) }.js`;
|
|
48
|
+
const tempFile = join(tmpdir, tempFileName);
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
50
|
+
await webpack({
|
|
51
|
+
mode: 'none',
|
|
52
|
+
node: {
|
|
53
|
+
global: false,
|
|
54
|
+
process: false,
|
|
55
|
+
setImmediate: false,
|
|
56
|
+
},
|
|
57
|
+
entry: list.map(it => require.resolve(`core-js/modules/${ it }`)),
|
|
58
|
+
output: {
|
|
59
|
+
filename: tempFileName,
|
|
60
|
+
hashFunction: 'md5',
|
|
61
|
+
path: tmpdir,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
61
64
|
|
|
62
|
-
|
|
65
|
+
const file = await readFile(tempFile);
|
|
63
66
|
|
|
64
|
-
|
|
67
|
+
await unlink(tempFile);
|
|
65
68
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
code = `!function (undefined) { 'use strict'; ${
|
|
70
|
+
// compress `__webpack_require__` with `keep_fnames` option
|
|
71
|
+
String(file).replace(/function __webpack_require__/, 'var __webpack_require__ = function ')
|
|
72
|
+
} }();\n`;
|
|
73
|
+
} else {
|
|
74
|
+
const template = it => format === 'esm'
|
|
75
|
+
? `import 'core-js/modules/${ it }.js';\n`
|
|
76
|
+
: `require('core-js/modules/${ it }');\n`;
|
|
77
|
+
code = list.map(template).join('');
|
|
78
|
+
}
|
|
70
79
|
}
|
|
71
80
|
|
|
72
81
|
if (summary.comment.size) script += `/*\n * size: ${ (code.length / 1024).toFixed(2) }KB w/o comments\n */`;
|
|
@@ -81,9 +90,9 @@ module.exports = async function ({
|
|
|
81
90
|
|
|
82
91
|
if (summary.console.modules) {
|
|
83
92
|
console.log(`\u001B[32mbundling \u001B[36m${ TITLE }\u001B[32m, modules:\u001B[0m`);
|
|
84
|
-
for (const it of list) {
|
|
93
|
+
if (list.length) for (const it of list) {
|
|
85
94
|
console.log(`\u001B[36m${ it + (targets ? ` \u001B[32mfor \u001B[36m${ JSON.stringify(compatTargets[it]) }` : '') }\u001B[0m`);
|
|
86
|
-
}
|
|
95
|
+
} else console.log('\u001B[36mnothing\u001B[0m');
|
|
87
96
|
}
|
|
88
97
|
|
|
89
98
|
if (filename != null) {
|
package/package.json
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "core-js-builder",
|
|
3
|
+
"version": "3.26.1",
|
|
3
4
|
"description": "core-js builder",
|
|
4
|
-
"version": "3.25.5",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/zloirock/core-js.git",
|
|
8
8
|
"directory": "packages/core-js-builder"
|
|
9
9
|
},
|
|
10
|
-
"
|
|
10
|
+
"funding": {
|
|
11
|
+
"type": "opencollective",
|
|
12
|
+
"url": "https://opencollective.com/core-js"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Denis Pushkarev",
|
|
17
|
+
"email": "zloirock@zloirock.ru",
|
|
18
|
+
"url": "http://zloirock.ru"
|
|
19
|
+
},
|
|
11
20
|
"sideEffects": false,
|
|
21
|
+
"main": "index.js",
|
|
12
22
|
"dependencies": {
|
|
13
|
-
"core-js": "3.
|
|
14
|
-
"core-js-compat": "3.
|
|
23
|
+
"core-js": "3.26.1",
|
|
24
|
+
"core-js-compat": "3.26.1",
|
|
15
25
|
"mkdirp": ">=0.5.5 <1",
|
|
16
26
|
"webpack": ">=4.46.0 <5"
|
|
17
27
|
},
|
|
18
28
|
"engines": {
|
|
19
29
|
"node": ">=8.9.0"
|
|
20
|
-
}
|
|
21
|
-
"funding": {
|
|
22
|
-
"type": "opencollective",
|
|
23
|
-
"url": "https://opencollective.com/core-js"
|
|
24
|
-
},
|
|
25
|
-
"license": "MIT"
|
|
30
|
+
}
|
|
26
31
|
}
|