@rslib/core 0.18.0 → 0.18.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/dist/800.js CHANGED
@@ -1,5 +1,44 @@
1
1
  import node_path, { basename, dirname, extname, isAbsolute, join } from "node:path";
2
- import { CSS_EXTENSIONS_PATTERN } from "./121.js";
2
+ const DEFAULT_CONFIG_NAME = 'rslib.config';
3
+ const DEFAULT_CONFIG_EXTENSIONS = [
4
+ '.js',
5
+ '.ts',
6
+ '.mjs',
7
+ '.mts',
8
+ '.cjs',
9
+ '.cts'
10
+ ];
11
+ const SWC_HELPERS = '@swc/helpers';
12
+ const DTS_EXTENSIONS = [
13
+ 'd.ts',
14
+ 'd.mts',
15
+ 'd.cts'
16
+ ];
17
+ const JS_EXTENSIONS = [
18
+ 'js',
19
+ 'mjs',
20
+ 'jsx',
21
+ '(?<!\\.d\\.)ts',
22
+ '(?<!\\.d\\.)mts',
23
+ '(?<!\\.d\\.)cts',
24
+ 'tsx',
25
+ 'cjs',
26
+ 'cjsx',
27
+ 'mjsx',
28
+ 'mtsx',
29
+ 'ctsx'
30
+ ];
31
+ const CSS_EXTENSIONS = [
32
+ 'css',
33
+ 'sass',
34
+ 'scss',
35
+ 'less',
36
+ 'styl',
37
+ 'stylus'
38
+ ];
39
+ const JS_EXTENSIONS_PATTERN = new RegExp(`\\.(${JS_EXTENSIONS.join('|')})$`);
40
+ const CSS_EXTENSIONS_PATTERN = new RegExp(`\\.(${CSS_EXTENSIONS.join('|')})$`);
41
+ const DTS_EXTENSIONS_PATTERN = new RegExp(`\\.(${DTS_EXTENSIONS.join('|')})$`);
3
42
  function getUndoPath(filename, outputPathArg, enforceRelative) {
4
43
  let depth = -1;
5
44
  let append = '';
@@ -49,4 +88,4 @@ const BASE_URI = 'webpack://';
49
88
  const AUTO_PUBLIC_PATH = '__mini_css_extract_plugin_public_path_auto__';
50
89
  const ABSOLUTE_PUBLIC_PATH = `${BASE_URI}/mini-css-extract-plugin/`;
51
90
  const SINGLE_DOT_PATH_SEGMENT = '__mini_css_extract_plugin_single_dot_path_segment__';
52
- export { ABSOLUTE_PUBLIC_PATH, AUTO_PUBLIC_PATH, BASE_URI, SINGLE_DOT_PATH_SEGMENT, basename, dirname, extname, getUndoPath, isAbsolute, isCssFile, isCssGlobalFile, isCssModulesFile, join, node_path };
91
+ export { ABSOLUTE_PUBLIC_PATH, AUTO_PUBLIC_PATH, BASE_URI, CSS_EXTENSIONS_PATTERN, DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME, DTS_EXTENSIONS_PATTERN, JS_EXTENSIONS_PATTERN, SINGLE_DOT_PATH_SEGMENT, SWC_HELPERS, basename, dirname, extname, getUndoPath, isAbsolute, isCssFile, isCssGlobalFile, isCssModulesFile, join, node_path };
@@ -1,22 +1,5 @@
1
- import { SHEBANG_REGEX, REACT_DIRECTIVE_REGEX } from "./121.js";
2
- function splitFromFirstLine(text) {
3
- const match = text.match(/(\r\n|\n)/);
4
- if (!match) return [
5
- text,
6
- ''
7
- ];
8
- return [
9
- text.slice(0, match.index),
10
- text.slice(match.index)
11
- ];
12
- }
13
1
  const entryModuleLoader_loader = function(source) {
14
- let result = source;
15
- const [firstLine1, rest] = splitFromFirstLine(result);
16
- if (SHEBANG_REGEX.test(firstLine1)) result = rest;
17
- const [firstLine2, rest2] = splitFromFirstLine(result);
18
- if (REACT_DIRECTIVE_REGEX.test(firstLine2)) result = rest2;
19
- return result;
2
+ return source;
20
3
  };
21
4
  const entryModuleLoader = entryModuleLoader_loader;
22
5
  export default entryModuleLoader;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import * as __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ from "@rsbuild/core";
2
- import node_fs, { chmodSync, promises } from "node:fs";
1
+ import * as __rspack_external__rsbuild_core_1b356efc from "@rsbuild/core";
2
+ import node_fs, { promises } from "node:fs";
3
3
  import { glob } from "../compiled/tinyglobby/index.js";
4
4
  import { createRequire } from "node:module";
5
5
  import picocolors from "../compiled/picocolors/index.js";
@@ -8,8 +8,7 @@ import node_fs_promises from "node:fs/promises";
8
8
  import { createRequire as external_module_createRequire } from "module";
9
9
  import { EventEmitter } from "events";
10
10
  import node_util from "node:util";
11
- import { basename as external_node_path_basename, node_path, extname, getUndoPath, ABSOLUTE_PUBLIC_PATH, isCssFile, dirname, AUTO_PUBLIC_PATH, join, isAbsolute, SINGLE_DOT_PATH_SEGMENT, isCssGlobalFile, BASE_URI, isCssModulesFile } from "./800.js";
12
- import { DEFAULT_CONFIG_NAME, SHEBANG_REGEX, DTS_EXTENSIONS_PATTERN, SWC_HELPERS, CSS_EXTENSIONS_PATTERN, JS_EXTENSIONS_PATTERN, DEFAULT_CONFIG_EXTENSIONS, REACT_DIRECTIVE_REGEX } from "./121.js";
11
+ import { basename as external_node_path_basename, node_path, extname, DEFAULT_CONFIG_NAME, dirname, DTS_EXTENSIONS_PATTERN, SWC_HELPERS, CSS_EXTENSIONS_PATTERN, JS_EXTENSIONS_PATTERN, BASE_URI, join, getUndoPath, ABSOLUTE_PUBLIC_PATH, isCssFile, AUTO_PUBLIC_PATH, isAbsolute, isCssGlobalFile, DEFAULT_CONFIG_EXTENSIONS, SINGLE_DOT_PATH_SEGMENT, isCssModulesFile } from "./800.js";
13
12
  const LibSvgrPatchPlugin_pluginName = 'LIB_SVGR_PATCH_PLUGIN';
14
13
  const PUBLIC_PATH_PLACEHOLDER = '__RSLIB_SVGR_AUTO_PUBLIC_PATH__';
15
14
  class LibSvgrPatchPlugin {
@@ -21,7 +20,7 @@ class LibSvgrPatchPlugin {
21
20
  const chunkAsset = Object.keys(assets).filter((name)=>/js$/.test(name));
22
21
  for (const name of chunkAsset)compilation.updateAsset(name, (old)=>{
23
22
  const oldSource = old.source().toString();
24
- const newSource = new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.sources.ReplaceSource(old);
23
+ const newSource = new __rspack_external__rsbuild_core_1b356efc.rspack.sources.ReplaceSource(old);
25
24
  const pattern = new RegExp(`\\(?['"]${PUBLIC_PATH_PLACEHOLDER}(.*)['"]\\)?`, 'g');
26
25
  const matches = [
27
26
  ...oldSource.matchAll(pattern)
@@ -165,7 +164,7 @@ class LibCssExtractPlugin {
165
164
  const chunkAsset = Object.keys(assets).filter((name)=>/\.css/.test(name));
166
165
  for (const name of chunkAsset)compilation.updateAsset(name, (old)=>{
167
166
  const oldSource = old.source().toString();
168
- const replaceSource = new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.sources.ReplaceSource(old);
167
+ const replaceSource = new __rspack_external__rsbuild_core_1b356efc.rspack.sources.ReplaceSource(old);
169
168
  function replace(searchValue, replaceValue) {
170
169
  let start = oldSource.indexOf(searchValue);
171
170
  while(-1 !== start){
@@ -265,19 +264,8 @@ const IMPORT_META_URL_SHIM = `const __rslib_import_meta_url__ = /*#__PURE__*/ (f
265
264
  new URL('main.js', document.baseURI).href;
266
265
  })();
267
266
  `;
268
- const matchFirstLine = (source, regex)=>{
269
- const lineBreakPos = source.match(/(\r\n|\n)/);
270
- const firstLineContent = source.slice(0, lineBreakPos?.index);
271
- const matched = regex.exec(firstLineContent);
272
- if (!matched) return false;
273
- return matched[0];
274
- };
275
267
  class EntryChunkPlugin {
276
- reactDirectives = {};
277
268
  shimsInjectedAssets = new Set();
278
- shebangChmod = 493;
279
- shebangEntries = {};
280
- shebangInjectedAssets = new Set();
281
269
  enabledImportMetaUrlShim;
282
270
  contextToWatch = null;
283
271
  constructor({ enabledImportMetaUrlShim = true, contextToWatch }){
@@ -291,39 +279,10 @@ class EntryChunkPlugin {
291
279
  if (!contextDep.has(this.contextToWatch)) contextDep.add(this.contextToWatch);
292
280
  });
293
281
  compiler.hooks.make.tap(EntryChunkPlugin_PLUGIN_NAME, (compilation)=>{
294
- const entries = {};
295
- for (const [key, value] of compilation.entries){
296
- const firstDep = value.dependencies[0];
297
- if (firstDep?.request) entries[key] = firstDep.request;
298
- }
299
- for(const name in entries){
300
- const first = entries[name];
301
- if (!first) continue;
302
- const filename = first.split('?')[0];
303
- const isJs = JS_EXTENSIONS_PATTERN.test(filename);
304
- if (!isJs) continue;
305
- const content = compiler.inputFileSystem.readFileSync(filename, {
306
- encoding: 'utf-8'
307
- });
308
- if (content.startsWith("#!")) {
309
- const shebangMatch = matchFirstLine(content, SHEBANG_REGEX);
310
- if (shebangMatch) this.shebangEntries[name] = shebangMatch;
311
- }
312
- const reactDirective = matchFirstLine(content, REACT_DIRECTIVE_REGEX);
313
- if (reactDirective) this.reactDirectives[name] = reactDirective;
314
- }
315
- });
316
- compiler.hooks.make.tap(EntryChunkPlugin_PLUGIN_NAME, (compilation)=>{
317
- compilation.hooks.chunkAsset.tap(EntryChunkPlugin_PLUGIN_NAME, (chunk, filename)=>{
282
+ compilation.hooks.chunkAsset.tap(EntryChunkPlugin_PLUGIN_NAME, (_chunk, filename)=>{
318
283
  const isJs = JS_EXTENSIONS_PATTERN.test(filename);
319
284
  if (!isJs) return;
320
285
  this.shimsInjectedAssets.add(filename);
321
- const name = chunk.name;
322
- if (!name) return;
323
- const shebangEntry = this.shebangEntries[name];
324
- if (shebangEntry) this.shebangEntries[filename] = shebangEntry;
325
- const reactDirective = this.reactDirectives[name];
326
- if (reactDirective) this.reactDirectives[filename] = reactDirective;
327
286
  });
328
287
  });
329
288
  compiler.hooks.make.tap(EntryChunkPlugin_PLUGIN_NAME, (compilation)=>{
@@ -332,34 +291,15 @@ class EntryChunkPlugin {
332
291
  const chunkAsset = Object.keys(assets).filter((name)=>JS_EXTENSIONS_PATTERN.test(name) && this.shimsInjectedAssets.has(name));
333
292
  for (const name of chunkAsset)compilation.updateAsset(name, (old)=>{
334
293
  const oldSource = old.source().toString();
335
- const replaceSource = new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.sources.ReplaceSource(old);
336
- if (oldSource.startsWith('use strict;') || oldSource.startsWith('"use strict";')) replaceSource.replace(0, 11, `"use strict";\n${IMPORT_META_URL_SHIM}`);
294
+ const replaceSource = new __rspack_external__rsbuild_core_1b356efc.rspack.sources.ReplaceSource(old);
295
+ if (oldSource.startsWith('#!')) {
296
+ const firstLineEnd = oldSource.indexOf('\n');
297
+ replaceSource.insert(firstLineEnd + 1, IMPORT_META_URL_SHIM);
298
+ } else if (oldSource.startsWith("'use strict'") || oldSource.startsWith('"use strict"')) replaceSource.replace(0, 11, `"use strict";\n${IMPORT_META_URL_SHIM}`);
337
299
  else replaceSource.insert(0, IMPORT_META_URL_SHIM);
338
300
  return replaceSource;
339
301
  });
340
302
  });
341
- compilation.hooks.processAssets.tap({
342
- name: EntryChunkPlugin_PLUGIN_NAME,
343
- stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING - 1
344
- }, (assets)=>{
345
- const chunkAsset = Object.keys(assets);
346
- for (const name of chunkAsset){
347
- const shebangValue = this.shebangEntries[name];
348
- const reactDirectiveValue = this.reactDirectives[name];
349
- if (shebangValue || reactDirectiveValue) compilation.updateAsset(name, (old)=>{
350
- const replaceSource = new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.sources.ReplaceSource(old);
351
- if (shebangValue) {
352
- replaceSource.insert(0, `${shebangValue}\n`);
353
- this.shebangInjectedAssets.add(name);
354
- }
355
- if (reactDirectiveValue) replaceSource.insert(0, `${reactDirectiveValue}\n`);
356
- return replaceSource;
357
- });
358
- }
359
- });
360
- });
361
- compiler.hooks.assetEmitted.tap(EntryChunkPlugin_PLUGIN_NAME, (file, { targetPath })=>{
362
- if (this.shebangInjectedAssets.has(file)) chmodSync(targetPath, this.shebangChmod);
363
303
  });
364
304
  }
365
305
  }
@@ -371,10 +311,10 @@ const entryModuleLoaderRsbuildPlugin = ()=>({
371
311
  });
372
312
  }
373
313
  });
374
- const composeEntryChunkConfig = ({ enabledImportMetaUrlShim, contextToWatch = null })=>({
375
- plugins: [
314
+ const composeEntryChunkConfig = ({ enabledImportMetaUrlShim, useLoader, contextToWatch = null })=>({
315
+ plugins: useLoader ? [
376
316
  entryModuleLoaderRsbuildPlugin()
377
- ],
317
+ ] : [],
378
318
  tools: {
379
319
  rspack: {
380
320
  plugins: [
@@ -406,9 +346,9 @@ const pluginEsmRequireShim = ()=>({
406
346
  setup (api) {
407
347
  api.modifyRspackConfig((config)=>{
408
348
  config.plugins ??= [];
409
- config.plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
349
+ config.plugins.push(new __rspack_external__rsbuild_core_1b356efc.rspack.BannerPlugin({
410
350
  banner: requireShim,
411
- stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE - 1,
351
+ stage: __rspack_external__rsbuild_core_1b356efc.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE - 1,
412
352
  raw: true,
413
353
  include: /\.(js|mjs)$/
414
354
  }));
@@ -1289,7 +1229,7 @@ async function loadConfig({ cwd = process.cwd(), path, envMode, loader }) {
1289
1229
  },
1290
1230
  filePath: void 0
1291
1231
  };
1292
- const { content } = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.loadConfig)({
1232
+ const { content } = await (0, __rspack_external__rsbuild_core_1b356efc.loadConfig)({
1293
1233
  cwd: dirname(configFilePath),
1294
1234
  path: configFilePath,
1295
1235
  envMode,
@@ -1424,6 +1364,7 @@ function composeMinifyConfig(config) {
1424
1364
  mangle: false,
1425
1365
  minify: 'mf' === format,
1426
1366
  compress: {
1367
+ directives: false,
1427
1368
  defaults: false,
1428
1369
  unused: true,
1429
1370
  dead_code: true,
@@ -1451,30 +1392,30 @@ function composeBannerFooterConfig(banner, footer) {
1451
1392
  if (isEmptyObject(bannerConfig) && isEmptyObject(footerConfig)) return {};
1452
1393
  const plugins = [];
1453
1394
  if (!isEmptyObject(bannerConfig)) {
1454
- if (bannerConfig.js) plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
1395
+ if (bannerConfig.js) plugins.push(new __rspack_external__rsbuild_core_1b356efc.rspack.BannerPlugin({
1455
1396
  banner: bannerConfig.js,
1456
- stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
1397
+ stage: __rspack_external__rsbuild_core_1b356efc.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
1457
1398
  raw: true,
1458
1399
  include: /\.(js|mjs|cjs)$/
1459
1400
  }));
1460
- if (bannerConfig.css) plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
1401
+ if (bannerConfig.css) plugins.push(new __rspack_external__rsbuild_core_1b356efc.rspack.BannerPlugin({
1461
1402
  banner: bannerConfig.css,
1462
- stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
1403
+ stage: __rspack_external__rsbuild_core_1b356efc.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
1463
1404
  raw: true,
1464
1405
  include: /\.(css)$/
1465
1406
  }));
1466
1407
  }
1467
1408
  if (!isEmptyObject(footerConfig)) {
1468
- if (footerConfig.js) plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
1409
+ if (footerConfig.js) plugins.push(new __rspack_external__rsbuild_core_1b356efc.rspack.BannerPlugin({
1469
1410
  banner: footerConfig.js,
1470
- stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
1411
+ stage: __rspack_external__rsbuild_core_1b356efc.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
1471
1412
  raw: true,
1472
1413
  footer: true,
1473
1414
  include: /\.(js|mjs|cjs)$/
1474
1415
  }));
1475
- if (footerConfig.css) plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
1416
+ if (footerConfig.css) plugins.push(new __rspack_external__rsbuild_core_1b356efc.rspack.BannerPlugin({
1476
1417
  banner: footerConfig.css,
1477
- stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
1418
+ stage: __rspack_external__rsbuild_core_1b356efc.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE + 1,
1478
1419
  raw: true,
1479
1420
  footer: true,
1480
1421
  include: /\.(css)$/
@@ -1516,7 +1457,7 @@ function composePrintFileSizeConfig(bundle, target) {
1516
1457
  };
1517
1458
  }
1518
1459
  async function createConstantRsbuildConfig() {
1519
- return (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.defineConfig)({
1460
+ return (0, __rspack_external__rsbuild_core_1b356efc.defineConfig)({
1520
1461
  performance: {
1521
1462
  chunkSplit: {
1522
1463
  strategy: 'custom'
@@ -1592,11 +1533,11 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson, enabledS
1592
1533
  };
1593
1534
  const experimentalEsmOutput = bundle && 'esm' === format && advancedEsm;
1594
1535
  const plugins = [
1595
- new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.experiments.RslibPlugin({
1536
+ new __rspack_external__rsbuild_core_1b356efc.rspack.experiments.RslibPlugin({
1596
1537
  interceptApiPlugin: true,
1597
1538
  forceNodeShims: enabledShims.esm.__dirname || enabledShims.esm.__filename
1598
1539
  }),
1599
- experimentalEsmOutput && new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.experiments.EsmLibraryPlugin()
1540
+ experimentalEsmOutput && new __rspack_external__rsbuild_core_1b356efc.rspack.experiments.EsmLibraryPlugin()
1600
1541
  ].filter(Boolean);
1601
1542
  switch(format){
1602
1543
  case 'esm':
@@ -1969,7 +1910,7 @@ const composeOutputFilenameConfig = (config, format, autoExtension, multiCompile
1969
1910
  }
1970
1911
  }
1971
1912
  };
1972
- const finalConfig = userJsFilename ? chunkFilename : (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(chunkFilename, {
1913
+ const finalConfig = userJsFilename ? chunkFilename : (0, __rspack_external__rsbuild_core_1b356efc.mergeRsbuildConfig)(chunkFilename, {
1973
1914
  output: {
1974
1915
  filename: {
1975
1916
  js: defaultJsFilename
@@ -2074,7 +2015,11 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOu
2074
2015
  dot: true
2075
2016
  });
2076
2017
  const resolvedEntryFiles = globEntryFiles.filter((i)=>!DTS_EXTENSIONS_PATTERN.test(i));
2077
- if (0 === resolvedEntryFiles.length) throw new Error(`Cannot find ${resolvedEntryFiles}`);
2018
+ if (0 === resolvedEntryFiles.length) {
2019
+ const error = new Error(`No entry files matching ${entryFiles.map((file)=>picocolors.cyan(file)).join(', ')}. Please ensure the entry pattern in ${picocolors.cyan('source.entry')} is correct and points to valid source files.`);
2020
+ error.stack = '';
2021
+ throw error;
2022
+ }
2078
2023
  const outBase = await resolveOutBase(resolvedEntryFiles);
2079
2024
  function getEntryName(file) {
2080
2025
  const { dir, name } = node_path.parse(node_path.relative(outBase, file));
@@ -2321,6 +2266,7 @@ async function composeLibRsbuildConfig(config, multiCompilerIndex, root, sharedP
2321
2266
  const cssConfig = composeCssConfig(outBase, cssModulesAuto, config.bundle, banner?.css, footer?.css);
2322
2267
  const assetConfig = composeAssetConfig(bundle, format);
2323
2268
  const entryChunkConfig = composeEntryChunkConfig({
2269
+ useLoader: true !== advancedEsm && ('esm' === format || 'iife' === format),
2324
2270
  enabledImportMetaUrlShim: enabledShims.cjs['import.meta.url'],
2325
2271
  contextToWatch: outBase
2326
2272
  });
@@ -2330,7 +2276,7 @@ async function composeLibRsbuildConfig(config, multiCompilerIndex, root, sharedP
2330
2276
  const bannerFooterConfig = composeBannerFooterConfig(banner, footer);
2331
2277
  const decoratorsConfig = composeDecoratorsConfig(compilerOptions, config.source?.decorators?.version);
2332
2278
  const printFileSizeConfig = composePrintFileSizeConfig(bundle, target);
2333
- return (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(bundleConfig, formatConfig, shimsConfig, syntaxConfig, externalHelpersConfig, outputFilenameConfig, targetConfig, externalsWarnConfig, userExternalsConfig, autoExternalConfig, targetExternalsConfig, bundlelessExternalConfig, entryConfig, cssConfig, assetConfig, entryChunkConfig, minifyConfig, dtsConfig, bannerFooterConfig, decoratorsConfig, printFileSizeConfig);
2279
+ return (0, __rspack_external__rsbuild_core_1b356efc.mergeRsbuildConfig)(bundleConfig, formatConfig, shimsConfig, syntaxConfig, externalHelpersConfig, outputFilenameConfig, targetConfig, externalsWarnConfig, userExternalsConfig, autoExternalConfig, targetExternalsConfig, bundlelessExternalConfig, entryConfig, cssConfig, assetConfig, entryChunkConfig, minifyConfig, dtsConfig, bannerFooterConfig, decoratorsConfig, printFileSizeConfig);
2334
2280
  }
2335
2281
  async function composeCreateRsbuildConfig(rslibConfig) {
2336
2282
  const constantRsbuildConfig = await createConstantRsbuildConfig();
@@ -2338,7 +2284,7 @@ async function composeCreateRsbuildConfig(rslibConfig) {
2338
2284
  if (logLevel && !isDebug()) logger.level = logLevel;
2339
2285
  if (!Array.isArray(libConfigsArray) || 0 === libConfigsArray.length) throw new Error(`Expect "lib" field to be a non-empty array, but got: ${picocolors.cyan(JSON.stringify(libConfigsArray))}.`);
2340
2286
  const libConfigPromises = libConfigsArray.map(async (libConfig, index)=>{
2341
- const userConfig = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(sharedRsbuildConfig, libConfig);
2287
+ const userConfig = (0, __rspack_external__rsbuild_core_1b356efc.mergeRsbuildConfig)(sharedRsbuildConfig, libConfig);
2342
2288
  const libRsbuildConfig = await composeLibRsbuildConfig(userConfig, libConfigsArray.length > 1 ? index : null, root, sharedPlugins);
2343
2289
  userConfig.source ??= {};
2344
2290
  userConfig.source.entry = {};
@@ -2346,7 +2292,7 @@ async function composeCreateRsbuildConfig(rslibConfig) {
2346
2292
  delete userConfig.output.externals;
2347
2293
  const config = {
2348
2294
  format: libConfig.format ?? 'esm',
2349
- config: (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(constantRsbuildConfig, libRsbuildConfig, omit(userConfig, {
2295
+ config: (0, __rspack_external__rsbuild_core_1b356efc.mergeRsbuildConfig)(constantRsbuildConfig, libRsbuildConfig, omit(userConfig, {
2350
2296
  id: true,
2351
2297
  bundle: true,
2352
2298
  format: true,
@@ -2445,7 +2391,7 @@ const beforeRestart = async ({ filePath, clear = true } = {})=>{
2445
2391
  };
2446
2392
  async function build(config, options = {}) {
2447
2393
  const { environments } = await composeRsbuildEnvironments(config);
2448
- const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.createRsbuild)({
2394
+ const rsbuildInstance = await (0, __rspack_external__rsbuild_core_1b356efc.createRsbuild)({
2449
2395
  callerName: 'rslib',
2450
2396
  config: {
2451
2397
  mode: 'production',
@@ -3026,7 +2972,7 @@ const applyCliOptions = (config, options, root)=>{
3026
2972
  async function initConfig(options) {
3027
2973
  const cwd = process.cwd();
3028
2974
  const root = options.root ? getAbsolutePath(cwd, options.root) : cwd;
3029
- const envs = (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.loadEnv)({
2975
+ const envs = (0, __rspack_external__rsbuild_core_1b356efc.loadEnv)({
3030
2976
  cwd: getEnvDir(root, options.envDir),
3031
2977
  mode: options.envMode
3032
2978
  });
@@ -3069,7 +3015,7 @@ async function initConfig(options) {
3069
3015
  }
3070
3016
  async function inspect(config, options = {}) {
3071
3017
  const { environments } = await composeRsbuildEnvironments(config);
3072
- const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.createRsbuild)({
3018
+ const rsbuildInstance = await (0, __rspack_external__rsbuild_core_1b356efc.createRsbuild)({
3073
3019
  callerName: 'rslib',
3074
3020
  config: {
3075
3021
  mode: 'production',
@@ -3105,7 +3051,7 @@ async function initMFRsbuild(config, options = {}) {
3105
3051
  }).map((env)=>env.id);
3106
3052
  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.`);
3107
3053
  const selectedEnvironments = pruneEnvironments(environments, selectedEnvironmentIds);
3108
- const rsbuildInstance = await (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.createRsbuild)({
3054
+ const rsbuildInstance = await (0, __rspack_external__rsbuild_core_1b356efc.createRsbuild)({
3109
3055
  callerName: 'rslib',
3110
3056
  config: {
3111
3057
  mode: 'development',
@@ -3133,7 +3079,7 @@ const applyCommonOptions = (cli)=>{
3133
3079
  };
3134
3080
  function runCli() {
3135
3081
  const cli = dist('rslib');
3136
- cli.version("0.18.0");
3082
+ cli.version("0.18.2");
3137
3083
  applyCommonOptions(cli);
3138
3084
  const buildDescription = `build the library for production ${picocolors.dim('(default if no command is given)')}`;
3139
3085
  const buildCommand = cli.command('', buildDescription).alias('build');
@@ -3249,9 +3195,9 @@ function prepareCli() {
3249
3195
  setupLogLevel();
3250
3196
  const { npm_execpath } = process.env;
3251
3197
  if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) logger.log();
3252
- logger.greet(` Rslib v0.18.0\n`);
3198
+ logger.greet(` Rslib v0.18.2\n`);
3253
3199
  }
3254
- const src_version = "0.18.0";
3200
+ const src_version = "0.18.2";
3255
3201
  export * as rsbuild from "@rsbuild/core";
3256
3202
  export { logger } from "../compiled/rslog/index.js";
3257
3203
  export { rspack } from "@rsbuild/core";
@@ -1,9 +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 SHEBANG_PREFIX = "#!";
5
- export declare const SHEBANG_REGEX: RegExp;
6
- export declare const REACT_DIRECTIVE_REGEX: RegExp;
7
4
  export declare const JS_EXTENSIONS_PATTERN: RegExp;
8
5
  export declare const CSS_EXTENSIONS_PATTERN: RegExp;
9
6
  export declare const DTS_EXTENSIONS_PATTERN: RegExp;
@@ -1,5 +1,6 @@
1
1
  import { type EnvironmentConfig } from '@rsbuild/core';
2
- export declare const composeEntryChunkConfig: ({ enabledImportMetaUrlShim, contextToWatch, }: {
2
+ export declare const composeEntryChunkConfig: ({ enabledImportMetaUrlShim, useLoader, contextToWatch, }: {
3
+ useLoader: boolean;
3
4
  enabledImportMetaUrlShim: boolean;
4
5
  contextToWatch: string | null;
5
6
  }) => EnvironmentConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rslib/core",
3
- "version": "0.18.0",
3
+ "version": "0.18.2",
4
4
  "description": "The Rsbuild-based library development tool.",
5
5
  "homepage": "https://rslib.rs",
6
6
  "bugs": {
@@ -36,11 +36,11 @@
36
36
  "types.d.ts"
37
37
  ],
38
38
  "dependencies": {
39
- "@rsbuild/core": "~1.6.6",
40
- "rsbuild-plugin-dts": "0.18.0"
39
+ "@rsbuild/core": "~1.6.9",
40
+ "rsbuild-plugin-dts": "0.18.2"
41
41
  },
42
42
  "devDependencies": {
43
- "@module-federation/rsbuild-plugin": "^0.21.4",
43
+ "@module-federation/rsbuild-plugin": "^0.21.6",
44
44
  "@types/fs-extra": "^11.0.4",
45
45
  "cac": "^6.7.14",
46
46
  "chokidar": "^4.0.3",
@@ -48,9 +48,9 @@
48
48
  "memfs": "^4.51.0",
49
49
  "path-serializer": "0.5.1",
50
50
  "picocolors": "1.1.1",
51
- "prebundle": "1.5.0",
51
+ "prebundle": "1.6.0",
52
52
  "rsbuild-plugin-publint": "^0.3.3",
53
- "rslib": "npm:@rslib/core@0.17.2",
53
+ "rslib": "npm:@rslib/core@0.18.0",
54
54
  "rslog": "^1.3.0",
55
55
  "tinyglobby": "0.2.14",
56
56
  "tsconfck": "3.1.6",
package/dist/121.js DELETED
@@ -1,43 +0,0 @@
1
- const DEFAULT_CONFIG_NAME = 'rslib.config';
2
- const DEFAULT_CONFIG_EXTENSIONS = [
3
- '.js',
4
- '.ts',
5
- '.mjs',
6
- '.mts',
7
- '.cjs',
8
- '.cts'
9
- ];
10
- const SWC_HELPERS = '@swc/helpers';
11
- const SHEBANG_REGEX = /#!.*[\s\n\r]*$/;
12
- const REACT_DIRECTIVE_REGEX = /^['"]use (client|server)['"](;?)[\s\n\r]*$/;
13
- const DTS_EXTENSIONS = [
14
- 'd.ts',
15
- 'd.mts',
16
- 'd.cts'
17
- ];
18
- const JS_EXTENSIONS = [
19
- 'js',
20
- 'mjs',
21
- 'jsx',
22
- '(?<!\\.d\\.)ts',
23
- '(?<!\\.d\\.)mts',
24
- '(?<!\\.d\\.)cts',
25
- 'tsx',
26
- 'cjs',
27
- 'cjsx',
28
- 'mjsx',
29
- 'mtsx',
30
- 'ctsx'
31
- ];
32
- const CSS_EXTENSIONS = [
33
- 'css',
34
- 'sass',
35
- 'scss',
36
- 'less',
37
- 'styl',
38
- 'stylus'
39
- ];
40
- const JS_EXTENSIONS_PATTERN = new RegExp(`\\.(${JS_EXTENSIONS.join('|')})$`);
41
- const CSS_EXTENSIONS_PATTERN = new RegExp(`\\.(${CSS_EXTENSIONS.join('|')})$`);
42
- const DTS_EXTENSIONS_PATTERN = new RegExp(`\\.(${DTS_EXTENSIONS.join('|')})$`);
43
- export { CSS_EXTENSIONS_PATTERN, DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME, DTS_EXTENSIONS_PATTERN, JS_EXTENSIONS_PATTERN, REACT_DIRECTIVE_REGEX, SHEBANG_REGEX, SWC_HELPERS };