@rslib/core 0.6.1 → 0.6.3

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.
@@ -342,4 +342,5 @@ declare const _default: {
342
342
  FSWatcher: typeof FSWatcher;
343
343
  };
344
344
 
345
- export { type ChokidarOptions, type EmitArgs, type EmitArgsWithName, type EmitErrorArgs, type FSWInstanceOptions, FSWatcher, type FSWatcherEventMap, type FSWatcherKnownEventMap, type MatchFunction, type Matcher, type MatcherObject, type ThrottleType, type Throttler, WatchHelper, _default as default, watch };
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 { type AddHelpTextContext, type AddHelpTextPosition, Argument, Command, type CommandOptions, CommanderError, type ErrorOptions, type ExecutableCommandOptions, Help, type HelpConfiguration, type HelpContext, type HookEvent, InvalidArgumentError, InvalidArgumentError as InvalidOptionArgumentError, Option, type OptionValueSource, type OptionValues, type OutputConfiguration, type ParseOptions, type ParseOptionsResult, createArgument, createCommand, createOption, program };
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 { type LogFunction, type LogLevel, type LogMessage, type LogType, type Logger, type Options, createLogger, logger };
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 = [
@@ -42,15 +41,13 @@ function splitFromFirstLine(text) {
42
41
  text.slice(match.index)
43
42
  ];
44
43
  }
