@rslib/core 0.6.0 → 0.6.2
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/chokidar/index.d.ts +2 -1
- package/compiled/commander/index.d.ts +2 -1
- package/compiled/rslog/index.d.ts +2 -1
- package/dist/entryModuleLoader.js +4 -7
- package/dist/index.js +77 -87
- package/dist/libCssExtractLoader.js +69 -15
- package/dist-types/config.d.ts +0 -1
- package/dist-types/constant.d.ts +0 -1
- package/dist-types/css/cssConfig.d.ts +1 -1
- package/dist-types/css/libCssExtractLoader.d.ts +2 -0
- package/dist-types/index.d.ts +2 -0
- package/package.json +7 -7
|
@@ -342,4 +342,5 @@ declare const _default: {
|
|
|
342
342
|
FSWatcher: typeof FSWatcher;
|
|
343
343
|
};
|
|
344
344
|
|
|
345
|
-
export {
|
|
345
|
+
export { FSWatcher, WatchHelper, _default as default, watch };
|
|
346
|
+
export type { ChokidarOptions, EmitArgs, EmitArgsWithName, EmitErrorArgs, FSWInstanceOptions, FSWatcherEventMap, FSWatcherKnownEventMap, MatchFunction, Matcher, MatcherObject, ThrottleType, Throttler };
|
|
@@ -1044,4 +1044,5 @@ declare function createArgument(name: string, description?: string): Argument;
|
|
|
1044
1044
|
|
|
1045
1045
|
declare const program: Command;
|
|
1046
1046
|
|
|
1047
|
-
export {
|
|
1047
|
+
export { Argument, Command, CommanderError, Help, InvalidArgumentError, InvalidArgumentError as InvalidOptionArgumentError, Option, createArgument, createCommand, createOption, program };
|
|
1048
|
+
export type { AddHelpTextContext, AddHelpTextPosition, CommandOptions, ErrorOptions, ExecutableCommandOptions, HelpConfiguration, HelpContext, HookEvent, OptionValueSource, OptionValues, OutputConfiguration, ParseOptions, ParseOptionsResult };
|
|
@@ -63,4 +63,5 @@ declare let createLogger: (options?: Options) => Logger;
|
|
|
63
63
|
|
|
64
64
|
declare let logger: Logger;
|
|
65
65
|
|
|
66
|
-
export {
|
|
66
|
+
export { createLogger, logger };
|
|
67
|
+
export type { LogFunction, LogLevel, LogMessage, LogType, Logger, Options };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const RSLIB_ENTRY_QUERY = '__rslib_entry__';
|
|
2
1
|
const SHEBANG_REGEX = /#!.*[\s\n\r]*$/;
|
|
3
2
|
const REACT_DIRECTIVE_REGEX = /^['"]use (client|server)['"](;?)[\s\n\r]*$/;
|
|
4
3
|
const DTS_EXTENSIONS = [
|
|
@@ -44,12 +43,10 @@ function splitFromFirstLine(text) {
|
|
|
44
43
|
}
|
|
45
44
|
const entryModuleLoader_rslib_entry_loader = function(source) {
|
|
46
45
|
let result = source;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (REACT_DIRECTIVE_REGEX.test(firstLine2)) result = rest2;
|
|
52
|
-
}
|
|
46
|
+
const [firstLine1, rest] = splitFromFirstLine(result);
|
|
47
|
+
if (SHEBANG_REGEX.test(firstLine1)) result = rest;
|
|
48
|
+
const [firstLine2, rest2] = splitFromFirstLine(result);
|
|
49
|
+
if (REACT_DIRECTIVE_REGEX.test(firstLine2)) result = rest2;
|
|
53
50
|
return result;
|
|
54
51
|
};
|
|
55
52
|
const entryModuleLoader_rslib_entry_ = entryModuleLoader_rslib_entry_loader;
|
package/dist/index.js
CHANGED
|
@@ -184,7 +184,7 @@ function prepareCli() {
|
|
|
184
184
|
initNodeEnv();
|
|
185
185
|
const { npm_execpath } = process.env;
|
|
186
186
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
187
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rslib v0.6.
|
|
187
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rslib v0.6.2\n`);
|
|
188
188
|
}
|
|
189
189
|
const DEFAULT_CONFIG_NAME = 'rslib.config';
|
|
190
190
|
const DEFAULT_CONFIG_EXTENSIONS = [
|
|
@@ -196,7 +196,6 @@ const DEFAULT_CONFIG_EXTENSIONS = [
|
|
|
196
196
|
'.cts'
|
|
197
197
|
];
|
|
198
198
|
const SWC_HELPERS = '@swc/helpers';
|
|
199
|
-
const RSLIB_ENTRY_QUERY = '__rslib_entry__';
|
|
200
199
|
const SHEBANG_PREFIX = '#!';
|
|
201
200
|
const SHEBANG_REGEX = /#!.*[\s\n\r]*$/;
|
|
202
201
|
const REACT_DIRECTIVE_REGEX = /^['"]use (client|server)['"](;?)[\s\n\r]*$/;
|
|
@@ -234,17 +233,16 @@ function getUndoPath(filename, outputPathArg, enforceRelative) {
|
|
|
234
233
|
let depth = -1;
|
|
235
234
|
let append = '';
|
|
236
235
|
let outputPath = outputPathArg.replace(/[\\/]$/, '');
|
|
237
|
-
for (const part of filename.split(/[/\\]+/))if ('..' === part)
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
} else if ('.' !== part) depth++;
|
|
236
|
+
for (const part of filename.split(/[/\\]+/))if ('..' === part) if (depth > -1) depth--;
|
|
237
|
+
else {
|
|
238
|
+
const i = outputPath.lastIndexOf('/');
|
|
239
|
+
const j = outputPath.lastIndexOf('\\');
|
|
240
|
+
const pos = i < 0 ? j : j < 0 ? i : Math.max(i, j);
|
|
241
|
+
if (pos < 0) return `${outputPath}/`;
|
|
242
|
+
append = `${outputPath.slice(pos + 1)}/${append}`;
|
|
243
|
+
outputPath = outputPath.slice(0, pos);
|
|
244
|
+
}
|
|
245
|
+
else if ('.' !== part) depth++;
|
|
248
246
|
return depth > 0 ? `${'../'.repeat(depth)}${append}` : enforceRelative ? `./${append}` : append;
|
|
249
247
|
}
|
|
250
248
|
const LibSvgrPatchPlugin_pluginName = 'LIB_SVGR_PATCH_PLUGIN';
|
|
@@ -339,19 +337,17 @@ const pluginLibAsset = ({ bundle })=>({
|
|
|
339
337
|
});
|
|
340
338
|
config.plugin(LibSvgrPatchPlugin.name).use(LibSvgrPatchPlugin, []);
|
|
341
339
|
}
|
|
342
|
-
if (isUsingSvgr) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
rule.issuer([]);
|
|
354
|
-
}
|
|
340
|
+
if (isUsingSvgr) if (bundle) {
|
|
341
|
+
const rule = config.module.rule(CHAIN_ID.RULE.SVG).oneOf(CHAIN_ID.ONE_OF.SVG_URL);
|
|
342
|
+
const originalGeneratorOptions = rule.get('generator');
|
|
343
|
+
const generatorOptions = isUserSetPublicPath ? originalGeneratorOptions : {
|
|
344
|
+
...originalGeneratorOptions,
|
|
345
|
+
importMode: 'preserve'
|
|
346
|
+
};
|
|
347
|
+
rule.generator(generatorOptions);
|
|
348
|
+
} else {
|
|
349
|
+
const rule = config.module.rule(CHAIN_ID.RULE.SVG).oneOf(CHAIN_ID.ONE_OF.SVG);
|
|
350
|
+
rule.issuer([]);
|
|
355
351
|
}
|
|
356
352
|
if (bundle) config.plugins.get(CHAIN_ID.PLUGIN.MINI_CSS_EXTRACT)?.tap((options)=>[
|
|
357
353
|
{
|
|
@@ -440,7 +436,7 @@ function parsePathQueryFragment(str) {
|
|
|
440
436
|
fragment: match?.[3] || ''
|
|
441
437
|
};
|
|
442
438
|
}
|
|
443
|
-
function
|
|
439
|
+
function cssConfig_isCssModulesFile(filepath, auto) {
|
|
444
440
|
const filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filepath);
|
|
445
441
|
if (true === auto) return CSS_MODULE_REG.test(filename);
|
|
446
442
|
if (auto instanceof RegExp) return auto.test(filepath);
|
|
@@ -453,7 +449,7 @@ function isCssModulesFile(filepath, auto) {
|
|
|
453
449
|
function isCssGlobalFile(filepath, auto) {
|
|
454
450
|
const isCss = isCssFile(filepath);
|
|
455
451
|
if (!isCss) return false;
|
|
456
|
-
const isCssModules =
|
|
452
|
+
const isCssModules = cssConfig_isCssModulesFile(filepath, auto);
|
|
457
453
|
return !isCssModules;
|
|
458
454
|
}
|
|
459
455
|
async function cssExternalHandler(request, callback, jsExtension, auto, styleRedirectPath, styleRedirectExtension, redirectPath, issuer) {
|
|
@@ -468,14 +464,14 @@ async function cssExternalHandler(request, callback, jsExtension, auto, styleRed
|
|
|
468
464
|
return false;
|
|
469
465
|
}
|
|
470
466
|
if (styleRedirectExtension) {
|
|
471
|
-
const isCssModulesRequest =
|
|
467
|
+
const isCssModulesRequest = cssConfig_isCssModulesFile(resolvedRequest, auto);
|
|
472
468
|
if (isCssModulesRequest) return callback(void 0, resolvedRequest.replace(/\.[^.]+$/, jsExtension));
|
|
473
469
|
return callback(void 0, resolvedRequest.replace(/\.[^.]+$/, '.css'));
|
|
474
470
|
}
|
|
475
471
|
return callback(void 0, resolvedRequest);
|
|
476
472
|
}
|
|
477
473
|
const cssConfig_PLUGIN_NAME = 'rsbuild:lib-css';
|
|
478
|
-
const pluginLibCss = (rootDir, banner, footer)=>({
|
|
474
|
+
const pluginLibCss = (rootDir, auto, banner, footer)=>({
|
|
479
475
|
name: cssConfig_PLUGIN_NAME,
|
|
480
476
|
setup (api) {
|
|
481
477
|
api.processAssets({
|
|
@@ -496,6 +492,7 @@ const pluginLibCss = (rootDir, banner, footer)=>({
|
|
|
496
492
|
isUsingCssExtract = true;
|
|
497
493
|
rule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader(cssConfig_require.resolve('./libCssExtractLoader.js')).options({
|
|
498
494
|
rootDir,
|
|
495
|
+
auto,
|
|
499
496
|
banner,
|
|
500
497
|
footer
|
|
501
498
|
});
|
|
@@ -509,11 +506,11 @@ const pluginLibCss = (rootDir, banner, footer)=>({
|
|
|
509
506
|
});
|
|
510
507
|
}
|
|
511
508
|
});
|
|
512
|
-
const composeCssConfig = (rootDir, bundle = true, banner, footer)=>{
|
|
509
|
+
const composeCssConfig = (rootDir, auto, bundle = true, banner, footer)=>{
|
|
513
510
|
if (bundle || null === rootDir) return {};
|
|
514
511
|
return {
|
|
515
512
|
plugins: [
|
|
516
|
-
pluginLibCss(rootDir, banner, footer)
|
|
513
|
+
pluginLibCss(rootDir, auto, banner, footer)
|
|
517
514
|
],
|
|
518
515
|
tools: {
|
|
519
516
|
cssLoader: {
|
|
@@ -634,7 +631,7 @@ const entryModuleLoaderRsbuildPlugin = ()=>({
|
|
|
634
631
|
name: EntryChunkPlugin_PLUGIN_NAME,
|
|
635
632
|
setup (api) {
|
|
636
633
|
api.modifyBundlerChain((config, { CHAIN_ID })=>{
|
|
637
|
-
config.module.rule(CHAIN_ID.RULE.JS).use(EntryChunkPlugin_LOADER_NAME).loader(EntryChunkPlugin_require.resolve('./entryModuleLoader.js'));
|
|
634
|
+
config.module.rule(`Rslib:${CHAIN_ID.RULE.JS}-entry-loader`).test(config.module.rule(CHAIN_ID.RULE.JS).get('test')).issuer(/^$/).use(EntryChunkPlugin_LOADER_NAME).loader(EntryChunkPlugin_require.resolve('./entryModuleLoader.js'));
|
|
638
635
|
});
|
|
639
636
|
}
|
|
640
637
|
});
|
|
@@ -1045,19 +1042,17 @@ async function find(filename, options) {
|
|
|
1045
1042
|
}
|
|
1046
1043
|
function findUp(dir, { resolve, reject, promise }, options) {
|
|
1047
1044
|
const { cache, root, configName } = options ?? {};
|
|
1048
|
-
if (cache) {
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
} else cache.setConfigPath(dir, promise, configName);
|
|
1060
|
-
}
|
|
1045
|
+
if (cache) if (cache.hasConfigPath(dir, configName)) {
|
|
1046
|
+
let cached;
|
|
1047
|
+
try {
|
|
1048
|
+
cached = cache.getConfigPath(dir, configName);
|
|
1049
|
+
} catch (e) {
|
|
1050
|
+
reject(e);
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
if (cached?.then) cached.then(resolve).catch(reject);
|
|
1054
|
+
else resolve(cached);
|
|
1055
|
+
} else cache.setConfigPath(dir, promise, configName);
|
|
1061
1056
|
const tsconfig = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dir, options?.configName ?? 'tsconfig.json');
|
|
1062
1057
|
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].stat(tsconfig, (err, stats)=>{
|
|
1063
1058
|
if (stats && (stats.isFile() || stats.isFIFO())) resolve(tsconfig);
|
|
@@ -1134,36 +1129,33 @@ function stripJsonComments(jsonString) {
|
|
|
1134
1129
|
const escaped = isEscaped(jsonString, index);
|
|
1135
1130
|
if (!escaped) isInsideString = !isInsideString;
|
|
1136
1131
|
}
|
|
1137
|
-
if (!isInsideString) {
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
} else if (isInsideComment || currentCharacter + nextCharacter !== '/*') {
|
|
1149
|
-
if (isInsideComment === multiComment && currentCharacter + nextCharacter === '*/') {
|
|
1150
|
-
index++;
|
|
1151
|
-
isInsideComment = false;
|
|
1152
|
-
result += strip(jsonString, offset, index + 1);
|
|
1153
|
-
offset = index + 1;
|
|
1154
|
-
}
|
|
1155
|
-
} else {
|
|
1156
|
-
result += jsonString.slice(offset, index);
|
|
1157
|
-
offset = index;
|
|
1158
|
-
isInsideComment = multiComment;
|
|
1159
|
-
index++;
|
|
1160
|
-
}
|
|
1161
|
-
} else {
|
|
1162
|
-
result += jsonString.slice(offset, index);
|
|
1163
|
-
offset = index;
|
|
1164
|
-
isInsideComment = singleComment;
|
|
1132
|
+
if (!isInsideString) if (isInsideComment || currentCharacter + nextCharacter !== '//') if (isInsideComment === singleComment && currentCharacter + nextCharacter === '\r\n') {
|
|
1133
|
+
index++;
|
|
1134
|
+
isInsideComment = false;
|
|
1135
|
+
result += strip(jsonString, offset, index);
|
|
1136
|
+
offset = index;
|
|
1137
|
+
} else if (isInsideComment === singleComment && '\n' === currentCharacter) {
|
|
1138
|
+
isInsideComment = false;
|
|
1139
|
+
result += strip(jsonString, offset, index);
|
|
1140
|
+
offset = index;
|
|
1141
|
+
} else if (isInsideComment || currentCharacter + nextCharacter !== '/*') {
|
|
1142
|
+
if (isInsideComment === multiComment && currentCharacter + nextCharacter === '*/') {
|
|
1165
1143
|
index++;
|
|
1144
|
+
isInsideComment = false;
|
|
1145
|
+
result += strip(jsonString, offset, index + 1);
|
|
1146
|
+
offset = index + 1;
|
|
1166
1147
|
}
|
|
1148
|
+
} else {
|
|
1149
|
+
result += jsonString.slice(offset, index);
|
|
1150
|
+
offset = index;
|
|
1151
|
+
isInsideComment = multiComment;
|
|
1152
|
+
index++;
|
|
1153
|
+
}
|
|
1154
|
+
else {
|
|
1155
|
+
result += jsonString.slice(offset, index);
|
|
1156
|
+
offset = index;
|
|
1157
|
+
isInsideComment = singleComment;
|
|
1158
|
+
index++;
|
|
1167
1159
|
}
|
|
1168
1160
|
}
|
|
1169
1161
|
return result + (isInsideComment ? strip(jsonString.slice(offset)) : jsonString.slice(offset));
|
|
@@ -1316,12 +1308,10 @@ function extendTSConfig(extending, extended) {
|
|
|
1316
1308
|
for (const key of Object.keys(extendedConfig).filter((key)=>EXTENDABLE_KEYS.includes(key)))if ('compilerOptions' === key) {
|
|
1317
1309
|
if (!extendingConfig.compilerOptions) extendingConfig.compilerOptions = {};
|
|
1318
1310
|
for (const option of Object.keys(extendedConfig.compilerOptions))if (!Object.prototype.hasOwnProperty.call(extendingConfig.compilerOptions, option)) extendingConfig.compilerOptions[option] = rebaseRelative(option, extendedConfig.compilerOptions[option], relativePath);
|
|
1319
|
-
} else if (void 0 === extendingConfig[key]) {
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
} else extendingConfig[key] = rebaseRelative(key, extendedConfig[key], relativePath);
|
|
1324
|
-
}
|
|
1311
|
+
} else if (void 0 === extendingConfig[key]) if ('watchOptions' === key) {
|
|
1312
|
+
extendingConfig.watchOptions = {};
|
|
1313
|
+
for (const option of Object.keys(extendedConfig.watchOptions))extendingConfig.watchOptions[option] = rebaseRelative(option, extendedConfig.watchOptions[option], relativePath);
|
|
1314
|
+
} else extendingConfig[key] = rebaseRelative(key, extendedConfig[key], relativePath);
|
|
1325
1315
|
}
|
|
1326
1316
|
const REBASE_KEYS = [
|
|
1327
1317
|
'files',
|
|
@@ -1965,7 +1955,6 @@ const traverseEntryQuery = (entry, callback)=>{
|
|
|
1965
1955
|
}
|
|
1966
1956
|
return newEntry;
|
|
1967
1957
|
};
|
|
1968
|
-
const appendEntryQuery = (entries)=>traverseEntryQuery(entries, (item)=>`${item}?${RSLIB_ENTRY_QUERY}`);
|
|
1969
1958
|
const resolveEntryPath = (entries, root)=>traverseEntryQuery(entries, (item)=>__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(root, item));
|
|
1970
1959
|
const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOutBase)=>{
|
|
1971
1960
|
let entries = rawEntry;
|
|
@@ -1996,7 +1985,7 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOu
|
|
|
1996
1985
|
return {
|
|
1997
1986
|
entryConfig: {
|
|
1998
1987
|
source: {
|
|
1999
|
-
entry:
|
|
1988
|
+
entry: resolveEntryPath(entries, root)
|
|
2000
1989
|
}
|
|
2001
1990
|
},
|
|
2002
1991
|
outBase: null
|
|
@@ -2052,7 +2041,7 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOu
|
|
|
2052
2041
|
rspack: {
|
|
2053
2042
|
entry: async ()=>{
|
|
2054
2043
|
const { resolvedEntries } = await scanGlobEntries(false);
|
|
2055
|
-
return
|
|
2044
|
+
return resolvedEntries;
|
|
2056
2045
|
}
|
|
2057
2046
|
}
|
|
2058
2047
|
}
|
|
@@ -2250,7 +2239,7 @@ async function composeLibRsbuildConfig(config, root, sharedPlugins) {
|
|
|
2250
2239
|
pkgJson,
|
|
2251
2240
|
userExternals: config.output?.externals
|
|
2252
2241
|
});
|
|
2253
|
-
const cssConfig = composeCssConfig(outBase, config.bundle, banner?.css, footer?.css);
|
|
2242
|
+
const cssConfig = composeCssConfig(outBase, cssModulesAuto, config.bundle, banner?.css, footer?.css);
|
|
2254
2243
|
const assetConfig = composeAssetConfig(bundle, format);
|
|
2255
2244
|
const entryChunkConfig = composeEntryChunkConfig({
|
|
2256
2245
|
enabledImportMetaUrlShim: enabledShims.cjs['import.meta.url'],
|
|
@@ -2477,7 +2466,7 @@ const repeatableOption = (value, previous)=>(previous ?? []).concat([
|
|
|
2477
2466
|
value
|
|
2478
2467
|
]);
|
|
2479
2468
|
function runCli() {
|
|
2480
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.6.
|
|
2469
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.6.2");
|
|
2481
2470
|
const buildCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('build');
|
|
2482
2471
|
const inspectCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('inspect');
|
|
2483
2472
|
const mfDevCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('mf-dev');
|
|
@@ -2538,6 +2527,7 @@ function runCli() {
|
|
|
2538
2527
|
});
|
|
2539
2528
|
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.parse();
|
|
2540
2529
|
}
|
|
2541
|
-
const src_rslib_entry_version = "0.6.
|
|
2530
|
+
const src_rslib_entry_version = "0.6.2";
|
|
2542
2531
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger;
|
|
2543
|
-
|
|
2532
|
+
var __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack;
|
|
2533
|
+
export { build, defineConfig, inspect, loadConfig, prepareCli, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ as rsbuild, runCli, startMFDevServer, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, src_rslib_entry_version as version, __webpack_exports__logger as logger, __webpack_exports__rspack as rspack };
|
|
@@ -1,17 +1,70 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
|
|
3
|
+
import "@rsbuild/core";
|
|
4
|
+
const DTS_EXTENSIONS = [
|
|
5
|
+
'd.ts',
|
|
6
|
+
'd.mts',
|
|
7
|
+
'd.cts'
|
|
8
|
+
];
|
|
9
|
+
const JS_EXTENSIONS = [
|
|
10
|
+
'js',
|
|
11
|
+
'mjs',
|
|
12
|
+
'jsx',
|
|
13
|
+
'(?<!\\.d\\.)ts',
|
|
14
|
+
'(?<!\\.d\\.)mts',
|
|
15
|
+
'(?<!\\.d\\.)cts',
|
|
16
|
+
'tsx',
|
|
17
|
+
'cjs',
|
|
18
|
+
'cjsx',
|
|
19
|
+
'mjsx',
|
|
20
|
+
'mtsx',
|
|
21
|
+
'ctsx'
|
|
22
|
+
];
|
|
23
|
+
const CSS_EXTENSIONS = [
|
|
24
|
+
'css',
|
|
25
|
+
'sass',
|
|
26
|
+
'scss',
|
|
27
|
+
'less',
|
|
28
|
+
'styl',
|
|
29
|
+
'stylus'
|
|
30
|
+
];
|
|
31
|
+
new RegExp(`\\.(${JS_EXTENSIONS.join('|')})$`);
|
|
32
|
+
new RegExp(`\\.(${CSS_EXTENSIONS.join('|')})$`);
|
|
33
|
+
new RegExp(`\\.(${DTS_EXTENSIONS.join('|')})$`);
|
|
34
|
+
(0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url);
|
|
35
|
+
const CSS_MODULE_REG = /\.module\.\w+$/i;
|
|
36
|
+
const PATH_QUERY_FRAGMENT_REGEXP = /^((?:\u200b.|[^?#\u200b])*)(\?(?:\u200b.|[^#\u200b])*)?(#.*)?$/;
|
|
37
|
+
function parsePathQueryFragment(str) {
|
|
38
|
+
const match = PATH_QUERY_FRAGMENT_REGEXP.exec(str);
|
|
39
|
+
return {
|
|
40
|
+
path: match?.[1]?.replace(/\u200b(.)/g, '$1') || '',
|
|
41
|
+
query: match?.[2] ? match[2].replace(/\u200b(.)/g, '$1') : '',
|
|
42
|
+
fragment: match?.[3] || ''
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function cssConfig_isCssModulesFile(filepath, auto) {
|
|
46
|
+
const filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filepath);
|
|
47
|
+
if (true === auto) return CSS_MODULE_REG.test(filename);
|
|
48
|
+
if (auto instanceof RegExp) return auto.test(filepath);
|
|
49
|
+
if ('function' == typeof auto) {
|
|
50
|
+
const { path, query, fragment } = parsePathQueryFragment(filepath);
|
|
51
|
+
return auto(path, query, fragment);
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
const libCssExtractLoader_rslib_entry_BASE_URI = 'webpack://';
|
|
56
|
+
const libCssExtractLoader_rslib_entry_MODULE_TYPE = 'css/mini-extract';
|
|
57
|
+
const libCssExtractLoader_rslib_entry_AUTO_PUBLIC_PATH = '__mini_css_extract_plugin_public_path_auto__';
|
|
58
|
+
const libCssExtractLoader_rslib_entry_ABSOLUTE_PUBLIC_PATH = `${libCssExtractLoader_rslib_entry_BASE_URI}/mini-css-extract-plugin/`;
|
|
59
|
+
const libCssExtractLoader_rslib_entry_SINGLE_DOT_PATH_SEGMENT = '__mini_css_extract_plugin_single_dot_path_segment__';
|
|
60
|
+
const libCssExtractLoader_rslib_entry_LOADER_NAME = 'LIB_CSS_EXTRACT_LOADER';
|
|
61
|
+
function libCssExtractLoader_rslib_entry_stringifyLocal(value) {
|
|
9
62
|
return 'function' == typeof value ? value.toString() : JSON.stringify(value);
|
|
10
63
|
}
|
|
11
64
|
const libCssExtractLoader_rslib_entry_loader = function(content) {
|
|
12
65
|
if (this._compiler?.options?.experiments?.css && this._module && ('css' === this._module.type || 'css/auto' === this._module.type || 'css/global' === this._module.type || 'css/module' === this._module.type)) return content;
|
|
13
66
|
};
|
|
14
|
-
const
|
|
67
|
+
const libCssExtractLoader_rslib_entry_pitch = function(request, _, _data) {
|
|
15
68
|
if (this._compiler?.options?.experiments?.css && this._module && ('css' === this._module.type || 'css/auto' === this._module.type || 'css/global' === this._module.type || 'css/module' === this._module.type)) {
|
|
16
69
|
const e = new Error("use type 'css' and `CssExtractRspackPlugin` together, please set `experiments.css` to `false` or set `{ type: \"javascript/auto\" }` for rules with `CssExtractRspackPlugin` in your rspack config (now `CssExtractRspackPlugin` does nothing).");
|
|
17
70
|
e.stack = void 0;
|
|
@@ -23,16 +76,17 @@ const pitch = function(request, _, _data) {
|
|
|
23
76
|
const callback = this.async();
|
|
24
77
|
const filepath = this.resourcePath;
|
|
25
78
|
const rootDir = options.rootDir ?? this.rootContext;
|
|
79
|
+
const auto = options.auto;
|
|
26
80
|
const banner = options.banner;
|
|
27
81
|
const footer = options.footer;
|
|
28
82
|
let { publicPath } = this._compilation.outputOptions;
|
|
29
83
|
if ('string' == typeof options.publicPath) publicPath = options.publicPath;
|
|
30
84
|
else if ('function' == typeof options.publicPath) publicPath = options.publicPath(this.resourcePath, this.rootContext);
|
|
31
|
-
if ('auto' === publicPath) publicPath =
|
|
85
|
+
if ('auto' === publicPath) publicPath = libCssExtractLoader_rslib_entry_AUTO_PUBLIC_PATH;
|
|
32
86
|
let publicPathForExtract;
|
|
33
87
|
if ('string' == typeof publicPath) {
|
|
34
88
|
const isAbsolutePublicPath = /^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(publicPath);
|
|
35
|
-
publicPathForExtract = isAbsolutePublicPath ? publicPath : `${
|
|
89
|
+
publicPathForExtract = isAbsolutePublicPath ? publicPath : `${libCssExtractLoader_rslib_entry_ABSOLUTE_PUBLIC_PATH}${publicPath.replace(/\./g, libCssExtractLoader_rslib_entry_SINGLE_DOT_PATH_SEGMENT)}`;
|
|
36
90
|
} else publicPathForExtract = publicPath;
|
|
37
91
|
const handleExports = (originalExports)=>{
|
|
38
92
|
let locals;
|
|
@@ -85,7 +139,7 @@ const pitch = function(request, _, _data) {
|
|
|
85
139
|
];
|
|
86
140
|
}
|
|
87
141
|
}());
|
|
88
|
-
const localsString = identifiers.map(([id, key])=>`\nvar ${id} = ${
|
|
142
|
+
const localsString = identifiers.map(([id, key])=>`\nvar ${id} = ${libCssExtractLoader_rslib_entry_stringifyLocal(locals[key])};`).join('');
|
|
89
143
|
const exportsString = `export { ${identifiers.map(([id, key])=>`${id} as ${JSON.stringify(key)}`).join(', ')} }`;
|
|
90
144
|
const defaultExport = void 0 !== options.defaultExport ? options.defaultExport : false;
|
|
91
145
|
return defaultExport ? `${localsString}\n${exportsString}\nexport default { ${identifiers.map(([id, key])=>`${JSON.stringify(key)}: ${id}`).join(', ')} }\n` : `${localsString}\n${exportsString}\n`;
|
|
@@ -95,7 +149,7 @@ const pitch = function(request, _, _data) {
|
|
|
95
149
|
if (esModule) return '\nexport {};';
|
|
96
150
|
return '';
|
|
97
151
|
}();
|
|
98
|
-
let resultSource = `// extracted by ${
|
|
152
|
+
let resultSource = `// extracted by ${libCssExtractLoader_rslib_entry_LOADER_NAME}`;
|
|
99
153
|
let importCssFiles = '';
|
|
100
154
|
function getRelativePath(from, to) {
|
|
101
155
|
let relativePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].relative(from, to);
|
|
@@ -107,7 +161,7 @@ const pitch = function(request, _, _data) {
|
|
|
107
161
|
let distFilepath = getRelativePath(rootDir, filepath);
|
|
108
162
|
const ext = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.extname)(distFilepath);
|
|
109
163
|
if ('css' !== ext) distFilepath = distFilepath.replace(ext, '.css');
|
|
110
|
-
distFilepath = distFilepath.replace(/\.module\.css/, '_module.css');
|
|
164
|
+
if (cssConfig_isCssModulesFile(filepath, auto)) distFilepath = distFilepath.replace(/\.module\.css/, '_module.css');
|
|
111
165
|
const cssFilename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(distFilepath);
|
|
112
166
|
if (content.trim()) {
|
|
113
167
|
m.get(distFilepath) ? m.set(distFilepath, `${m.get(distFilepath) + content}\n`) : m.set(distFilepath, `${content}\n`);
|
|
@@ -133,7 +187,7 @@ const pitch = function(request, _, _data) {
|
|
|
133
187
|
this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`, {
|
|
134
188
|
layer: options.layer,
|
|
135
189
|
publicPath: publicPathForExtract,
|
|
136
|
-
baseUri: `${
|
|
190
|
+
baseUri: `${libCssExtractLoader_rslib_entry_BASE_URI}/`
|
|
137
191
|
}, (error, exports)=>{
|
|
138
192
|
if (error) {
|
|
139
193
|
callback(error);
|
|
@@ -143,4 +197,4 @@ const pitch = function(request, _, _data) {
|
|
|
143
197
|
});
|
|
144
198
|
};
|
|
145
199
|
const libCssExtractLoader_rslib_entry_ = libCssExtractLoader_rslib_entry_loader;
|
|
146
|
-
export { ABSOLUTE_PUBLIC_PATH, AUTO_PUBLIC_PATH, BASE_URI, MODULE_TYPE, SINGLE_DOT_PATH_SEGMENT, libCssExtractLoader_rslib_entry_ as default, pitch };
|
|
200
|
+
export { libCssExtractLoader_rslib_entry_ABSOLUTE_PUBLIC_PATH as ABSOLUTE_PUBLIC_PATH, libCssExtractLoader_rslib_entry_AUTO_PUBLIC_PATH as AUTO_PUBLIC_PATH, libCssExtractLoader_rslib_entry_BASE_URI as BASE_URI, libCssExtractLoader_rslib_entry_MODULE_TYPE as MODULE_TYPE, libCssExtractLoader_rslib_entry_SINGLE_DOT_PATH_SEGMENT as SINGLE_DOT_PATH_SEGMENT, libCssExtractLoader_rslib_entry_ as default, libCssExtractLoader_rslib_entry_pitch as pitch };
|
package/dist-types/config.d.ts
CHANGED
|
@@ -28,7 +28,6 @@ export declare function composeBannerFooterConfig(banner: BannerAndFooter, foote
|
|
|
28
28
|
export declare function composeDecoratorsConfig(compilerOptions?: Record<string, any>, version?: NonNullable<NonNullable<EnvironmentConfig['source']>['decorators']>['version']): EnvironmentConfig;
|
|
29
29
|
export declare function createConstantRsbuildConfig(): Promise<EnvironmentConfig>;
|
|
30
30
|
export declare const composeModuleImportWarn: (request: string, issuer: string) => string;
|
|
31
|
-
export declare const appendEntryQuery: (entries: RsbuildConfigEntry) => RsbuildEntry;
|
|
32
31
|
export declare const resolveEntryPath: (entries: RsbuildConfigEntry, root: string) => RsbuildEntry;
|
|
33
32
|
export declare function composeCreateRsbuildConfig(rslibConfig: RslibConfig): Promise<RsbuildConfigWithLibInfo[]>;
|
|
34
33
|
export declare function composeRsbuildEnvironments(rslibConfig: RslibConfig): Promise<{
|
package/dist-types/constant.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export declare const DEFAULT_CONFIG_NAME = "rslib.config";
|
|
2
2
|
export declare const DEFAULT_CONFIG_EXTENSIONS: readonly [".js", ".ts", ".mjs", ".mts", ".cjs", ".cts"];
|
|
3
3
|
export declare const SWC_HELPERS = "@swc/helpers";
|
|
4
|
-
export declare const RSLIB_ENTRY_QUERY = "__rslib_entry__";
|
|
5
4
|
export declare const SHEBANG_PREFIX = "#!";
|
|
6
5
|
export declare const SHEBANG_REGEX: RegExp;
|
|
7
6
|
export declare const REACT_DIRECTIVE_REGEX: RegExp;
|
|
@@ -13,5 +13,5 @@ export declare function isCssModulesFile(filepath: string, auto: CssLoaderOption
|
|
|
13
13
|
export declare function isCssGlobalFile(filepath: string, auto: CssLoaderOptionsAuto): boolean;
|
|
14
14
|
type ExternalCallback = (arg0?: undefined, arg1?: string) => void;
|
|
15
15
|
export declare function cssExternalHandler(request: string, callback: ExternalCallback, jsExtension: string, auto: CssLoaderOptionsAuto, styleRedirectPath: boolean, styleRedirectExtension: boolean, redirectPath: (request: string) => Promise<string | undefined>, issuer: string): Promise<false | void>;
|
|
16
|
-
export declare const composeCssConfig: (rootDir: string | null, bundle?: boolean, banner?: string, footer?: string) => EnvironmentConfig;
|
|
16
|
+
export declare const composeCssConfig: (rootDir: string | null, auto: CssLoaderOptionsAuto, bundle?: boolean, banner?: string, footer?: string) => EnvironmentConfig;
|
|
17
17
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Rspack } from '@rsbuild/core';
|
|
2
|
+
import { type CssLoaderOptionsAuto } from './cssConfig';
|
|
2
3
|
export declare const BASE_URI = "webpack://";
|
|
3
4
|
export declare const MODULE_TYPE = "css/mini-extract";
|
|
4
5
|
export declare const AUTO_PUBLIC_PATH = "__mini_css_extract_plugin_public_path_auto__";
|
|
@@ -11,6 +12,7 @@ export interface CssExtractRspackLoaderOptions {
|
|
|
11
12
|
layer?: string;
|
|
12
13
|
defaultExport?: boolean;
|
|
13
14
|
rootDir?: string;
|
|
15
|
+
auto?: CssLoaderOptionsAuto;
|
|
14
16
|
banner?: string;
|
|
15
17
|
footer?: string;
|
|
16
18
|
}
|
package/dist-types/index.d.ts
CHANGED
|
@@ -7,3 +7,5 @@ export { defineConfig, loadConfig, composeCreateRsbuildConfig as unstable_compos
|
|
|
7
7
|
export { logger } from './utils/logger';
|
|
8
8
|
export type * from './types';
|
|
9
9
|
export declare const version: string;
|
|
10
|
+
export { rspack, type Rspack } from '@rsbuild/core';
|
|
11
|
+
export * as rsbuild from '@rsbuild/core';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "The Rsbuild-based library development tool.",
|
|
5
5
|
"homepage": "https://lib.rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -36,24 +36,24 @@
|
|
|
36
36
|
"types.d.ts"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@rsbuild/core": "1.3.
|
|
39
|
+
"@rsbuild/core": "1.3.5",
|
|
40
40
|
"tinyglobby": "^0.2.12",
|
|
41
|
-
"rsbuild-plugin-dts": "0.6.
|
|
41
|
+
"rsbuild-plugin-dts": "0.6.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@module-federation/rsbuild-plugin": "^0.11.
|
|
44
|
+
"@module-federation/rsbuild-plugin": "^0.11.4",
|
|
45
45
|
"@types/fs-extra": "^11.0.4",
|
|
46
46
|
"chokidar": "^4.0.3",
|
|
47
47
|
"commander": "^13.1.0",
|
|
48
48
|
"fs-extra": "^11.3.0",
|
|
49
49
|
"memfs": "^4.17.0",
|
|
50
50
|
"picocolors": "1.1.1",
|
|
51
|
-
"prebundle": "1.
|
|
51
|
+
"prebundle": "1.3.3",
|
|
52
52
|
"rsbuild-plugin-publint": "^0.3.0",
|
|
53
|
-
"rslib": "npm:@rslib/core@0.
|
|
53
|
+
"rslib": "npm:@rslib/core@0.6.1",
|
|
54
54
|
"rslog": "^1.2.3",
|
|
55
55
|
"tsconfck": "3.1.5",
|
|
56
|
-
"typescript": "^5.8.
|
|
56
|
+
"typescript": "^5.8.3",
|
|
57
57
|
"@rslib/tsconfig": "0.0.1"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|