@rslib/core 0.0.12 → 0.0.13
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/dist/index.js
CHANGED
|
@@ -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.13\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)=>{
|
|
@@ -1410,7 +1415,9 @@ const composeAutoExternalConfig = (options)=>{
|
|
|
1410
1415
|
}
|
|
1411
1416
|
} : {};
|
|
1412
1417
|
};
|
|
1413
|
-
function composeMinifyConfig(
|
|
1418
|
+
function composeMinifyConfig(config) {
|
|
1419
|
+
const minify = config.output?.minify;
|
|
1420
|
+
const format = config.format;
|
|
1414
1421
|
if (void 0 !== minify) // User's minify configuration will be merged afterwards.
|
|
1415
1422
|
return {};
|
|
1416
1423
|
// When minify is not specified, Rslib will use a sane default for minify options.
|
|
@@ -1428,7 +1435,8 @@ function composeMinifyConfig(minify) {
|
|
|
1428
1435
|
defaults: false,
|
|
1429
1436
|
unused: true,
|
|
1430
1437
|
dead_code: true,
|
|
1431
|
-
toplevel
|
|
1438
|
+
// remoteEntry's global variable will be tree-shaken if `toplevel` is enabled in "mf" format
|
|
1439
|
+
toplevel: 'mf' !== format
|
|
1432
1440
|
},
|
|
1433
1441
|
format: {
|
|
1434
1442
|
comments: 'all'
|
|
@@ -1552,7 +1560,7 @@ async function createConstantRsbuildConfig() {
|
|
|
1552
1560
|
}
|
|
1553
1561
|
});
|
|
1554
1562
|
}
|
|
1555
|
-
const composeFormatConfig = (format)=>{
|
|
1563
|
+
const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
|
|
1556
1564
|
const jsParserOptions = {
|
|
1557
1565
|
cjs: {
|
|
1558
1566
|
requireResolve: false,
|
|
@@ -1623,20 +1631,45 @@ const composeFormatConfig = (format)=>{
|
|
|
1623
1631
|
}
|
|
1624
1632
|
};
|
|
1625
1633
|
case 'umd':
|
|
1634
|
+
{
|
|
1635
|
+
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.');
|
|
1636
|
+
const config = {
|
|
1637
|
+
tools: {
|
|
1638
|
+
rspack: {
|
|
1639
|
+
module: {
|
|
1640
|
+
parser: {
|
|
1641
|
+
javascript: {
|
|
1642
|
+
importMeta: false
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
},
|
|
1646
|
+
output: {
|
|
1647
|
+
asyncChunks: false,
|
|
1648
|
+
library: umdName ? {
|
|
1649
|
+
type: 'umd',
|
|
1650
|
+
name: umdName
|
|
1651
|
+
} : {
|
|
1652
|
+
type: 'umd'
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
};
|
|
1658
|
+
return config;
|
|
1659
|
+
}
|
|
1660
|
+
case 'mf':
|
|
1626
1661
|
return {
|
|
1627
1662
|
tools: {
|
|
1628
1663
|
rspack: {
|
|
1629
|
-
module: {
|
|
1630
|
-
parser: {
|
|
1631
|
-
javascript: {
|
|
1632
|
-
importMeta: false
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
},
|
|
1636
1664
|
output: {
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1665
|
+
uniqueName: pkgJson.name
|
|
1666
|
+
},
|
|
1667
|
+
// TODO when we provide dev mode for rslib mf format, this should be modified to as the same with config.mode
|
|
1668
|
+
// can not set nodeEnv to false, because mf format should build shared module.
|
|
1669
|
+
// If nodeEnv is false, the process.env.NODE_ENV in third-party packages's will not be replaced
|
|
1670
|
+
// now we have not provide dev mode for users, so we can always set nodeEnv as 'production'
|
|
1671
|
+
optimization: {
|
|
1672
|
+
nodeEnv: 'production'
|
|
1640
1673
|
}
|
|
1641
1674
|
}
|
|
1642
1675
|
}
|
|
@@ -1680,6 +1713,8 @@ const composeShimsConfig = (format, shims)=>{
|
|
|
1680
1713
|
};
|
|
1681
1714
|
case 'umd':
|
|
1682
1715
|
return {};
|
|
1716
|
+
case 'mf':
|
|
1717
|
+
return {};
|
|
1683
1718
|
default:
|
|
1684
1719
|
throw new Error(`Unsupported format: ${format}`);
|
|
1685
1720
|
}
|
|
@@ -1692,12 +1727,14 @@ const composeExternalsConfig = (format, externals)=>{
|
|
|
1692
1727
|
const externalsTypeMap = {
|
|
1693
1728
|
esm: 'module-import',
|
|
1694
1729
|
cjs: 'commonjs',
|
|
1695
|
-
umd: 'umd'
|
|
1730
|
+
umd: 'umd',
|
|
1731
|
+
mf: 'var'
|
|
1696
1732
|
};
|
|
1697
1733
|
switch(format){
|
|
1698
1734
|
case 'esm':
|
|
1699
1735
|
case 'cjs':
|
|
1700
1736
|
case 'umd':
|
|
1737
|
+
case 'mf':
|
|
1701
1738
|
return {
|
|
1702
1739
|
output: externals ? {
|
|
1703
1740
|
externals
|
|
@@ -1820,7 +1857,7 @@ const composeEntryConfig = async (entries, bundle, root, cssModulesAuto)=>{
|
|
|
1820
1857
|
lcp
|
|
1821
1858
|
};
|
|
1822
1859
|
};
|
|
1823
|
-
const composeBundleConfig = (jsExtension, redirect, cssModulesAuto, bundle
|
|
1860
|
+
const composeBundleConfig = (jsExtension, redirect, cssModulesAuto, bundle)=>{
|
|
1824
1861
|
if (bundle) return {};
|
|
1825
1862
|
const isStyleRedirect = redirect.style ?? true;
|
|
1826
1863
|
return {
|
|
@@ -1944,17 +1981,23 @@ const composeExternalHelpersConfig = (externalHelpers, pkgJson)=>{
|
|
|
1944
1981
|
return defaultConfig;
|
|
1945
1982
|
};
|
|
1946
1983
|
async function composeLibRsbuildConfig(config, configPath) {
|
|
1984
|
+
checkMFPlugin(config);
|
|
1947
1985
|
const rootPath = (0, __WEBPACK_EXTERNAL_MODULE_node_path__.dirname)(configPath);
|
|
1948
1986
|
const pkgJson = readPackageJson(rootPath);
|
|
1949
1987
|
const { compilerOptions } = await loadTsconfig(rootPath, config.source?.tsconfigPath);
|
|
1950
1988
|
const cssModulesAuto = config.output?.cssModules?.auto ?? true;
|
|
1951
|
-
const { format, shims, banner = {}, footer = {}, autoExtension = true, autoExternal = true, externalHelpers = false, redirect = {} } = config;
|
|
1989
|
+
const { format, shims, bundle = true, banner = {}, footer = {}, autoExtension = true, autoExternal = true, externalHelpers = false, redirect = {}, umdName } = config;
|
|
1952
1990
|
const shimsConfig = composeShimsConfig(format, shims);
|
|
1953
|
-
const formatConfig = composeFormatConfig(
|
|
1991
|
+
const formatConfig = composeFormatConfig({
|
|
1992
|
+
format: format,
|
|
1993
|
+
pkgJson: pkgJson,
|
|
1994
|
+
bundle,
|
|
1995
|
+
umdName
|
|
1996
|
+
});
|
|
1954
1997
|
const externalHelpersConfig = composeExternalHelpersConfig(externalHelpers, pkgJson);
|
|
1955
1998
|
const externalsConfig = composeExternalsConfig(format, config.output?.externals);
|
|
1956
1999
|
const { config: autoExtensionConfig, jsExtension, dtsExtension } = composeAutoExtensionConfig(config, autoExtension, pkgJson);
|
|
1957
|
-
const bundleConfig = composeBundleConfig(jsExtension, redirect, cssModulesAuto,
|
|
2000
|
+
const bundleConfig = composeBundleConfig(jsExtension, redirect, cssModulesAuto, bundle);
|
|
1958
2001
|
const targetConfig = composeTargetConfig(config.output?.target);
|
|
1959
2002
|
const syntaxConfig = composeSyntaxConfig(config?.syntax, config.output?.target);
|
|
1960
2003
|
const autoExternalConfig = composeAutoExternalConfig({
|
|
@@ -1966,7 +2009,7 @@ async function composeLibRsbuildConfig(config, configPath) {
|
|
|
1966
2009
|
const cssConfig = composeCssConfig(lcp, config.bundle);
|
|
1967
2010
|
const dtsConfig = await composeDtsConfig(config, dtsExtension);
|
|
1968
2011
|
const externalsWarnConfig = composeExternalsWarnConfig(format, autoExternalConfig?.output?.externals, externalsConfig?.output?.externals);
|
|
1969
|
-
const minifyConfig = composeMinifyConfig(config
|
|
2012
|
+
const minifyConfig = composeMinifyConfig(config);
|
|
1970
2013
|
const bannerFooterConfig = composeBannerFooterConfig(banner, footer);
|
|
1971
2014
|
const decoratorsConfig = composeDecoratorsConfig(compilerOptions, config.source?.decorators?.version);
|
|
1972
2015
|
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 +2042,20 @@ async function composeCreateRsbuildConfig(rslibConfig, path) {
|
|
|
1999
2042
|
// We should state in the document that the built-in configuration should not be changed optionally
|
|
2000
2043
|
// In compose process of 2, we may read some config from 1, and reassemble the related config,
|
|
2001
2044
|
// 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
|
-
|
|
2045
|
+
config: (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.mergeRsbuildConfig)(constantRsbuildConfig, libRsbuildConfig, omit(userConfig, {
|
|
2046
|
+
bundle: true,
|
|
2047
|
+
format: true,
|
|
2048
|
+
autoExtension: true,
|
|
2049
|
+
autoExternal: true,
|
|
2050
|
+
redirect: true,
|
|
2051
|
+
syntax: true,
|
|
2052
|
+
externalHelpers: true,
|
|
2053
|
+
banner: true,
|
|
2054
|
+
footer: true,
|
|
2055
|
+
dts: true,
|
|
2056
|
+
shims: true,
|
|
2057
|
+
umdName: true
|
|
2058
|
+
}))
|
|
2015
2059
|
};
|
|
2016
2060
|
});
|
|
2017
2061
|
const composedRsbuildConfig = await Promise.all(libConfigPromises);
|
|
@@ -2027,7 +2071,8 @@ async function initRsbuild(rslibConfig) {
|
|
|
2027
2071
|
const formatIndex = {
|
|
2028
2072
|
esm: 0,
|
|
2029
2073
|
cjs: 0,
|
|
2030
|
-
umd: 0
|
|
2074
|
+
umd: 0,
|
|
2075
|
+
mf: 0
|
|
2031
2076
|
};
|
|
2032
2077
|
for (const { format, config } of rsbuildConfigObject){
|
|
2033
2078
|
const currentFormatCount = formatCount[format];
|
|
@@ -2051,7 +2096,7 @@ const applyCommonOptions = (command)=>{
|
|
|
2051
2096
|
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
2097
|
};
|
|
2053
2098
|
function runCli() {
|
|
2054
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.name('rslib').usage('<command> [options]').version("0.0.
|
|
2099
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.name('rslib').usage('<command> [options]').version("0.0.13");
|
|
2055
2100
|
const buildCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.command('build');
|
|
2056
2101
|
const inspectCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.command('inspect');
|
|
2057
2102
|
[
|
|
@@ -2093,6 +2138,6 @@ function runCli() {
|
|
|
2093
2138
|
});
|
|
2094
2139
|
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.parse();
|
|
2095
2140
|
}
|
|
2096
|
-
const src_version = "0.0.
|
|
2141
|
+
const src_version = "0.0.13";
|
|
2097
2142
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger;
|
|
2098
2143
|
export { build, defineConfig, loadConfig, prepareCli, runCli, src_version as version, __webpack_exports__logger as logger };
|
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.13",
|
|
4
4
|
"description": "The Rspack-based library build tool.",
|
|
5
5
|
"homepage": "https://lib.rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@rsbuild/core": "~1.0.14",
|
|
36
|
-
"rsbuild-plugin-dts": "0.0.
|
|
36
|
+
"rsbuild-plugin-dts": "0.0.13"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@rspack/core": "1.0.8",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"memfs": "^4.14.0",
|
|
45
45
|
"picocolors": "1.1.0",
|
|
46
46
|
"prebundle": "1.2.2",
|
|
47
|
-
"rslib": "npm:@rslib/core@0.0.
|
|
47
|
+
"rslib": "npm:@rslib/core@0.0.12",
|
|
48
48
|
"rslog": "^1.2.3",
|
|
49
49
|
"tsconfck": "3.1.4",
|
|
50
50
|
"typescript": "^5.6.3",
|