@rslib/core 0.14.0 → 0.15.1

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.
Files changed (2) hide show
  1. package/dist/index.js +43 -8
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -18,7 +18,6 @@ const DEFAULT_CONFIG_EXTENSIONS = [
18
18
  '.cts'
19
19
  ];
20
20
  const SWC_HELPERS = '@swc/helpers';
21
- const SHEBANG_PREFIX = '#!';
22
21
  const SHEBANG_REGEX = /#!.*[\s\n\r]*$/;
23
22
  const REACT_DIRECTIVE_REGEX = /^['"]use (client|server)['"](;?)[\s\n\r]*$/;
24
23
  const DTS_EXTENSIONS = [
@@ -395,7 +394,7 @@ class EntryChunkPlugin {
395
394
  const content = compiler.inputFileSystem.readFileSync(filename, {
396
395
  encoding: 'utf-8'
397
396
  });
398
- if (content.startsWith(SHEBANG_PREFIX)) {
397
+ if (content.startsWith("#!")) {
399
398
  const shebangMatch = matchFirstLine(content, SHEBANG_REGEX);
400
399
  if (shebangMatch) this.shebangEntries[name] = shebangMatch;
401
400
  }
@@ -1521,6 +1520,7 @@ function composeMinifyConfig(config) {
1521
1520
  js: true,
1522
1521
  css: false,
1523
1522
  jsOptions: {
1523
+ test: /\.[cm]?jsx?(\?.*)?$/,
1524
1524
  minimizerOptions: {
1525
1525
  mangle: false,
1526
1526
  minify: 'mf' === format,
@@ -1682,7 +1682,10 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
1682
1682
  },
1683
1683
  esm: {
1684
1684
  importMeta: false,
1685
- importDynamic: false
1685
+ importDynamic: false,
1686
+ commonjs: {
1687
+ exports: 'skipInEsm'
1688
+ }
1686
1689
  },
1687
1690
  others: {
1688
1691
  worker: false
@@ -1879,6 +1882,34 @@ const fixJsModuleTypePlugin = ()=>({
1879
1882
  });
1880
1883
  }
1881
1884
  });
1885
+ const BundlePlugin = ()=>({
1886
+ name: 'rslib:bundle',
1887
+ setup (api) {
1888
+ api.onBeforeBuild({
1889
+ order: 'post',
1890
+ handler: ({ bundlerConfigs })=>{
1891
+ if (bundlerConfigs) {
1892
+ for (const config of bundlerConfigs)if (config?.module?.parser?.javascript?.jsx === true) {
1893
+ logger.error('Bundle mode does not support preserving JSX syntax. Set "bundle" to "false" or change the JSX runtime to `automatic` or `classic`. Check out ' + picocolors.green('https://rslib.rs/guide/solution/react#jsx-transform') + ' for more details.');
1894
+ process.exit(1);
1895
+ }
1896
+ }
1897
+ }
1898
+ });
1899
+ }
1900
+ });
1901
+ const composeBundleConfig = (bundle)=>{
1902
+ if (bundle) return {
1903
+ rsbuildConfig: {
1904
+ plugins: [
1905
+ BundlePlugin()
1906
+ ]
1907
+ }
1908
+ };
1909
+ return {
1910
+ rsbuildConfig: {}
1911
+ };
1912
+ };
1882
1913
  const composeShimsConfig = (format, shims)=>{
1883
1914
  const resolvedShims = {
1884
1915
  cjs: {
@@ -2344,6 +2375,7 @@ async function composeLibRsbuildConfig(config, multiCompilerIndex, root, sharedP
2344
2375
  const { compilerOptions } = await loadTsconfig(rootPath, config.source?.tsconfigPath);
2345
2376
  const cssModulesAuto = config.output?.cssModules?.auto ?? true;
2346
2377
  const { format = 'esm', shims, bundle = true, banner = {}, footer = {}, autoExtension = true, autoExternal, externalHelpers = false, redirect = {}, umdName } = config;
2378
+ const { rsbuildConfig: bundleConfig } = composeBundleConfig(bundle);
2347
2379
  const { rsbuildConfig: shimsConfig, enabledShims } = composeShimsConfig(format, shims);
2348
2380
  const formatConfig = composeFormatConfig({
2349
2381
  format,
@@ -2377,7 +2409,7 @@ async function composeLibRsbuildConfig(config, multiCompilerIndex, root, sharedP
2377
2409
  const bannerFooterConfig = composeBannerFooterConfig(banner, footer);
2378
2410
  const decoratorsConfig = composeDecoratorsConfig(compilerOptions, config.source?.decorators?.version);
2379
2411
  const printFileSizeConfig = composePrintFileSizeConfig(bundle, target);
2380
- return (0, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.mergeRsbuildConfig)(formatConfig, shimsConfig, syntaxConfig, externalHelpersConfig, outputFilenameConfig, targetConfig, externalsWarnConfig, userExternalsConfig, autoExternalConfig, targetExternalsConfig, bundlelessExternalConfig, entryConfig, cssConfig, assetConfig, entryChunkConfig, minifyConfig, dtsConfig, bannerFooterConfig, decoratorsConfig, printFileSizeConfig);
2412
+ 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);
2381
2413
  }
2382
2414
  async function composeCreateRsbuildConfig(rslibConfig) {
2383
2415
  const constantRsbuildConfig = await createConstantRsbuildConfig();
@@ -3047,7 +3079,10 @@ async function inspect(config, options = {}) {
3047
3079
  mode: options.mode,
3048
3080
  verbose: options.verbose,
3049
3081
  outputPath: options.output,
3050
- writeToDisk: true
3082
+ writeToDisk: true,
3083
+ extraConfigs: {
3084
+ rslib: config
3085
+ }
3051
3086
  });
3052
3087
  return rsbuildInstance;
3053
3088
  }
@@ -3093,7 +3128,7 @@ const applyCommonOptions = (cli)=>{
3093
3128
  function runCli() {
3094
3129
  const cli = dist('rslib');
3095
3130
  cli.help();
3096
- cli.version("0.14.0");
3131
+ cli.version("0.15.1");
3097
3132
  applyCommonOptions(cli);
3098
3133
  const buildCommand = cli.command('build', 'build the library for production');
3099
3134
  const inspectCommand = cli.command('inspect', 'inspect the Rsbuild / Rspack configs of Rslib projects');
@@ -3176,8 +3211,8 @@ function prepareCli() {
3176
3211
  setupLogLevel();
3177
3212
  const { npm_execpath } = process.env;
3178
3213
  if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) logger.log();
3179
- logger.greet(` Rslib v0.14.0\n`);
3214
+ logger.greet(` Rslib v0.15.1\n`);
3180
3215
  }
3181
- const src_version = "0.14.0";
3216
+ const src_version = "0.15.1";
3182
3217
  var __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack;
3183
3218
  export { build, defineConfig, inspect, loadConfig, logger, prepareCli, __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__ as rsbuild, runCli, startMFDevServer, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, src_version as version, __webpack_exports__rspack as rspack };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rslib/core",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
4
4
  "description": "The Rsbuild-based library development tool.",
5
5
  "homepage": "https://rslib.rs",
6
6
  "bugs": {
@@ -36,25 +36,25 @@
36
36
  "types.d.ts"
37
37
  ],
38
38
  "dependencies": {
39
- "@rsbuild/core": "~1.5.11",
40
- "rsbuild-plugin-dts": "0.14.0"
39
+ "@rsbuild/core": "~1.5.17",
40
+ "rsbuild-plugin-dts": "0.15.1"
41
41
  },
42
42
  "devDependencies": {
43
- "@module-federation/rsbuild-plugin": "^0.19.1",
43
+ "@module-federation/rsbuild-plugin": "^0.20.0",
44
44
  "@types/fs-extra": "^11.0.4",
45
45
  "cac": "^6.7.14",
46
46
  "chokidar": "^4.0.3",
47
47
  "fs-extra": "^11.3.2",
48
- "memfs": "^4.43.0",
48
+ "memfs": "^4.49.0",
49
49
  "path-serializer": "0.5.1",
50
50
  "picocolors": "1.1.1",
51
51
  "prebundle": "1.4.2",
52
52
  "rsbuild-plugin-publint": "^0.3.3",
53
- "rslib": "npm:@rslib/core@0.13.3",
53
+ "rslib": "npm:@rslib/core@0.15.0",
54
54
  "rslog": "^1.2.11",
55
55
  "tinyglobby": "0.2.14",
56
56
  "tsconfck": "3.1.6",
57
- "typescript": "^5.9.2",
57
+ "typescript": "^5.9.3",
58
58
  "@rslib/tsconfig": "0.0.1"
59
59
  },
60
60
  "peerDependencies": {