@rslib/core 0.2.2 → 0.3.0

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.
@@ -1 +1 @@
1
- {"name":"commander","author":"TJ Holowaychuk <tj@vision-media.ca>","version":"12.1.0","license":"MIT","types":"index.d.ts","type":"commonjs"}
1
+ {"name":"commander","author":"TJ Holowaychuk <tj@vision-media.ca>","version":"13.0.0","license":"MIT","types":"index.d.ts","type":"commonjs"}
@@ -5,14 +5,14 @@ const JS_EXTENSIONS = [
5
5
  'js',
6
6
  'mjs',
7
7
  'jsx',
8
- 'ts',
9
- 'mts',
8
+ '(?<!d.)ts',
9
+ '(?<!d.)mts',
10
+ '(?<!d.)cts',
10
11
  'tsx',
11
12
  'cjs',
12
13
  'cjsx',
13
14
  'mjsx',
14
15
  'mtsx',
15
- 'cts',
16
16
  'ctsx'
17
17
  ];
18
18
  const CSS_EXTENSIONS = [
package/dist/index.js CHANGED
@@ -160,7 +160,7 @@ function prepareCli() {
160
160
  initNodeEnv();
161
161
  const { npm_execpath } = process.env;
162
162
  if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
163
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.greet(` Rslib v0.2.2\n`);
163
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.greet(` Rslib v0.3.0\n`);
164
164
  }
165
165
  const composeAssetConfig = (bundle, format)=>{
166
166
  if ('esm' === format || 'cjs' === format) {
@@ -190,14 +190,14 @@ const JS_EXTENSIONS = [
190
190
  'js',
191
191
  'mjs',
192
192
  'jsx',
193
- 'ts',
194
- 'mts',
193
+ '(?<!d.)ts',
194
+ '(?<!d.)mts',
195
+ '(?<!d.)cts',
195
196
  'tsx',
196
197
  'cjs',
197
198
  'cjsx',
198
199
  'mjsx',
199
200
  'mtsx',
200
- 'cts',
201
201
  'ctsx'
202
202
  ];
203
203
  const CSS_EXTENSIONS = [
@@ -304,15 +304,20 @@ function isCssGlobalFile(filepath, auto) {
304
304
  const isCssModules = isCssModulesFile(filepath, auto);
305
305
  return !isCssModules;
306
306
  }
307
- function cssExternalHandler(request, callback, jsExtension, auto, isStyleRedirect) {
308
- const isCssModulesRequest = isCssModulesFile(request, auto);
307
+ async function cssExternalHandler(request, callback, jsExtension, auto, styleRedirectPath, styleRedirectExtension, redirectPath) {
309
308
  if (/compiled\/css-loader\//.test(request)) return callback();
310
- if ('.' === request[0] && isCssFile(request)) {
311
- if (!isStyleRedirect) return callback(void 0, request);
312
- if (isCssModulesRequest) return callback(void 0, request.replace(/\.[^.]+$/, jsExtension));
313
- return callback(void 0, request.replace(/\.[^.]+$/, '.css'));
309
+ let resolvedRequest = request;
310
+ if (styleRedirectPath) {
311
+ const resolved = await redirectPath(resolvedRequest);
312
+ if (resolved) resolvedRequest = resolved;
314
313
  }
315
- return false;
314
+ if (!isCssFile(resolvedRequest)) return false;
315
+ if (styleRedirectExtension) {
316
+ const isCssModulesRequest = isCssModulesFile(resolvedRequest, auto);
317
+ if (isCssModulesRequest) return callback(void 0, resolvedRequest.replace(/\.[^.]+$/, jsExtension));
318
+ return callback(void 0, resolvedRequest.replace(/\.[^.]+$/, '.css'));
319
+ }
320
+ return callback(void 0, resolvedRequest);
316
321
  }
317
322
  const PLUGIN_NAME = 'rsbuild:lib-css';
318
323
  const pluginLibCss = (rootDir)=>({
@@ -407,19 +412,28 @@ class EntryChunkPlugin {
407
412
  shebangEntries = {};
408
413
  shebangInjectedAssets = new Set();
409
414
  enabledImportMetaUrlShim;
410
- constructor({ enabledImportMetaUrlShim = true }){
415
+ contextToWatch = null;
416
+ contextWatched = false;
417
+ constructor({ enabledImportMetaUrlShim = true, contextToWatch }){
411
418
  this.enabledImportMetaUrlShim = enabledImportMetaUrlShim;
419
+ this.contextToWatch = contextToWatch;
412
420
  }
413
421
  apply(compiler) {
414
- compiler.hooks.entryOption.tap(EntryChunkPlugin_PLUGIN_NAME, (_context, entries)=>{
422
+ compiler.hooks.afterCompile.tap(EntryChunkPlugin_PLUGIN_NAME, (compilation)=>{
423
+ if (this.contextWatched || null === this.contextToWatch) return;
424
+ const contextDep = compilation.contextDependencies;
425
+ contextDep.add(this.contextToWatch);
426
+ this.contextWatched = true;
427
+ });
428
+ compiler.hooks.make.tap(EntryChunkPlugin_PLUGIN_NAME, (compilation)=>{
429
+ const entries = {};
430
+ for (const [key, value] of compilation.entries){
431
+ const firstDep = value.dependencies[0];
432
+ if (firstDep?.request) entries[key] = firstDep.request;
433
+ }
415
434
  for(const name in entries){
416
- const entry = entries[name];
417
- if (!entry) continue;
418
- let first;
419
- if (Array.isArray(entry)) first = entry[0];
420
- else if (Array.isArray(entry.import)) first = entry.import[0];
421
- else if ('string' == typeof entry) first = entry;
422
- if ('string' != typeof first) continue;
435
+ const first = entries[name];
436
+ if (!first) continue;
423
437
  const filename = first.split('?')[0];
424
438
  const isJs = JS_EXTENSIONS_PATTERN.test(filename);
425
439
  if (!isJs) continue;
@@ -434,7 +448,7 @@ class EntryChunkPlugin {
434
448
  if (reactDirective) this.reactDirectives[name] = reactDirective;
435
449
  }
436
450
  });
437
- compiler.hooks.thisCompilation.tap(EntryChunkPlugin_PLUGIN_NAME, (compilation)=>{
451
+ compiler.hooks.make.tap(EntryChunkPlugin_PLUGIN_NAME, (compilation)=>{
438
452
  compilation.hooks.chunkAsset.tap(EntryChunkPlugin_PLUGIN_NAME, (chunk, filename)=>{
439
453
  const isJs = JS_EXTENSIONS_PATTERN.test(filename);
440
454
  if (!isJs) return;
@@ -491,7 +505,7 @@ const entryModuleLoaderRsbuildPlugin = ()=>({
491
505
  });
492
506
  }
493
507
  });
494
- const composeEntryChunkConfig = ({ enabledImportMetaUrlShim })=>({
508
+ const composeEntryChunkConfig = ({ enabledImportMetaUrlShim, contextToWatch = null })=>({
495
509
  plugins: [
496
510
  entryModuleLoaderRsbuildPlugin()
497
511
  ],
@@ -499,7 +513,8 @@ const composeEntryChunkConfig = ({ enabledImportMetaUrlShim })=>({
499
513
  rspack: {
500
514
  plugins: [
501
515
  new EntryChunkPlugin({
502
- enabledImportMetaUrlShim
516
+ enabledImportMetaUrlShim,
517
+ contextToWatch
503
518
  })
504
519
  ]
505
520
  }
@@ -1302,7 +1317,8 @@ const composeExternalsWarnConfig = (format, ...externalsArray)=>{
1302
1317
  };
1303
1318
  const getAutoExternalDefaultValue = (format, autoExternal)=>autoExternal ?? isIntermediateOutputFormat(format);
1304
1319
  const composeAutoExternalConfig = (options)=>{
1305
- const { format, pkgJson, userExternals } = options;
1320
+ const { bundle, format, pkgJson, userExternals } = options;
1321
+ if (false === bundle) return {};
1306
1322
  const autoExternal = getAutoExternalDefaultValue(format, options.autoExternal);
1307
1323
  if (false === autoExternal) return {};
1308
1324
  if (!pkgJson) {
@@ -1514,7 +1530,8 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
1514
1530
  },
1515
1531
  optimization: {
1516
1532
  concatenateModules: true,
1517
- sideEffects: 'flag'
1533
+ sideEffects: 'flag',
1534
+ avoidEntryIife: true
1518
1535
  },
1519
1536
  output: {
1520
1537
  module: true,
@@ -1753,62 +1770,99 @@ const composeSyntaxConfig = (target, syntax)=>{
1753
1770
  }
1754
1771
  };
1755
1772
  };
1756
- const appendEntryQuery = (entry)=>{
1773
+ const traverseEntryQuery = (entry, callback)=>{
1757
1774
  const newEntry = {};
1758
1775
  for (const [key, value] of Object.entries(entry)){
1759
1776
  let result = value;
1760
- result = 'string' == typeof value ? `${value}?${RSLIB_ENTRY_QUERY}` : Array.isArray(value) ? value.map((item)=>`${item}?${RSLIB_ENTRY_QUERY}`) : {
1777
+ result = 'string' == typeof value ? callback(value) : Array.isArray(value) ? value.map(callback) : {
1761
1778
  ...value,
1762
- import: 'string' == typeof value.import ? `${value.import}?${RSLIB_ENTRY_QUERY}` : value.import.map((item)=>`${item}?${RSLIB_ENTRY_QUERY}`)
1779
+ import: 'string' == typeof value.import ? callback(value.import) : value.import.map(callback)
1763
1780
  };
1764
1781
  newEntry[key] = result;
1765
1782
  }
1766
1783
  return newEntry;
1767
1784
  };
1768
- const composeEntryConfig = async (entries, bundle, root, cssModulesAuto)=>{
1769
- if (!entries) return {
1770
- entryConfig: {},
1771
- lcp: null
1772
- };
1773
- if (false !== bundle) return {
1774
- entryConfig: {
1775
- source: {
1776
- entry: appendEntryQuery(entries)
1785
+ const appendEntryQuery = (entries)=>traverseEntryQuery(entries, (item)=>`${item}?${RSLIB_ENTRY_QUERY}`);
1786
+ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto)=>{
1787
+ let entries = rawEntry;
1788
+ if (!entries) {
1789
+ if (false !== bundle) return {
1790
+ entryConfig: {},
1791
+ lcp: null
1792
+ };
1793
+ entries = {
1794
+ index: 'src/**'
1795
+ };
1796
+ }
1797
+ if (false !== bundle) {
1798
+ let isFileEntry = false;
1799
+ traverseEntryQuery(entries, (entry)=>{
1800
+ const entryAbsPath = __WEBPACK_EXTERNAL_MODULE_node_path__["default"].isAbsolute(entry) ? entry : __WEBPACK_EXTERNAL_MODULE_node_path__["default"].resolve(root, entry);
1801
+ if (__WEBPACK_EXTERNAL_MODULE_node_fs__["default"].existsSync(entryAbsPath)) {
1802
+ const stats = __WEBPACK_EXTERNAL_MODULE_node_fs__["default"].statSync(entryAbsPath);
1803
+ isFileEntry = stats.isFile();
1777
1804
  }
1778
- },
1779
- lcp: null
1780
- };
1781
- const resolvedEntries = {};
1782
- for (const key of Object.keys(entries)){
1783
- const entry = entries[key];
1784
- const entryFiles = Array.isArray(entry) ? entry : 'string' == typeof entry ? [
1785
- entry
1786
- ] : null;
1787
- if (!entryFiles) throw new Error('Entry can only be a string or an array of strings for now');
1788
- const globEntryFiles = await (0, __WEBPACK_EXTERNAL_MODULE_tinyglobby__.glob)(entryFiles, {
1789
- cwd: root,
1790
- absolute: true
1805
+ return entry;
1791
1806
  });
1792
- const resolvedEntryFiles = globEntryFiles.filter((file)=>ENTRY_EXTENSIONS_PATTERN.test(file));
1793
- if (0 === resolvedEntryFiles.length) throw new Error(`Cannot find ${resolvedEntryFiles}`);
1794
- const lcp = await calcLongestCommonPath(resolvedEntryFiles);
1795
- const outBase = null === lcp ? root : lcp;
1796
- function getEntryName(file) {
1797
- const { dir, name } = __WEBPACK_EXTERNAL_MODULE_node_path__["default"].parse(__WEBPACK_EXTERNAL_MODULE_node_path__["default"].relative(outBase, file));
1798
- const entryFileName = __WEBPACK_EXTERNAL_MODULE_node_path__["default"].join(dir, name);
1799
- if (isCssGlobalFile(file, cssModulesAuto)) return `${RSLIB_CSS_ENTRY_FLAG}/${entryFileName}`;
1800
- return entryFileName;
1807
+ if (!isFileEntry) throw new Error(`Glob pattern is not supported when "bundle" is "true", considering ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__["default"].green('set "bundle" to "false"')} to use bundleless mode. See ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__["default"].green('https://lib.rsbuild.dev/guide/basic/output-structure')} for more details.`);
1808
+ return {
1809
+ entryConfig: {
1810
+ source: {
1811
+ entry: appendEntryQuery(entries)
1812
+ }
1813
+ },
1814
+ lcp: null
1815
+ };
1816
+ }
1817
+ const scanGlobEntries = async (calcLcp)=>{
1818
+ const resolvedEntries = {};
1819
+ for (const key of Object.keys(entries)){
1820
+ const entry = entries[key];
1821
+ const entryFiles = Array.isArray(entry) ? entry : 'string' == typeof entry ? [
1822
+ entry
1823
+ ] : null;
1824
+ if (!entryFiles) throw new Error('Entry can only be a string or an array of strings for now');
1825
+ const globEntryFiles = await (0, __WEBPACK_EXTERNAL_MODULE_tinyglobby__.glob)(entryFiles, {
1826
+ cwd: root,
1827
+ absolute: true
1828
+ });
1829
+ const resolvedEntryFiles = globEntryFiles.filter((file)=>ENTRY_EXTENSIONS_PATTERN.test(file));
1830
+ if (0 === resolvedEntryFiles.length) throw new Error(`Cannot find ${resolvedEntryFiles}`);
1831
+ const lcp = await calcLongestCommonPath(resolvedEntryFiles);
1832
+ const outBase = null === lcp ? root : lcp;
1833
+ function getEntryName(file) {
1834
+ const { dir, name } = __WEBPACK_EXTERNAL_MODULE_node_path__["default"].parse(__WEBPACK_EXTERNAL_MODULE_node_path__["default"].relative(outBase, file));
1835
+ const entryFileName = __WEBPACK_EXTERNAL_MODULE_node_path__["default"].join(dir, name);
1836
+ if (isCssGlobalFile(file, cssModulesAuto)) return `${RSLIB_CSS_ENTRY_FLAG}/${entryFileName}`;
1837
+ return entryFileName;
1838
+ }
1839
+ for (const file of resolvedEntryFiles){
1840
+ const entryName = getEntryName(file);
1841
+ if (resolvedEntries[entryName]) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.warn(`duplicate entry: ${entryName}, this may lead to the incorrect output, please rename the file`);
1842
+ resolvedEntries[entryName] = file;
1843
+ }
1801
1844
  }
1802
- for (const file of resolvedEntryFiles){
1803
- const entryName = getEntryName(file);
1804
- if (resolvedEntries[entryName]) __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.warn(`duplicate entry: ${entryName}, this may lead to the incorrect output, please rename the file`);
1805
- resolvedEntries[entryName] = file;
1845
+ if (calcLcp) {
1846
+ const lcp = await calcLongestCommonPath(Object.values(resolvedEntries));
1847
+ return {
1848
+ resolvedEntries,
1849
+ lcp
1850
+ };
1806
1851
  }
1807
- }
1808
- const lcp = await calcLongestCommonPath(Object.values(resolvedEntries));
1852
+ return {
1853
+ resolvedEntries,
1854
+ lcp: null
1855
+ };
1856
+ };
1857
+ const { lcp } = await scanGlobEntries(true);
1809
1858
  const entryConfig = {
1810
- source: {
1811
- entry: appendEntryQuery(resolvedEntries)
1859
+ tools: {
1860
+ rspack: {
1861
+ entry: async ()=>{
1862
+ const { resolvedEntries } = await scanGlobEntries(false);
1863
+ return appendEntryQuery(resolvedEntries);
1864
+ }
1865
+ }
1812
1866
  }
1813
1867
  };
1814
1868
  return {
@@ -1820,7 +1874,8 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
1820
1874
  if (bundle) return {
1821
1875
  config: {}
1822
1876
  };
1823
- const isStyleRedirected = redirect.style ?? true;
1877
+ const styleRedirectPath = redirect.style?.path ?? true;
1878
+ const styleRedirectExtension = redirect.style?.extension ?? true;
1824
1879
  const jsRedirectPath = redirect.js?.path ?? true;
1825
1880
  const jsRedirectExtension = redirect.js?.extension ?? true;
1826
1881
  let resolver;
@@ -1835,17 +1890,31 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
1835
1890
  async (data, callback)=>{
1836
1891
  const { request, getResolve, context, contextInfo } = data;
1837
1892
  if (!request || !getResolve || !context || !contextInfo) return callback();
1893
+ const { issuer } = contextInfo;
1838
1894
  if (!resolver) resolver = await getResolve();
1839
- if (contextInfo.issuer) {
1840
- let resolvedRequest = request;
1841
- const cssExternal = cssExternalHandler(resolvedRequest, callback, jsExtension, cssModulesAuto, isStyleRedirected);
1842
- if (false !== cssExternal) return cssExternal;
1843
- if (jsRedirectPath) try {
1895
+ async function redirectPath(request) {
1896
+ try {
1897
+ let resolvedRequest = request;
1844
1898
  resolvedRequest = await resolver(context, resolvedRequest);
1845
- resolvedRequest = normalizeSlash(__WEBPACK_EXTERNAL_MODULE_node_path__["default"].relative(__WEBPACK_EXTERNAL_MODULE_node_path__["default"].dirname(contextInfo.issuer), resolvedRequest));
1846
- if ('.' !== resolvedRequest[0]) resolvedRequest = `./${resolvedRequest}`;
1899
+ if (!resolvedRequest.includes('node_modules')) {
1900
+ resolvedRequest = normalizeSlash(__WEBPACK_EXTERNAL_MODULE_node_path__["default"].relative(__WEBPACK_EXTERNAL_MODULE_node_path__["default"].dirname(issuer), resolvedRequest));
1901
+ if ('.' !== resolvedRequest[0]) resolvedRequest = `./${resolvedRequest}`;
1902
+ return resolvedRequest;
1903
+ }
1904
+ return;
1847
1905
  } catch (e) {
1848
- __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.warn(`Failed to resolve module ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__["default"].green(`"${resolvedRequest}"`)} from ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__["default"].green(contextInfo.issuer)}. If it's an npm package, consider adding it to dependencies or peerDependencies in package.json to make it externalized.`);
1906
+ __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger.debug(`Failed to resolve module ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__["default"].green(`"${request}"`)} from ${__WEBPACK_EXTERNAL_MODULE__compiled_picocolors_index_js__["default"].green(issuer)}. If it's an npm package, consider adding it to dependencies or peerDependencies in package.json to make it externalized.`);
1907
+ return request;
1908
+ }
1909
+ }
1910
+ if (issuer) {
1911
+ let resolvedRequest = request;
1912
+ const cssExternal = await cssExternalHandler(resolvedRequest, callback, jsExtension, cssModulesAuto, styleRedirectPath, styleRedirectExtension, redirectPath);
1913
+ if (false !== cssExternal) return cssExternal;
1914
+ if (jsRedirectPath) {
1915
+ const redirectedPath = await redirectPath(resolvedRequest);
1916
+ if (void 0 === redirectedPath) return callback(void 0, request);
1917
+ resolvedRequest = redirectedPath;
1849
1918
  }
1850
1919
  if (jsRedirectExtension && resolvedRequest.startsWith('.')) {
1851
1920
  const ext = (0, __WEBPACK_EXTERNAL_MODULE_node_path__.extname)(resolvedRequest);
@@ -1977,6 +2046,7 @@ async function composeLibRsbuildConfig(config, root, sharedPlugins) {
1977
2046
  const { config: targetConfig, externalsConfig: targetExternalsConfig, target } = composeTargetConfig(config.output?.target, format);
1978
2047
  const syntaxConfig = composeSyntaxConfig(target, config?.syntax);
1979
2048
  const autoExternalConfig = composeAutoExternalConfig({
2049
+ bundle,
1980
2050
  format: format,
1981
2051
  autoExternal,
1982
2052
  pkgJson,
@@ -1986,7 +2056,8 @@ async function composeLibRsbuildConfig(config, root, sharedPlugins) {
1986
2056
  const cssConfig = composeCssConfig(lcp, config.bundle);
1987
2057
  const assetConfig = composeAssetConfig(bundle, format);
1988
2058
  const entryChunkConfig = composeEntryChunkConfig({
1989
- enabledImportMetaUrlShim: enabledShims.cjs['import.meta.url']
2059
+ enabledImportMetaUrlShim: enabledShims.cjs['import.meta.url'],
2060
+ contextToWatch: lcp
1990
2061
  });
1991
2062
  const dtsConfig = await composeDtsConfig(config, dtsExtension);
1992
2063
  const externalsWarnConfig = composeExternalsWarnConfig(format, autoExternalConfig?.output?.externals, userExternalsConfig?.output?.externals);
@@ -2065,7 +2136,9 @@ async function composeRsbuildEnvironments(rslibConfig) {
2065
2136
  }
2066
2137
  const pruneEnvironments = (environments, libs)=>{
2067
2138
  if (!libs) return environments;
2068
- return Object.fromEntries(Object.entries(environments).filter(([name])=>libs.includes(name)));
2139
+ const filteredEnvironments = Object.fromEntries(Object.entries(environments).filter(([name])=>libs.includes(name)));
2140
+ if (0 === Object.keys(filteredEnvironments).length) throw new Error(`The following libs are not found: ${libs.map((lib)=>`"${lib}"`).join(', ')}.`);
2141
+ return filteredEnvironments;
2069
2142
  };
2070
2143
  async function watchFilesForRestart(files, restart) {
2071
2144
  if (!files.length) return;
@@ -2183,7 +2256,7 @@ async function initMFRsbuild(config, options = {}) {
2183
2256
  if (!options?.lib) return isMf;
2184
2257
  return env.id && options.lib.includes(env.id);
2185
2258
  }).map((env)=>env.id);
2186
- if (!selectedEnvironmentIds.length) throw new Error('No mf format found, please check your config.');
2259
+ if (!selectedEnvironmentIds.length) throw new Error(`No mf format found in ${options.lib ? `libs ${options.lib.map((lib)=>`"${lib}"`).join(', ')}` : 'your config'}, please check your config to ensure that the mf format is enabled correctly.`);
2187
2260
  const selectedEnvironments = pruneEnvironments(environments, selectedEnvironmentIds);
2188
2261
  const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core__.createRsbuild)({
2189
2262
  rsbuildConfig: {
@@ -2206,7 +2279,7 @@ const repeatableOption = (value, previous)=>(previous ?? []).concat([
2206
2279
  value
2207
2280
  ]);
2208
2281
  function runCli() {
2209
- __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.name('rslib').usage('<command> [options]').version("0.2.2");
2282
+ __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.name('rslib').usage('<command> [options]').version("0.3.0");
2210
2283
  const buildCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.command('build');
2211
2284
  const inspectCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.command('inspect');
2212
2285
  const mfDevCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.command('mf-dev');
@@ -2266,6 +2339,6 @@ function runCli() {
2266
2339
  });
2267
2340
  __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js__.program.parse();
2268
2341
  }
2269
- const src_rslib_entry_version = "0.2.2";
2342
+ const src_rslib_entry_version = "0.3.0";
2270
2343
  var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js__.logger;
2271
2344
  export { build, defineConfig, inspect, loadConfig, prepareCli, runCli, startMFDevServer, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, src_rslib_entry_version as version, __webpack_exports__logger as logger };
@@ -1,4 +1,4 @@
1
- import { type EnvironmentConfig } from '@rsbuild/core';
1
+ import { type EnvironmentConfig, type RsbuildEntry } from '@rsbuild/core';
2
2
  import type { AutoExternal, BannerAndFooter, Format, LibConfig, PkgJson, RequireKey, RsbuildConfigEntry, RsbuildConfigWithLibInfo, RslibConfig, RslibConfigAsyncFn, RslibConfigExport, RslibConfigSyncFn } from './types';
3
3
  /**
4
4
  * This function helps you to autocomplete configuration types.
@@ -17,6 +17,7 @@ export declare function loadConfig({ cwd, path, envMode, }: {
17
17
  filePath: string;
18
18
  }>;
19
19
  export declare const composeAutoExternalConfig: (options: {
20
+ bundle: boolean;
20
21
  format: Format;
21
22
  autoExternal?: AutoExternal;
22
23
  pkgJson?: PkgJson;
@@ -27,7 +28,7 @@ export declare function composeBannerFooterConfig(banner: BannerAndFooter, foote
27
28
  export declare function composeDecoratorsConfig(compilerOptions?: Record<string, any>, version?: NonNullable<NonNullable<EnvironmentConfig['source']>['decorators']>['version']): EnvironmentConfig;
28
29
  export declare function createConstantRsbuildConfig(): Promise<EnvironmentConfig>;
29
30
  export declare const composeModuleImportWarn: (request: string) => string;
30
- export declare const appendEntryQuery: (entry: RsbuildConfigEntry) => RsbuildConfigEntry;
31
+ export declare const appendEntryQuery: (entries: RsbuildConfigEntry) => RsbuildEntry;
31
32
  export declare function composeCreateRsbuildConfig(rslibConfig: RslibConfig): Promise<RsbuildConfigWithLibInfo[]>;
32
33
  export declare function composeRsbuildEnvironments(rslibConfig: RslibConfig): Promise<{
33
34
  environments: Record<string, EnvironmentConfig>;
@@ -5,9 +5,6 @@ export declare const RSLIB_ENTRY_QUERY = "__rslib_entry__";
5
5
  export declare const SHEBANG_PREFIX = "#!";
6
6
  export declare const SHEBANG_REGEX: RegExp;
7
7
  export declare const REACT_DIRECTIVE_REGEX: RegExp;
8
- export declare const JS_EXTENSIONS: string[];
9
- export declare const CSS_EXTENSIONS: string[];
10
- export declare const ENTRY_EXTENSIONS: string[];
11
8
  export declare const JS_EXTENSIONS_PATTERN: RegExp;
12
9
  export declare const CSS_EXTENSIONS_PATTERN: RegExp;
13
10
  export declare const ENTRY_EXTENSIONS_PATTERN: RegExp;
@@ -12,6 +12,6 @@ export declare function parsePathQueryFragment(str: string): {
12
12
  export declare function isCssModulesFile(filepath: string, auto: CssLoaderOptionsAuto): boolean;
13
13
  export declare function isCssGlobalFile(filepath: string, auto: CssLoaderOptionsAuto): boolean;
14
14
  type ExternalCallback = (arg0?: undefined, arg1?: string) => void;
15
- export declare function cssExternalHandler(request: string, callback: ExternalCallback, jsExtension: string, auto: CssLoaderOptionsAuto, isStyleRedirect: boolean): void | false;
15
+ export declare function cssExternalHandler(request: string, callback: ExternalCallback, jsExtension: string, auto: CssLoaderOptionsAuto, styleRedirectPath: boolean, styleRedirectExtension: boolean, redirectPath: (request: string) => Promise<string | undefined>): Promise<false | void>;
16
16
  export declare const composeCssConfig: (rootDir: string | null, bundle?: boolean) => EnvironmentConfig;
17
17
  export {};
@@ -1,4 +1,5 @@
1
1
  import { type EnvironmentConfig } from '@rsbuild/core';
2
- export declare const composeEntryChunkConfig: ({ enabledImportMetaUrlShim, }: {
2
+ export declare const composeEntryChunkConfig: ({ enabledImportMetaUrlShim, contextToWatch, }: {
3
3
  enabledImportMetaUrlShim: boolean;
4
+ contextToWatch: string | null;
4
5
  }) => EnvironmentConfig;
@@ -51,11 +51,23 @@ export type JsRedirect = {
51
51
  */
52
52
  extension?: boolean;
53
53
  };
54
+ export type StyleRedirect = {
55
+ /**
56
+ * Whether to automatically redirect the import paths of style output files.
57
+ * @defaultValue `true`
58
+ */
59
+ path?: boolean;
60
+ /**
61
+ * Whether to automatically add the file extension to import paths based on the style output files.
62
+ * @defaultValue `true`
63
+ */
64
+ extension?: boolean;
65
+ };
54
66
  export type Redirect = {
55
67
  /** Controls the redirect of the import paths of output JavaScript files. */
56
68
  js?: JsRedirect;
57
69
  /** Whether to redirect the import path of the style file. */
58
- style?: boolean;
70
+ style?: StyleRedirect;
59
71
  };
60
72
  export interface LibConfig extends EnvironmentConfig {
61
73
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rslib/core",
3
- "version": "0.2.2",
3
+ "version": "0.3.0",
4
4
  "description": "The Rsbuild-based library development tool.",
5
5
  "homepage": "https://lib.rsbuild.dev",
6
6
  "bugs": {
@@ -32,21 +32,21 @@
32
32
  "compiled"
33
33
  ],
34
34
  "dependencies": {
35
- "@rsbuild/core": "~1.1.13",
35
+ "@rsbuild/core": "1.2.0-alpha.0",
36
36
  "tinyglobby": "^0.2.10",
37
- "rsbuild-plugin-dts": "0.2.2"
37
+ "rsbuild-plugin-dts": "0.3.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@module-federation/rsbuild-plugin": "^0.8.5",
40
+ "@module-federation/rsbuild-plugin": "^0.8.7",
41
41
  "@types/fs-extra": "^11.0.4",
42
42
  "chokidar": "^4.0.3",
43
- "commander": "^12.1.0",
43
+ "commander": "^13.0.0",
44
44
  "fs-extra": "^11.2.0",
45
- "memfs": "^4.15.1",
45
+ "memfs": "^4.15.3",
46
46
  "picocolors": "1.1.1",
47
47
  "prebundle": "1.2.5",
48
48
  "rsbuild-plugin-publint": "^0.2.1",
49
- "rslib": "npm:@rslib/core@0.2.0",
49
+ "rslib": "npm:@rslib/core@0.2.2",
50
50
  "rslog": "^1.2.3",
51
51
  "tsconfck": "3.1.4",
52
52
  "typescript": "^5.7.2",