@rslib/core 0.12.3 → 0.12.4

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/index.js CHANGED
@@ -696,6 +696,14 @@ const windowsSlashRegex = /\\/g;
696
696
  function normalizeSlash(p) {
697
697
  return p.replace(windowsSlashRegex, '/');
698
698
  }
699
+ async function isDirectory(filePath) {
700
+ try {
701
+ const stat = await node_fs_promises.stat(filePath);
702
+ return stat.isDirectory();
703
+ } catch {
704
+ return false;
705
+ }
706
+ }
699
707
  const LATEST_TARGET_VERSIONS = {
700
708
  node: [
701
709
  'last 1 node versions'
@@ -1775,7 +1783,10 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
1775
1783
  }
1776
1784
  },
1777
1785
  optimization: {
1778
- nodeEnv: process.env.NODE_ENV
1786
+ nodeEnv: process.env.NODE_ENV,
1787
+ splitChunks: {
1788
+ chunks: 'async'
1789
+ }
1779
1790
  },
1780
1791
  plugins
1781
1792
  }
@@ -1858,6 +1869,14 @@ const disableUrlParseRsbuildPlugin = ()=>({
1858
1869
  });
1859
1870
  }
1860
1871
  });
1872
+ const fixJsModuleTypePlugin = ()=>({
1873
+ name: 'rsbuild:fix-js-module-type',
1874
+ setup (api) {
1875
+ api.modifyBundlerChain((config, { CHAIN_ID })=>{
1876
+ config.module.rule(CHAIN_ID.RULE.JS).delete('type');
1877
+ });
1878
+ }
1879
+ });
1861
1880
  const composeShimsConfig = (format, shims)=>{
1862
1881
  const resolvedShims = {
1863
1882
  cjs: {
@@ -1893,7 +1912,8 @@ const composeShimsConfig = (format, shims)=>{
1893
1912
  },
1894
1913
  plugins: [
1895
1914
  resolvedShims.esm.require && pluginEsmRequireShim(),
1896
- disableUrlParseRsbuildPlugin()
1915
+ disableUrlParseRsbuildPlugin(),
1916
+ fixJsModuleTypePlugin()
1897
1917
  ].filter(Boolean)
1898
1918
  };
1899
1919
  break;
@@ -1901,13 +1921,19 @@ const composeShimsConfig = (format, shims)=>{
1901
1921
  rsbuildConfig = {
1902
1922
  plugins: [
1903
1923
  resolvedShims.cjs['import.meta.url'] && pluginCjsImportMetaUrlShim(),
1904
- disableUrlParseRsbuildPlugin()
1924
+ disableUrlParseRsbuildPlugin(),
1925
+ fixJsModuleTypePlugin()
1905
1926
  ].filter(Boolean)
1906
1927
  };
1907
1928
  break;
1908
1929
  case 'umd':
1909
1930
  case 'iife':
1910
1931
  case 'mf':
1932
+ rsbuildConfig = {
1933
+ plugins: [
1934
+ fixJsModuleTypePlugin()
1935
+ ]
1936
+ };
1911
1937
  break;
1912
1938
  default:
1913
1939
  throw new Error(`Unsupported format: ${format}`);
@@ -2075,7 +2101,8 @@ const composeEntryConfig = async (rawEntry, bundle, root, cssModulesAuto, userOu
2075
2101
  if (!entryFiles) throw new Error('Entry can only be a string or an array of strings for now');
2076
2102
  const globEntryFiles = await glob(entryFiles, {
2077
2103
  cwd: root,
2078
- absolute: true
2104
+ absolute: true,
2105
+ dot: true
2079
2106
  });
2080
2107
  const resolvedEntryFiles = globEntryFiles.filter((i)=>!DTS_EXTENSIONS_PATTERN.test(i));
2081
2108
  if (0 === resolvedEntryFiles.length) throw new Error(`Cannot find ${resolvedEntryFiles}`);
@@ -2152,7 +2179,7 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
2152
2179
  const isSubpath = normalizeSlash(resolvedRequest).startsWith(`${normalizeSlash(outBase)}/`);
2153
2180
  if (isSubpath) {
2154
2181
  resolvedRequest = normalizeSlash(node_path.relative(node_path.dirname(issuer), resolvedRequest));
2155
- if ('.' !== resolvedRequest[0]) resolvedRequest = `./${resolvedRequest}`;
2182
+ if (!resolvedRequest.startsWith('./') && !resolvedRequest.startsWith('../')) resolvedRequest = `./${resolvedRequest}`;
2156
2183
  return resolvedRequest;
2157
2184
  }
2158
2185
  return;
@@ -2176,7 +2203,10 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
2176
2203
  resolvedRequest = assetRedirectPath ? redirectedPath : request;
2177
2204
  if (assetRedirectExtension) resolvedRequest = resolvedRequest.replace(/\.[^.]+$/, jsExtension);
2178
2205
  }
2179
- else if (jsRedirectExtension) resolvedRequest = `${resolvedRequest}${jsExtension}`;
2206
+ else if (jsRedirectExtension) {
2207
+ if (!jsRedirectPath && await isDirectory(join(dirname(issuer), resolvedRequest))) resolvedRequest = `${resolvedRequest.replace(/\/+$/, '')}/index`;
2208
+ resolvedRequest = `${resolvedRequest}${jsExtension}`;
2209
+ }
2180
2210
  }
2181
2211
  callback(void 0, resolvedRequest);
2182
2212
  return;
@@ -3031,7 +3061,7 @@ const applyCommonOptions = (cli)=>{
3031
3061
  function runCli() {
3032
3062
  const cli = dist('rslib');
3033
3063
  cli.help();
3034
- cli.version("0.12.3");
3064
+ cli.version("0.12.4");
3035
3065
  applyCommonOptions(cli);
3036
3066
  const buildCommand = cli.command('build', 'build the library for production');
3037
3067
  const inspectCommand = cli.command('inspect', 'inspect the Rsbuild / Rspack configs of Rslib projects');
@@ -3102,8 +3132,8 @@ function prepareCli() {
3102
3132
  initNodeEnv();
3103
3133
  const { npm_execpath } = process.env;
3104
3134
  if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
3105
- logger.greet(` Rslib v0.12.3\n`);
3135
+ logger.greet(` Rslib v0.12.4\n`);
3106
3136
  }
3107
- const src_version = "0.12.3";
3137
+ const src_version = "0.12.4";
3108
3138
  var __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack;
3109
3139
  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 };
@@ -21,3 +21,4 @@ export declare function debounce<T extends (...args: any[]) => void>(func: T, wa
21
21
  export declare const isTTY: (type?: "stdin" | "stdout") => boolean;
22
22
  export declare const isIntermediateOutputFormat: (format: Format) => boolean;
23
23
  export declare function normalizeSlash(p: string): string;
24
+ export declare function isDirectory(filePath: string): Promise<boolean>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rslib/core",
3
- "version": "0.12.3",
3
+ "version": "0.12.4",
4
4
  "description": "The Rsbuild-based library development tool.",
5
5
  "homepage": "https://rslib.rs",
6
6
  "bugs": {
@@ -36,9 +36,9 @@
36
36
  "types.d.ts"
37
37
  ],
38
38
  "dependencies": {
39
- "@rsbuild/core": "~1.5.0",
39
+ "@rsbuild/core": "~1.5.1",
40
40
  "tinyglobby": "^0.2.14",
41
- "rsbuild-plugin-dts": "0.12.3"
41
+ "rsbuild-plugin-dts": "0.12.4"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@module-federation/rsbuild-plugin": "^0.18.3",
@@ -46,11 +46,12 @@
46
46
  "cac": "^6.7.14",
47
47
  "chokidar": "^4.0.3",
48
48
  "fs-extra": "^11.3.1",
49
- "memfs": "^4.38.1",
49
+ "memfs": "^4.38.2",
50
+ "path-serializer": "0.5.1",
50
51
  "picocolors": "1.1.1",
51
52
  "prebundle": "1.4.1",
52
53
  "rsbuild-plugin-publint": "^0.3.3",
53
- "rslib": "npm:@rslib/core@0.12.2",
54
+ "rslib": "npm:@rslib/core@0.12.3",
54
55
  "rslog": "^1.2.11",
55
56
  "tsconfck": "3.1.6",
56
57
  "typescript": "^5.9.2",