45
- const entryModuleLoader_rslib_entry_loader = function(source) {
44
+ const entryModuleLoader_loader = function(source) {
46
45
  let result = source;
47
- if (this.resourceQuery === `?${RSLIB_ENTRY_QUERY}`) {
48
- const [firstLine1, rest] = splitFromFirstLine(result);
49
- if (SHEBANG_REGEX.test(firstLine1)) result = rest;
50
- const [firstLine2, rest2] = splitFromFirstLine(result);
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
- const entryModuleLoader_rslib_entry_ = entryModuleLoader_rslib_entry_loader;
56
- export { entryModuleLoader_rslib_entry_ as default };
52
+ const entryModuleLoader = entryModuleLoader_loader;
53
+ export { entryModuleLoader as default };
package/dist/index.js CHANGED
@@ -88,10 +88,7 @@ function getAbsolutePath(base, filepath) {
88
88
  }
89
89
  const readPackageJson = (rootPath)=>{
90
90
  const pkgJsonPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(rootPath, './package.json');
91
- if (!__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(pkgJsonPath)) {
92
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`The \`package.json\` file does not exist in the ${rootPath} directory`);
93
- return;
94
- }
91
+ if (!__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(pkgJsonPath)) return void __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.warn(`The \`package.json\` file does not exist in the ${rootPath} directory`);
95
92
  try {
96
93
  return JSON.parse(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(pkgJsonPath, 'utf8'));
97
94
  } catch (err) {
@@ -184,7 +181,7 @@ function prepareCli() {
184
181
  initNodeEnv();
185
182
  const { npm_execpath } = process.env;
186
183
  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.1\n`);
184
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rslib v0.6.3\n`);
188
185
  }
189
186
  const DEFAULT_CONFIG_NAME = 'rslib.config';
190
187
  const DEFAULT_CONFIG_EXTENSIONS = [
@@ -196,7 +193,6 @@ const DEFAULT_CONFIG_EXTENSIONS = [
196
193
  '.cts'
197
194
  ];
198
195
  const SWC_HELPERS = '@swc/helpers';
199
- const RSLIB_ENTRY_QUERY = '__rslib_entry__';
200
196
  const SHEBANG_PREFIX = '#!';
201
197
  const SHEBANG_REGEX = /#!.*[\s\n\r]*$/;
202
198
  const REACT_DIRECTIVE_REGEX = /^['"]use (client|server)['"](;?)[\s\n\r]*$/;
@@ -437,7 +433,7 @@ function parsePathQueryFragment(str) {
437
433
  fragment: match?.[3] || ''
438
434
  };
439
435
  }
440
- function isCssModulesFile(filepath, auto) {
436
+ function cssConfig_isCssModulesFile(filepath, auto) {
441
437
  const filename = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].basename(filepath);
442
438
  if (true === auto) return CSS_MODULE_REG.test(filename);
443
439
  if (auto instanceof RegExp) return auto.test(filepath);
@@ -450,7 +446,7 @@ function isCssModulesFile(filepath, auto) {
450
446
  function isCssGlobalFile(filepath, auto) {
451
447
  const isCss = isCssFile(filepath);
452
448
  if (!isCss) return false;
453
- const isCssModules = isCssModulesFile(filepath, auto);
449
+ const isCssModules = cssConfig_isCssModulesFile(filepath, auto);
454
450
  return !isCssModules;
455
451
  }
456
452
  async function cssExternalHandler(request, callback, jsExtension, auto, styleRedirectPath, styleRedirectExtension, redirectPath, issuer) {
@@ -465,14 +461,14 @@ async function cssExternalHandler(request, callback, jsExtension, auto, styleRed
465
461
  return false;
466
462
  }
467
463
  if (styleRedirectExtension) {
468
- const isCssModulesRequest = isCssModulesFile(resolvedRequest, auto);
464
+ const isCssModulesRequest = cssConfig_isCssModulesFile(resolvedRequest, auto);
469
465
  if (isCssModulesRequest) return callback(void 0, resolvedRequest.replace(/\.[^.]+$/, jsExtension));
470
466
  return callback(void 0, resolvedRequest.replace(/\.[^.]+$/, '.css'));
471
467
  }
472
468
  return callback(void 0, resolvedRequest);
473
469
  }
474
470
  const cssConfig_PLUGIN_NAME = 'rsbuild:lib-css';
475
- const pluginLibCss = (rootDir, banner, footer)=>({
471
+ const pluginLibCss = (rootDir, auto, banner, footer)=>({
476
472
  name: cssConfig_PLUGIN_NAME,
477
473
  setup (api) {
478
474
  api.processAssets({
@@ -493,6 +489,7 @@ const pluginLibCss = (rootDir, banner, footer)=>({
493
489
  isUsingCssExtract = true;
494
490
  rule.use(CHAIN_ID.USE.MINI_CSS_EXTRACT).loader(cssConfig_require.resolve('./libCssExtractLoader.js')).options({
495
491
  rootDir,
492
+ auto,
496
493
  banner,
497
494
  footer
498
495
  });
@@ -506,11 +503,11 @@ const pluginLibCss = (rootDir, banner, footer)=>({
506
503
  });
507
504
  }
508
505
  });
509
- const composeCssConfig = (rootDir, bundle = true, banner, footer)=>{
506
+ const composeCssConfig = (rootDir, auto, bundle = true, banner, footer)=>{
510
507
  if (bundle || null === rootDir) return {};
511
508
  return {
512
509
  plugins: [
513
- pluginLibCss(rootDir, banner, footer)
510
+ pluginLibCss(rootDir, auto, banner, footer)
514
511
  ],
515
512
  tools: {
516
513
  cssLoader: {
@@ -631,7 +628,7 @@ const entryModuleLoaderRsbuildPlugin = ()=>({
631
628
  name: EntryChunkPlugin_PLUGIN_NAME,
632
629
  setup (api) {
633
630
  api.modifyBundlerChain((config, { CHAIN_ID })=>{
634
- config.module.rule(CHAIN_ID.RULE.JS).use(EntryChunkPlugin_LOADER_NAME).loader(EntryChunkPlugin_require.resolve('./entryModuleLoader.js'));
631
+ 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'));
635
632
  });
636
633
  }
637
634
  });
@@ -1421,10 +1418,7 @@ const composeExternalsWarnConfig = (format, ...externalsArray)=>{
1421
1418
  else externals.push(e);
1422
1419
  const matchUserExternals = (externals, request, callback)=>{
1423
1420
  if ('string' == typeof externals) {
1424
- if (handleMatchedExternal(externals, request)) {
1425
- callback(true, true);
1426
- return;
1427
- }
1421
+ if (handleMatchedExternal(externals, request)) return void callback(true, true);
1428
1422
  }
1429
1423
  if (Array.isArray(externals)) {
1430
1424
  let i = 0;
@@ -1451,16 +1445,10 @@ const composeExternalsWarnConfig = (format, ...externalsArray)=>{
1451
1445
  return;
1452
1446
  }
1453
1447
  if (externals instanceof RegExp) {
1454
- if (externals.test(request)) {
1455
- callback(true, true);
1456
- return;
1457
- }
1448
+ if (externals.test(request)) return void callback(true, true);
1458
1449
  } else if ('function' == typeof externals) ;
1459
1450
  else if ('object' == typeof externals) {
1460
- if (Object.prototype.hasOwnProperty.call(externals, request)) {
1461
- handleMatchedExternal(externals[request], request) ? callback(true, true) : callback(true);
1462
- return;
1463
- }
1451
+ if (Object.prototype.hasOwnProperty.call(externals, request)) return void (handleMatchedExternal(externals[request], request) ? callback(true, true) : callback(true));
1464
1452
  }
1465
1453
  callback(false);
1466
1454
  };
@@ -1903,18 +1891,19 @@ const composeAutoExtensionConfig = (config, autoExtension, pkgJson)=>{
1903
1891
  return filenameHash ? '.[contenthash:8]' : '';
1904
1892
  };
1905
1893
  const hash = getHash();
1906
- const updatedConfig = {
1894
+ const defaultJsFilename = `[name]${hash}${jsExtension}`;
1895
+ const userJsFilename = config.output?.filename?.js;
1896
+ const finalJsExtension = 'string' == typeof userJsFilename && userJsFilename ? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.extname)(userJsFilename) : jsExtension;
1897
+ const finalConfig = userJsFilename ? {} : {
1907
1898
  output: {
1908
1899
  filename: {
1909
- js: `[name]${hash}${jsExtension}`,
1910
- ...config.output?.filename
1900
+ js: defaultJsFilename
1911
1901
  }
1912
1902
  }
1913
1903
  };
1914
- const updatedJsExtension = 'string' == typeof updatedConfig.output?.filename?.js && updatedConfig.output?.filename?.js ? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.extname)(updatedConfig.output.filename.js) : jsExtension;
1915
1904
  return {
1916
- config: updatedConfig,
1917
- jsExtension: updatedJsExtension,
1905
+ config: finalConfig,
1906
+ jsExtension: finalJsExtension,
1918
1907
  dtsExtension
1919
1908
  };
1920
1909
  };
@@ -1955,7 +1944,6 @@ const traverseEntryQuery = (entry, callback)=>{
1955
1944
  }
1956
1945
  return newEntry;
1957
1946
  };
1958
- const appendEntryQuery = (entries)=>traverseEntryQuery(entries, (item)=>`${item}?${RSLIB_ENTRY_QUERY}`);
1959
1947
  const resolveEntryPath = (entries, root)=>traverseEntryQuery(entries, (item)=>__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(root, item));
1960
1948
  const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOutBase)=>{
1961
1949
  let entries = rawEntry;
@@ -1986,7 +1974,7 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOu
1986
1974
  return {
1987
1975
  entryConfig: {
1988
1976
  source: {
1989
- entry: appendEntryQuery(resolveEntryPath(entries, root))
1977
+ entry: resolveEntryPath(entries, root)
1990
1978
  }
1991
1979
  },
1992
1980
  outBase: null
@@ -2042,7 +2030,7 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOu
2042
2030
  rspack: {
2043
2031
  entry: async ()=>{
2044
2032
  const { resolvedEntries } = await scanGlobEntries(false);
2045
- return appendEntryQuery(resolvedEntries);
2033
+ return resolvedEntries;
2046
2034
  }
2047
2035
  }
2048
2036
  }
@@ -2240,7 +2228,7 @@ async function composeLibRsbuildConfig(config, root, sharedPlugins) {
2240
2228
  pkgJson,
2241
2229
  userExternals: config.output?.externals
2242
2230
  });
2243
- const cssConfig = composeCssConfig(outBase, config.bundle, banner?.css, footer?.css);
2231
+ const cssConfig = composeCssConfig(outBase, cssModulesAuto, config.bundle, banner?.css, footer?.css);
2244
2232
  const assetConfig = composeAssetConfig(bundle, format);
2245
2233
  const entryChunkConfig = composeEntryChunkConfig({
2246
2234
  enabledImportMetaUrlShim: enabledShims.cjs['import.meta.url'],
@@ -2467,7 +2455,7 @@ const repeatableOption = (value, previous)=>(previous ?? []).concat([
2467
2455
  value
2468
2456
  ]);
2469
2457
  function runCli() {
2470
- __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.6.1");
2458
+ __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.6.3");
2471
2459
  const buildCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('build');
2472
2460
  const inspectCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('inspect');
2473
2461
  const mfDevCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('mf-dev');
@@ -2528,7 +2516,7 @@ function runCli() {
2528
2516
  });
2529
2517
  __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.parse();
2530
2518
  }
2531
- const src_rslib_entry_version = "0.6.1";
2519
+ const src_version = "0.6.3";
2532
2520
  var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger;
2533
2521
  var __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack;
2534
- 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 };
2522
+ export { build, defineConfig, inspect, loadConfig, prepareCli, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ as rsbuild, runCli, startMFDevServer, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, src_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
- const BASE_URI = 'webpack://';
3
- const MODULE_TYPE = 'css/mini-extract';
4
- const AUTO_PUBLIC_PATH = '__mini_css_extract_plugin_public_path_auto__';
5
- const ABSOLUTE_PUBLIC_PATH = `${BASE_URI}/mini-css-extract-plugin/`;
6
- const SINGLE_DOT_PATH_SEGMENT = '__mini_css_extract_plugin_single_dot_path_segment__';
7
- const LOADER_NAME = 'LIB_CSS_EXTRACT_LOADER';
8
- function stringifyLocal(value) {
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 css_libCssExtractLoader_BASE_URI = 'webpack://';
56
+ const libCssExtractLoader_MODULE_TYPE = 'css/mini-extract';
57
+ const css_libCssExtractLoader_AUTO_PUBLIC_PATH = '__mini_css_extract_plugin_public_path_auto__';
58
+ const css_libCssExtractLoader_ABSOLUTE_PUBLIC_PATH = `${css_libCssExtractLoader_BASE_URI}/mini-css-extract-plugin/`;
59
+ const css_libCssExtractLoader_SINGLE_DOT_PATH_SEGMENT = '__mini_css_extract_plugin_single_dot_path_segment__';
60
+ const libCssExtractLoader_LOADER_NAME = 'LIB_CSS_EXTRACT_LOADER';
61
+ function libCssExtractLoader_stringifyLocal(value) {
9
62
  return 'function' == typeof value ? value.toString() : JSON.stringify(value);
10
63
  }
11
- const libCssExtractLoader_rslib_entry_loader = function(content) {
64
+ const css_libCssExtractLoader_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 pitch = function(request, _, _data) {
67
+ const libCssExtractLoader_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 = AUTO_PUBLIC_PATH;
85
+ if ('auto' === publicPath) publicPath = css_libCssExtractLoader_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 : `${ABSOLUTE_PUBLIC_PATH}${publicPath.replace(/\./g, SINGLE_DOT_PATH_SEGMENT)}`;
89
+ publicPathForExtract = isAbsolutePublicPath ? publicPath : `${css_libCssExtractLoader_ABSOLUTE_PUBLIC_PATH}${publicPath.replace(/\./g, css_libCssExtractLoader_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} = ${stringifyLocal(locals[key])};`).join('');
142
+ const localsString = identifiers.map(([id, key])=>`\nvar ${id} = ${libCssExtractLoader_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 ${LOADER_NAME}`;
152
+ let resultSource = `// extracted by ${libCssExtractLoader_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,14 +187,11 @@ 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: `${BASE_URI}/`
190
+ baseUri: `${css_libCssExtractLoader_BASE_URI}/`
137
191
  }, (error, exports)=>{
138
- if (error) {
139
- callback(error);
140
- return;
141
- }
192
+ if (error) return void callback(error);
142
193
  handleExports(exports);
143
194
  });
144
195
  };
145
- 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 };
196
+ const css_libCssExtractLoader = css_libCssExtractLoader_loader;
197
+ export { css_libCssExtractLoader_ABSOLUTE_PUBLIC_PATH as ABSOLUTE_PUBLIC_PATH, css_libCssExtractLoader_AUTO_PUBLIC_PATH as AUTO_PUBLIC_PATH, css_libCssExtractLoader_BASE_URI as BASE_URI, libCssExtractLoader_MODULE_TYPE as MODULE_TYPE, css_libCssExtractLoader_SINGLE_DOT_PATH_SEGMENT as SINGLE_DOT_PATH_SEGMENT, css_libCssExtractLoader as default, libCssExtractLoader_pitch as pitch };
@@ -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<{
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rslib/core",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
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.1",
39
+ "@rsbuild/core": "1.3.5",
40
40
  "tinyglobby": "^0.2.12",
41
- "rsbuild-plugin-dts": "0.6.1"
41
+ "rsbuild-plugin-dts": "0.6.3"
42
42
  },
43
43
  "devDependencies": {
44
- "@module-federation/rsbuild-plugin": "^0.11.2",
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.2.7",
51
+ "prebundle": "1.3.3",
52
52
  "rsbuild-plugin-publint": "^0.3.0",
53
- "rslib": "npm:@rslib/core@0.6.0",
53
+ "rslib": "npm:@rslib/core@0.6.2",
54
54
  "rslog": "^1.2.3",
55
55
  "tsconfck": "3.1.5",
56
- "typescript": "^5.8.2",
56
+ "typescript": "^5.8.3",
57
57
  "@rslib/tsconfig": "0.0.1"
58
58
  },
59
59
  "peerDependencies": {