@rslib/core 0.0.12 → 0.0.14
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/compiled/picocolors/index.d.ts +17 -18
- package/compiled/picocolors/index.js +56 -74
- package/compiled/picocolors/package.json +1 -1
- package/dist/index.js +190 -133
- package/dist/libCssExtractLoader.js +1 -1
- package/dist-types/config.d.ts +2 -2
- package/dist-types/types/config/index.d.ts +3 -1
- package/dist-types/types/utils.d.ts +1 -0
- package/dist-types/utils/helper.d.ts +4 -2
- package/package.json +6 -6
- package/compiled/fast-glob/index.d.ts +0 -237
- package/compiled/fast-glob/index.js +0 -7309
- package/compiled/fast-glob/license +0 -21
- package/compiled/fast-glob/package.json +0 -1
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import * as __WEBPACK_EXTERNAL_MODULE_node_path__ from "node:path";
|
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__ from "../compiled/picocolors/index.js";
|
|
6
6
|
import * as __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__ from "../compiled/commander/index.js";
|
|
7
7
|
import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core__ from "@rsbuild/core";
|
|
8
|
-
import * as
|
|
8
|
+
import * as __WEBPACK_EXTERNAL_MODULE_tinyglobby__ from "tinyglobby";
|
|
9
9
|
import * as __WEBPACK_EXTERNAL_MODULE_node_module__ from "node:module";
|
|
10
10
|
import * as __WEBPACK_EXTERNAL_MODULE_module__ from "module";
|
|
11
11
|
/**
|
|
@@ -112,12 +112,28 @@ function pick(obj, keys) {
|
|
|
112
112
|
return ret;
|
|
113
113
|
}, {});
|
|
114
114
|
}
|
|
115
|
-
function omit(obj,
|
|
115
|
+
function omit(obj, keysObj) {
|
|
116
116
|
return Object.keys(obj).reduce((ret, key)=>{
|
|
117
|
-
if (
|
|
117
|
+
if (true !== keysObj[key]) ret[key] = obj[key];
|
|
118
118
|
return ret;
|
|
119
119
|
}, {});
|
|
120
120
|
}
|
|
121
|
+
function isPluginIncluded(config, pluginName) {
|
|
122
|
+
return Boolean(config.plugins?.some((plugin)=>{
|
|
123
|
+
if ('object' == typeof plugin && null !== plugin && 'name' in plugin) return plugin.name === pluginName;
|
|
124
|
+
return false;
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
function checkMFPlugin(config) {
|
|
128
|
+
if ('mf' !== config.format) return true;
|
|
129
|
+
// https://github.com/module-federation/core/blob/4e5c4b96ee45899f3ba5904b8927768980d5ad0e/packages/rsbuild-plugin/src/cli/index.ts#L17
|
|
130
|
+
const added = isPluginIncluded(config, 'rsbuild:module-federation-enhanced');
|
|
131
|
+
if (!added) {
|
|
132
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.warn(`${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__["default"].green('format: "mf"')} should be used with ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__["default"].blue('@module-federation/rsbuild-plugin')}", consider installing and adding it to plugins. Check the documentation (https://module-federation.io/guide/basic/rsbuild.html#rslib-module) to get started with "mf" output.`);
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
return added;
|
|
136
|
+
}
|
|
121
137
|
// setup the logger level
|
|
122
138
|
if (process.env.DEBUG) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.level = 'verbose';
|
|
123
139
|
function initNodeEnv() {
|
|
@@ -134,7 +150,7 @@ function prepareCli() {
|
|
|
134
150
|
// Some package managers automatically output a blank line, some do not.
|
|
135
151
|
const { npm_execpath } = process.env;
|
|
136
152
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
137
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.greet(` Rslib v0.0.
|
|
153
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.greet(` Rslib v0.0.14\n`);
|
|
138
154
|
}
|
|
139
155
|
const DEFAULT_CONFIG_NAME = 'rslib.config';
|
|
140
156
|
const DEFAULT_CONFIG_EXTENSIONS = [
|
|
@@ -173,17 +189,17 @@ const ENTRY_EXTENSIONS = [
|
|
|
173
189
|
const JS_EXTENSIONS_PATTERN = new RegExp(`\\.(${JS_EXTENSIONS.join('|')})$`);
|
|
174
190
|
const CSS_EXTENSIONS_PATTERN = new RegExp(`\\.(${CSS_EXTENSIONS.join('|')})$`);
|
|
175
191
|
const ENTRY_EXTENSIONS_PATTERN = new RegExp(`\\.(${ENTRY_EXTENSIONS.join('|')})$`);
|
|
176
|
-
const
|
|
192
|
+
const RemoveCssExtractAssetPlugin_pluginName = 'REMOVE_CSS_EXTRACT_ASSET_PLUGIN';
|
|
177
193
|
class RemoveCssExtractAssetPlugin {
|
|
178
|
-
name =
|
|
194
|
+
name = RemoveCssExtractAssetPlugin_pluginName;
|
|
179
195
|
options;
|
|
180
196
|
constructor(options){
|
|
181
197
|
this.options = options;
|
|
182
198
|
}
|
|
183
199
|
apply(compiler) {
|
|
184
200
|
const include = this.options.include;
|
|
185
|
-
compiler.hooks.thisCompilation.tap(
|
|
186
|
-
compilation.hooks.chunkAsset.tap(
|
|
201
|
+
compiler.hooks.thisCompilation.tap(RemoveCssExtractAssetPlugin_pluginName, (compilation)=>{
|
|
202
|
+
compilation.hooks.chunkAsset.tap(RemoveCssExtractAssetPlugin_pluginName, (_chunk, filename)=>{
|
|
187
203
|
const asset = compilation.getAsset(filename);
|
|
188
204
|
if (!asset) return;
|
|
189
205
|
const needRemove = Boolean(asset.name.match(include));
|
|
@@ -395,115 +411,104 @@ const RSPACK_TARGET_UNLISTED_MODERN_ECMA_VERSIONS = [
|
|
|
395
411
|
* https://github.com/rspack-contrib/browserslist-to-es-version
|
|
396
412
|
* TODO: align with Rsbuild, we may should align with SWC
|
|
397
413
|
*/ const ESX_TO_BROWSERSLIST = {
|
|
414
|
+
es5: {
|
|
415
|
+
chrome: '5.0.0',
|
|
416
|
+
edge: '12.0.0',
|
|
417
|
+
firefox: '2.0.0',
|
|
418
|
+
ie: '9.0.0',
|
|
419
|
+
ios: '6.0.0',
|
|
420
|
+
node: '0.4.0',
|
|
421
|
+
opera: '10.10.0',
|
|
422
|
+
safari: '3.1.0'
|
|
423
|
+
},
|
|
398
424
|
es6: {
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
],
|
|
407
|
-
Opera: '50.0.0',
|
|
408
|
-
Safari: '13.0.0'
|
|
425
|
+
chrome: '63.0.0',
|
|
426
|
+
edge: '79.0.0',
|
|
427
|
+
firefox: '67.0.0',
|
|
428
|
+
ios: '13.0.0',
|
|
429
|
+
node: '13.2.0',
|
|
430
|
+
opera: '50.0.0',
|
|
431
|
+
safari: '13.0.0'
|
|
409
432
|
},
|
|
410
433
|
es2015: {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
434
|
+
chrome: '63.0.0',
|
|
435
|
+
edge: '79.0.0',
|
|
436
|
+
firefox: '67.0.0',
|
|
437
|
+
ios: '13.0.0',
|
|
438
|
+
node: '13.2.0',
|
|
439
|
+
opera: '50.0.0',
|
|
440
|
+
safari: '13.0.0'
|
|
418
441
|
},
|
|
419
442
|
es2016: {
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
443
|
+
chrome: '63.0.0',
|
|
444
|
+
edge: '79.0.0',
|
|
445
|
+
firefox: '67.0.0',
|
|
446
|
+
ios: '13.0.0',
|
|
447
|
+
node: '13.2.0',
|
|
448
|
+
opera: '50.0.0',
|
|
449
|
+
safari: '13.0.0'
|
|
427
450
|
},
|
|
428
451
|
es2017: {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
452
|
+
chrome: '63.0.0',
|
|
453
|
+
edge: '79.0.0',
|
|
454
|
+
firefox: '67.0.0',
|
|
455
|
+
ios: '13.0.0',
|
|
456
|
+
node: '13.2.0',
|
|
457
|
+
opera: '50.0.0',
|
|
458
|
+
safari: '13.0.0'
|
|
436
459
|
},
|
|
437
460
|
es2018: {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
'node > 21.3.0'
|
|
446
|
-
],
|
|
447
|
-
Opera: '51.0.0',
|
|
448
|
-
Safari: '16.4.0'
|
|
461
|
+
chrome: '64.0.0',
|
|
462
|
+
edge: '79.0.0',
|
|
463
|
+
firefox: '78.0.0',
|
|
464
|
+
ios: '16.4.0',
|
|
465
|
+
node: '13.2.0',
|
|
466
|
+
opera: '51.0.0',
|
|
467
|
+
safari: '16.4.0'
|
|
449
468
|
},
|
|
450
469
|
es2019: {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
470
|
+
chrome: '66.0.0',
|
|
471
|
+
edge: '79.0.0',
|
|
472
|
+
firefox: '78.0.0',
|
|
473
|
+
ios: '16.4.0',
|
|
474
|
+
node: '13.2.0',
|
|
475
|
+
opera: '53.0.0',
|
|
476
|
+
safari: '16.4.0'
|
|
458
477
|
},
|
|
459
478
|
es2020: {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
479
|
+
chrome: '91.0.0',
|
|
480
|
+
edge: '91.0.0',
|
|
481
|
+
firefox: '80.0.0',
|
|
482
|
+
ios: '16.4.0',
|
|
483
|
+
node: '16.1.0',
|
|
484
|
+
opera: '77.0.0',
|
|
485
|
+
safari: '16.4.0'
|
|
467
486
|
},
|
|
468
487
|
es2021: {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
488
|
+
chrome: '91.0.0',
|
|
489
|
+
edge: '91.0.0',
|
|
490
|
+
firefox: '80.0.0',
|
|
491
|
+
ios: '16.4.0',
|
|
492
|
+
node: '16.1.0',
|
|
493
|
+
opera: '77.0.0',
|
|
494
|
+
safari: '16.4.0'
|
|
476
495
|
},
|
|
477
496
|
es2022: {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
Opera: '80.0.0',
|
|
484
|
-
Safari: '16.4.0'
|
|
497
|
+
chrome: '91.0.0',
|
|
498
|
+
firefox: '93.0.0',
|
|
499
|
+
ios: '16.4.0',
|
|
500
|
+
node: '16.11.0',
|
|
501
|
+
safari: '16.4.0'
|
|
485
502
|
},
|
|
486
503
|
es2023: {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
Opera: '62.0.0',
|
|
493
|
-
Safari: '13.1.0'
|
|
504
|
+
chrome: '91.0.0',
|
|
505
|
+
firefox: '93.0.0',
|
|
506
|
+
ios: '16.4.0',
|
|
507
|
+
node: '16.11.0',
|
|
508
|
+
safari: '16.4.0'
|
|
494
509
|
},
|
|
495
510
|
es2024: calcEsnextBrowserslistByTarget,
|
|
496
|
-
esnext: calcEsnextBrowserslistByTarget
|
|
497
|
-
es5: {
|
|
498
|
-
Chrome: '5.0.0',
|
|
499
|
-
Edge: '12.0.0',
|
|
500
|
-
Firefox: '2.0.0',
|
|
501
|
-
ie: '9.0.0',
|
|
502
|
-
iOS: '6.0.0',
|
|
503
|
-
Node: '0.4.0',
|
|
504
|
-
Opera: '10.10.0',
|
|
505
|
-
Safari: '3.1.0'
|
|
506
|
-
}
|
|
511
|
+
esnext: calcEsnextBrowserslistByTarget
|
|
507
512
|
};
|
|
508
513
|
function transformSyntaxToRspackTarget(syntax) {
|
|
509
514
|
const handleSyntaxItem = (syntaxItem)=>{
|
|
@@ -513,6 +518,8 @@ function transformSyntaxToRspackTarget(syntax) {
|
|
|
513
518
|
// The latest EcmaScript version supported by Rspack's `target` is es2022.
|
|
514
519
|
// Higher versions are treated as es2022.
|
|
515
520
|
if (RSPACK_TARGET_UNLISTED_MODERN_ECMA_VERSIONS.includes(normalizedSyntaxItem)) return 'es2022';
|
|
521
|
+
// The es6 is the same as es2015, compatible with rspack API schema
|
|
522
|
+
if ('es6' === normalizedSyntaxItem) return 'es2015';
|
|
516
523
|
return normalizedSyntaxItem;
|
|
517
524
|
}
|
|
518
525
|
throw new Error(`Unsupported ES version: ${syntaxItem}`);
|
|
@@ -1410,7 +1417,9 @@ const composeAutoExternalConfig = (options)=>{
|
|
|
1410
1417
|
}
|
|
1411
1418
|
} : {};
|
|
1412
1419
|
};
|
|
1413
|
-
function composeMinifyConfig(
|
|
1420
|
+
function composeMinifyConfig(config) {
|
|
1421
|
+
const minify = config.output?.minify;
|
|
1422
|
+
const format = config.format;
|
|
1414
1423
|
if (void 0 !== minify) // User's minify configuration will be merged afterwards.
|
|
1415
1424
|
return {};
|
|
1416
1425
|
// When minify is not specified, Rslib will use a sane default for minify options.
|
|
@@ -1428,7 +1437,8 @@ function composeMinifyConfig(minify) {
|
|
|
1428
1437
|
defaults: false,
|
|
1429
1438
|
unused: true,
|
|
1430
1439
|
dead_code: true,
|
|
1431
|
-
toplevel
|
|
1440
|
+
// remoteEntry's global variable will be tree-shaken if `toplevel` is enabled in "mf" format
|
|
1441
|
+
toplevel: 'mf' !== format
|
|
1432
1442
|
},
|
|
1433
1443
|
format: {
|
|
1434
1444
|
comments: 'all'
|
|
@@ -1504,10 +1514,19 @@ async function createConstantRsbuildConfig() {
|
|
|
1504
1514
|
dev: {
|
|
1505
1515
|
progressBar: false
|
|
1506
1516
|
},
|
|
1517
|
+
performance: {
|
|
1518
|
+
chunkSplit: {
|
|
1519
|
+
strategy: 'custom'
|
|
1520
|
+
}
|
|
1521
|
+
},
|
|
1507
1522
|
tools: {
|
|
1508
1523
|
htmlPlugin: false,
|
|
1509
1524
|
rspack: {
|
|
1510
1525
|
optimization: {
|
|
1526
|
+
splitChunks: {
|
|
1527
|
+
// Splitted "sync" chunks will make entry modules can't be inlined.
|
|
1528
|
+
chunks: 'async'
|
|
1529
|
+
},
|
|
1511
1530
|
moduleIds: 'named',
|
|
1512
1531
|
nodeEnv: false
|
|
1513
1532
|
},
|
|
@@ -1552,7 +1571,7 @@ async function createConstantRsbuildConfig() {
|
|
|
1552
1571
|
}
|
|
1553
1572
|
});
|
|
1554
1573
|
}
|
|
1555
|
-
const composeFormatConfig = (format)=>{
|
|
1574
|
+
const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
1556
1575
|
const jsParserOptions = {
|
|
1557
1576
|
cjs: {
|
|
1558
1577
|
requireResolve: false,
|
|
@@ -1623,20 +1642,45 @@ const composeFormatConfig = (format)=>{
|
|
|
1623
1642
|
}
|
|
1624
1643
|
};
|
|
1625
1644
|
case 'umd':
|
|
1645
|
+
{
|
|
1646
|
+
if (false === bundle) throw new Error('When using "umd" format, "bundle" must be set to "true". Since the default value for "bundle" is "true", so you can either explicitly set it to "true" or remove the field entirely.');
|
|
1647
|
+
const config = {
|
|
1648
|
+
tools: {
|
|
1649
|
+
rspack: {
|
|
1650
|
+
module: {
|
|
1651
|
+
parser: {
|
|
1652
|
+
javascript: {
|
|
1653
|
+
importMeta: false
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
},
|
|
1657
|
+
output: {
|
|
1658
|
+
asyncChunks: false,
|
|
1659
|
+
library: umdName ? {
|
|
1660
|
+
type: 'umd',
|
|
1661
|
+
name: umdName
|
|
1662
|
+
} : {
|
|
1663
|
+
type: 'umd'
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
};
|
|
1669
|
+
return config;
|
|
1670
|
+
}
|
|
1671
|
+
case 'mf':
|
|
1626
1672
|
return {
|
|
1627
1673
|
tools: {
|
|
1628
1674
|
rspack: {
|
|
1629
|
-
module: {
|
|
1630
|
-
parser: {
|
|
1631
|
-
javascript: {
|
|
1632
|
-
importMeta: false
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
},
|
|
1636
1675
|
output: {
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1676
|
+
uniqueName: pkgJson.name
|
|
1677
|
+
},
|
|
1678
|
+
// TODO when we provide dev mode for rslib mf format, this should be modified to as the same with config.mode
|
|
1679
|
+
// can not set nodeEnv to false, because mf format should build shared module.
|
|
1680
|
+
// If nodeEnv is false, the process.env.NODE_ENV in third-party packages's will not be replaced
|
|
1681
|
+
// now we have not provide dev mode for users, so we can always set nodeEnv as 'production'
|
|
1682
|
+
optimization: {
|
|
1683
|
+
nodeEnv: 'production'
|
|
1640
1684
|
}
|
|
1641
1685
|
}
|
|
1642
1686
|
}
|
|
@@ -1680,6 +1724,8 @@ const composeShimsConfig = (format, shims)=>{
|
|
|
1680
1724
|
};
|
|
1681
1725
|
case 'umd':
|
|
1682
1726
|
return {};
|
|
1727
|
+
case 'mf':
|
|
1728
|
+
return {};
|
|
1683
1729
|
default:
|
|
1684
1730
|
throw new Error(`Unsupported format: ${format}`);
|
|
1685
1731
|
}
|
|
@@ -1692,12 +1738,14 @@ const composeExternalsConfig = (format, externals)=>{
|
|
|
1692
1738
|
const externalsTypeMap = {
|
|
1693
1739
|
esm: 'module-import',
|
|
1694
1740
|
cjs: 'commonjs',
|
|
1695
|
-
umd: 'umd'
|
|
1741
|
+
umd: 'umd',
|
|
1742
|
+
mf: 'var'
|
|
1696
1743
|
};
|
|
1697
1744
|
switch(format){
|
|
1698
1745
|
case 'esm':
|
|
1699
1746
|
case 'cjs':
|
|
1700
1747
|
case 'umd':
|
|
1748
|
+
case 'mf':
|
|
1701
1749
|
return {
|
|
1702
1750
|
output: externals ? {
|
|
1703
1751
|
externals
|
|
@@ -1784,8 +1832,9 @@ const composeEntryConfig = async (entries, bundle, root, cssModulesAuto)=>{
|
|
|
1784
1832
|
] : null;
|
|
1785
1833
|
if (!entryFiles) throw new Error('Entry can only be a string or an array of strings for now');
|
|
1786
1834
|
// Turn entries in array into each separate entry.
|
|
1787
|
-
const globEntryFiles = await (0,
|
|
1788
|
-
cwd: root
|
|
1835
|
+
const globEntryFiles = await (0, __WEBPACK_EXTERNAL_MODULE_tinyglobby__.glob)(entryFiles, {
|
|
1836
|
+
cwd: root,
|
|
1837
|
+
absolute: true
|
|
1789
1838
|
});
|
|
1790
1839
|
// Filter the glob resolved entry files based on the allowed extensions
|
|
1791
1840
|
const resolvedEntryFiles = globEntryFiles.filter((file)=>ENTRY_EXTENSIONS_PATTERN.test(file));
|
|
@@ -1820,7 +1869,7 @@ const composeEntryConfig = async (entries, bundle, root, cssModulesAuto)=>{
|
|
|
1820
1869
|
lcp
|
|
1821
1870
|
};
|
|
1822
1871
|
};
|
|
1823
|
-
const composeBundleConfig = (jsExtension, redirect, cssModulesAuto, bundle
|
|
1872
|
+
const composeBundleConfig = (jsExtension, redirect, cssModulesAuto, bundle)=>{
|
|
1824
1873
|
if (bundle) return {};
|
|
1825
1874
|
const isStyleRedirect = redirect.style ?? true;
|
|
1826
1875
|
return {
|
|
@@ -1944,17 +1993,23 @@ const composeExternalHelpersConfig = (externalHelpers, pkgJson)=>{
|
|
|
1944
1993
|
return defaultConfig;
|
|
1945
1994
|
};
|
|
1946
1995
|
async function composeLibRsbuildConfig(config, configPath) {
|
|
1996
|
+
checkMFPlugin(config);
|
|
1947
1997
|
const rootPath = (0, __WEBPACK_EXTERNAL_MODULE_node_path__.dirname)(configPath);
|
|
1948
1998
|
const pkgJson = readPackageJson(rootPath);
|
|
1949
1999
|
const { compilerOptions } = await loadTsconfig(rootPath, config.source?.tsconfigPath);
|
|
1950
2000
|
const cssModulesAuto = config.output?.cssModules?.auto ?? true;
|
|
1951
|
-
const { format, shims, banner = {}, footer = {}, autoExtension = true, autoExternal = true, externalHelpers = false, redirect = {} } = config;
|
|
2001
|
+
const { format, shims, bundle = true, banner = {}, footer = {}, autoExtension = true, autoExternal = true, externalHelpers = false, redirect = {}, umdName } = config;
|
|
1952
2002
|
const shimsConfig = composeShimsConfig(format, shims);
|
|
1953
|
-
const formatConfig = composeFormatConfig(
|
|
2003
|
+
const formatConfig = composeFormatConfig({
|
|
2004
|
+
format: format,
|
|
2005
|
+
pkgJson: pkgJson,
|
|
2006
|
+
bundle,
|
|
2007
|
+
umdName
|
|
2008
|
+
});
|
|
1954
2009
|
const externalHelpersConfig = composeExternalHelpersConfig(externalHelpers, pkgJson);
|
|
1955
2010
|
const externalsConfig = composeExternalsConfig(format, config.output?.externals);
|
|
1956
2011
|
const { config: autoExtensionConfig, jsExtension, dtsExtension } = composeAutoExtensionConfig(config, autoExtension, pkgJson);
|
|
1957
|
-
const bundleConfig = composeBundleConfig(jsExtension, redirect, cssModulesAuto,
|
|
2012
|
+
const bundleConfig = composeBundleConfig(jsExtension, redirect, cssModulesAuto, bundle);
|
|
1958
2013
|
const targetConfig = composeTargetConfig(config.output?.target);
|
|
1959
2014
|
const syntaxConfig = composeSyntaxConfig(config?.syntax, config.output?.target);
|
|
1960
2015
|
const autoExternalConfig = composeAutoExternalConfig({
|
|
@@ -1966,7 +2021,7 @@ async function composeLibRsbuildConfig(config, configPath) {
|
|
|
1966
2021
|
const cssConfig = composeCssConfig(lcp, config.bundle);
|
|
1967
2022
|
const dtsConfig = await composeDtsConfig(config, dtsExtension);
|
|
1968
2023
|
const externalsWarnConfig = composeExternalsWarnConfig(format, autoExternalConfig?.output?.externals, externalsConfig?.output?.externals);
|
|
1969
|
-
const minifyConfig = composeMinifyConfig(config
|
|
2024
|
+
const minifyConfig = composeMinifyConfig(config);
|
|
1970
2025
|
const bannerFooterConfig = composeBannerFooterConfig(banner, footer);
|
|
1971
2026
|
const decoratorsConfig = composeDecoratorsConfig(compilerOptions, config.source?.decorators?.version);
|
|
1972
2027
|
return (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.mergeRsbuildConfig)(formatConfig, shimsConfig, externalHelpersConfig, externalsWarnConfig, externalsConfig, autoExternalConfig, autoExtensionConfig, syntaxConfig, bundleConfig, targetConfig, entryConfig, cssConfig, minifyConfig, dtsConfig, bannerFooterConfig, decoratorsConfig);
|
|
@@ -1999,19 +2054,20 @@ async function composeCreateRsbuildConfig(rslibConfig, path) {
|
|
|
1999
2054
|
// We should state in the document that the built-in configuration should not be changed optionally
|
|
2000
2055
|
// In compose process of 2, we may read some config from 1, and reassemble the related config,
|
|
2001
2056
|
// so before final mergeRsbuildConfig, we reset some specified fields
|
|
2002
|
-
config: (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.mergeRsbuildConfig)(constantRsbuildConfig, libRsbuildConfig, omit(userConfig,
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2057
|
+
config: (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.mergeRsbuildConfig)(constantRsbuildConfig, libRsbuildConfig, omit(userConfig, {
|
|
2058
|
+
bundle: true,
|
|
2059
|
+
format: true,
|
|
2060
|
+
autoExtension: true,
|
|
2061
|
+
autoExternal: true,
|
|
2062
|
+
redirect: true,
|
|
2063
|
+
syntax: true,
|
|
2064
|
+
externalHelpers: true,
|
|
2065
|
+
banner: true,
|
|
2066
|
+
footer: true,
|
|
2067
|
+
dts: true,
|
|
2068
|
+
shims: true,
|
|
2069
|
+
umdName: true
|
|
2070
|
+
}))
|
|
2015
2071
|
};
|
|
2016
2072
|
});
|
|
2017
2073
|
const composedRsbuildConfig = await Promise.all(libConfigPromises);
|
|
@@ -2027,7 +2083,8 @@ async function initRsbuild(rslibConfig) {
|
|
|
2027
2083
|
const formatIndex = {
|
|
2028
2084
|
esm: 0,
|
|
2029
2085
|
cjs: 0,
|
|
2030
|
-
umd: 0
|
|
2086
|
+
umd: 0,
|
|
2087
|
+
mf: 0
|
|
2031
2088
|
};
|
|
2032
2089
|
for (const { format, config } of rsbuildConfigObject){
|
|
2033
2090
|
const currentFormatCount = formatCount[format];
|
|
@@ -2051,7 +2108,7 @@ const applyCommonOptions = (command)=>{
|
|
|
2051
2108
|
command.option('-c --config <config>', 'specify the configuration file, can be a relative or absolute path').option('--env-mode <mode>', 'specify the env mode to load the `.env.[mode]` file');
|
|
2052
2109
|
};
|
|
2053
2110
|
function runCli() {
|
|
2054
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.name('rslib').usage('<command> [options]').version("0.0.
|
|
2111
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.name('rslib').usage('<command> [options]').version("0.0.14");
|
|
2055
2112
|
const buildCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.command('build');
|
|
2056
2113
|
const inspectCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.command('inspect');
|
|
2057
2114
|
[
|
|
@@ -2093,6 +2150,6 @@ function runCli() {
|
|
|
2093
2150
|
});
|
|
2094
2151
|
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.parse();
|
|
2095
2152
|
}
|
|
2096
|
-
const src_version = "0.0.
|
|
2153
|
+
const src_version = "0.0.14";
|
|
2097
2154
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger;
|
|
2098
2155
|
export { build, defineConfig, loadConfig, prepareCli, runCli, src_version as version, __webpack_exports__logger as logger };
|
|
@@ -121,5 +121,5 @@ const pitch = function(request, _, _data) {
|
|
|
121
121
|
handleExports(exports);
|
|
122
122
|
});
|
|
123
123
|
};
|
|
124
|
-
/*
|
|
124
|
+
/* ESM default export */ const libCssExtractLoader = libCssExtractLoader_loader;
|
|
125
125
|
export { libCssExtractLoader as default, pitch };
|
package/dist-types/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RsbuildConfig, type RsbuildInstance } from '@rsbuild/core';
|
|
2
|
-
import type { AutoExternal, BannerAndFooter, Format, PkgJson, RslibConfig, RslibConfigAsyncFn, RslibConfigExport, RslibConfigSyncFn } from './types';
|
|
2
|
+
import type { AutoExternal, BannerAndFooter, Format, LibConfig, PkgJson, RslibConfig, RslibConfigAsyncFn, RslibConfigExport, RslibConfigSyncFn } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* This function helps you to autocomplete configuration types.
|
|
5
5
|
* It accepts a Rslib config object, or a function that returns a config.
|
|
@@ -18,7 +18,7 @@ export declare const composeAutoExternalConfig: (options: {
|
|
|
18
18
|
pkgJson?: PkgJson;
|
|
19
19
|
userExternals?: NonNullable<RsbuildConfig["output"]>["externals"];
|
|
20
20
|
}) => RsbuildConfig;
|
|
21
|
-
export declare function composeMinifyConfig(
|
|
21
|
+
export declare function composeMinifyConfig(config: LibConfig): RsbuildConfig;
|
|
22
22
|
export declare function composeBannerFooterConfig(banner: BannerAndFooter, footer: BannerAndFooter): RsbuildConfig;
|
|
23
23
|
export declare function composeDecoratorsConfig(compilerOptions?: Record<string, any>, version?: NonNullable<NonNullable<RsbuildConfig['source']>['decorators']>['version']): RsbuildConfig;
|
|
24
24
|
export declare function createConstantRsbuildConfig(): Promise<RsbuildConfig>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RsbuildConfig } from '@rsbuild/core';
|
|
2
2
|
import type { PluginDtsOptions } from 'rsbuild-plugin-dts';
|
|
3
|
-
export type Format = 'esm' | 'cjs' | 'umd';
|
|
3
|
+
export type Format = 'esm' | 'cjs' | 'umd' | 'mf';
|
|
4
4
|
export type FixedEcmaVersions = 'es5' | 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'es2023';
|
|
5
5
|
export type LatestEcmaVersions = 'es2024' | 'esnext';
|
|
6
6
|
export type EcmaScriptVersion = FixedEcmaVersions | LatestEcmaVersions;
|
|
@@ -45,7 +45,9 @@ export interface LibConfig extends RsbuildConfig {
|
|
|
45
45
|
footer?: BannerAndFooter;
|
|
46
46
|
shims?: Shims;
|
|
47
47
|
dts?: Dts;
|
|
48
|
+
umdName?: string;
|
|
48
49
|
}
|
|
50
|
+
export type LibOnlyConfig = Omit<LibConfig, keyof RsbuildConfig>;
|
|
49
51
|
export interface RslibConfig extends RsbuildConfig {
|
|
50
52
|
lib: LibConfig[];
|
|
51
53
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import color from 'picocolors';
|
|
2
|
-
import type { PkgJson } from '../types';
|
|
2
|
+
import type { LibConfig, PkgJson } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* Node.js built-in modules.
|
|
5
5
|
* Copied from https://github.com/webpack/webpack/blob/dd44b206a9c50f4b4cb4d134e1a0bd0387b159a3/lib/node/NodeTargetPlugin.js#L12-L72
|
|
@@ -10,5 +10,7 @@ export declare const readPackageJson: (rootPath: string) => undefined | PkgJson;
|
|
|
10
10
|
export declare const isObject: (obj: unknown) => obj is Record<string, any>;
|
|
11
11
|
export declare const isEmptyObject: (obj: object) => boolean;
|
|
12
12
|
export declare function pick<T, U extends keyof T>(obj: T, keys: ReadonlyArray<U>): Pick<T, U>;
|
|
13
|
-
export declare function omit<T extends object, U extends keyof T>(obj: T,
|
|
13
|
+
export declare function omit<T extends object, U extends keyof T>(obj: T, keysObj: Record<U, boolean>): Omit<T, keyof U>;
|
|
14
|
+
export declare function isPluginIncluded(config: LibConfig, pluginName: string): boolean;
|
|
15
|
+
export declare function checkMFPlugin(config: LibConfig): boolean;
|
|
14
16
|
export { color };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"description": "The Rspack-based library build tool.",
|
|
5
5
|
"homepage": "https://lib.rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -32,19 +32,19 @@
|
|
|
32
32
|
"compiled"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@rsbuild/core": "~1.0.
|
|
36
|
-
"
|
|
35
|
+
"@rsbuild/core": "~1.0.17",
|
|
36
|
+
"tinyglobby": "^0.2.9",
|
|
37
|
+
"rsbuild-plugin-dts": "0.0.14"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@rspack/core": "1.0.8",
|
|
40
41
|
"@types/fs-extra": "^11.0.4",
|
|
41
42
|
"commander": "^12.1.0",
|
|
42
|
-
"fast-glob": "^3.3.2",
|
|
43
43
|
"fs-extra": "^11.2.0",
|
|
44
44
|
"memfs": "^4.14.0",
|
|
45
|
-
"picocolors": "1.1.
|
|
45
|
+
"picocolors": "1.1.1",
|
|
46
46
|
"prebundle": "1.2.2",
|
|
47
|
-
"rslib": "npm:@rslib/core@0.0.
|
|
47
|
+
"rslib": "npm:@rslib/core@0.0.13",
|
|
48
48
|
"rslog": "^1.2.3",
|
|
49
49
|
"tsconfck": "3.1.4",
|
|
50
50
|
"typescript": "^5.6.3",
|