@rslib/core 0.10.5 → 0.11.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.
package/dist/index.js CHANGED
@@ -276,12 +276,11 @@ class LibCssExtractPlugin {
276
276
  }
277
277
  const cssConfig_require = createRequire(import.meta.url);
278
278
  const RSLIB_CSS_ENTRY_FLAG = '__rslib_css__';
279
- async function cssExternalHandler(request, callback, jsExtension, auto, styleRedirectPath, styleRedirectExtension, redirectPath, issuer) {
279
+ async function cssExternalHandler(request, callback, jsExtension, auto, styleRedirectPath, styleRedirectExtension, redirectedPath, issuer) {
280
280
  if (/compiled\/css-loader\//.test(request)) return callback();
281
281
  let resolvedRequest = request;
282
282
  if (styleRedirectPath) {
283
- const redirectedPath = await redirectPath(resolvedRequest);
284
- if (void 0 === redirectedPath) return callback(void 0, request);
283
+ if (void 0 === redirectedPath) return false;
285
284
  resolvedRequest = redirectedPath;
286
285
  }
287
286
  if (!isCssFile(resolvedRequest)) {
@@ -2097,7 +2096,8 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
2097
2096
  const styleRedirectExtension = redirect.style?.extension ?? true;
2098
2097
  const jsRedirectPath = redirect.js?.path ?? true;
2099
2098
  const jsRedirectExtension = redirect.js?.extension ?? true;
2100
- const assetRedirect = redirect.asset ?? true;
2099
+ const assetRedirectPath = redirect.asset?.path ?? true;
2100
+ const assetRedirectExtension = redirect.asset?.extension ?? true;
2101
2101
  let resolver;
2102
2102
  return {
2103
2103
  resolvedJsRedirect: {
@@ -2131,20 +2131,20 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
2131
2131
  }
2132
2132
  if (issuer) {
2133
2133
  let resolvedRequest = request;
2134
- const cssExternal = await cssExternalHandler(resolvedRequest, callback, jsExtension, cssModulesAuto, styleRedirectPath, styleRedirectExtension, redirectPath, issuer);
2134
+ const redirectedPath = await redirectPath(resolvedRequest);
2135
+ const cssExternal = await cssExternalHandler(resolvedRequest, callback, jsExtension, cssModulesAuto, styleRedirectPath, styleRedirectExtension, redirectedPath, issuer);
2135
2136
  if (false !== cssExternal) return cssExternal;
2136
- if (jsRedirectPath) {
2137
- const redirectedPath = await redirectPath(resolvedRequest);
2138
- if (void 0 === redirectedPath) return callback(void 0, request);
2139
- resolvedRequest = redirectedPath;
2140
- }
2137
+ if (void 0 === redirectedPath) return callback(void 0, request);
2138
+ if (jsRedirectPath) resolvedRequest = redirectedPath;
2141
2139
  if (resolvedRequest.startsWith('.')) {
2142
2140
  const ext = extname(resolvedRequest);
2143
- if (ext) {
2144
- if (JS_EXTENSIONS_PATTERN.test(resolvedRequest)) {
2145
- if (jsRedirectExtension) resolvedRequest = resolvedRequest.replace(/\.[^.]+$/, jsExtension);
2146
- } else if (assetRedirect) resolvedRequest = resolvedRequest.replace(/\.[^.]+$/, jsExtension);
2147
- } else if (jsRedirectExtension) resolvedRequest = `${resolvedRequest}${jsExtension}`;
2141
+ if (ext) if (JS_EXTENSIONS_PATTERN.test(resolvedRequest)) {
2142
+ if (jsRedirectExtension) resolvedRequest = resolvedRequest.replace(/\.[^.]+$/, jsExtension);
2143
+ } else {
2144
+ resolvedRequest = assetRedirectPath ? redirectedPath : request;
2145
+ if (assetRedirectExtension) resolvedRequest = resolvedRequest.replace(/\.[^.]+$/, jsExtension);
2146
+ }
2147
+ else if (jsRedirectExtension) resolvedRequest = `${resolvedRequest}${jsExtension}`;
2148
2148
  }
2149
2149
  return callback(void 0, resolvedRequest);
2150
2150
  }
@@ -2996,7 +2996,7 @@ const applyCommonOptions = (cli)=>{
2996
2996
  function runCli() {
2997
2997
  const cli = dist('rslib');
2998
2998
  cli.help();
2999
- cli.version("0.10.5");
2999
+ cli.version("0.11.0");
3000
3000
  applyCommonOptions(cli);
3001
3001
  const buildCommand = cli.command('build', 'build the library for production');
3002
3002
  const inspectCommand = cli.command('inspect', 'inspect the Rsbuild / Rspack configs of Rslib projects');
@@ -3067,8 +3067,8 @@ function prepareCli() {
3067
3067
  initNodeEnv();
3068
3068
  const { npm_execpath } = process.env;
3069
3069
  if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
3070
- logger.greet(` Rslib v0.10.5\n`);
3070
+ logger.greet(` Rslib v0.11.0\n`);
3071
3071
  }
3072
- const src_version = "0.10.5";
3072
+ const src_version = "0.11.0";
3073
3073
  var __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack;
3074
3074
  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 };
@@ -2,6 +2,6 @@ import type { EnvironmentConfig } from '@rsbuild/core';
2
2
  import { type CssLoaderOptionsAuto } from './utils';
3
3
  export declare const RSLIB_CSS_ENTRY_FLAG = "__rslib_css__";
4
4
  type ExternalCallback = (arg0?: undefined, arg1?: string) => void;
5
- 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>;
5
+ export declare function cssExternalHandler(request: string, callback: ExternalCallback, jsExtension: string, auto: CssLoaderOptionsAuto, styleRedirectPath: boolean, styleRedirectExtension: boolean, redirectedPath: string | undefined, issuer: string): Promise<false | void>;
6
6
  export declare const composeCssConfig: (rootDir: string | null, auto: CssLoaderOptionsAuto, bundle?: boolean, banner?: string, footer?: string) => EnvironmentConfig;
7
7
  export {};
@@ -146,6 +146,18 @@ export type StyleRedirect = {
146
146
  */
147
147
  extension?: boolean;
148
148
  };
149
+ export type AssetRedirect = {
150
+ /**
151
+ * Whether to automatically redirect the import paths of asset output files.
152
+ * @defaultValue `true`
153
+ */
154
+ path?: boolean;
155
+ /**
156
+ * Whether to automatically redirect the file extension to import paths based on the asset output files.
157
+ * @defaultValue `true`
158
+ */
159
+ extension?: boolean;
160
+ };
149
161
  export type DtsRedirect = {
150
162
  /**
151
163
  * Whether to automatically redirect the import paths of TypeScript declaration output files.
@@ -164,7 +176,7 @@ export type Redirect = {
164
176
  /** Controls the redirect of the import paths of output style files. */
165
177
  style?: StyleRedirect;
166
178
  /** Controls the redirect of the import paths of output asset files. */
167
- asset?: boolean;
179
+ asset?: AssetRedirect;
168
180
  /** Controls the redirect of the import paths of output TypeScript declaration files. */
169
181
  dts?: DtsRedirect;
170
182
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rslib/core",
3
- "version": "0.10.5",
3
+ "version": "0.11.0",
4
4
  "description": "The Rsbuild-based library development tool.",
5
5
  "homepage": "https://rslib.rs",
6
6
  "bugs": {
@@ -36,12 +36,12 @@
36
36
  "types.d.ts"
37
37
  ],
38
38
  "dependencies": {
39
- "@rsbuild/core": "~1.4.3",
39
+ "@rsbuild/core": "~1.4.8",
40
40
  "tinyglobby": "^0.2.14",
41
- "rsbuild-plugin-dts": "0.10.5"
41
+ "rsbuild-plugin-dts": "0.11.0"
42
42
  },
43
43
  "devDependencies": {
44
- "@module-federation/rsbuild-plugin": "^0.16.0",
44
+ "@module-federation/rsbuild-plugin": "^0.17.0",
45
45
  "@types/fs-extra": "^11.0.4",
46
46
  "cac": "^6.7.14",
47
47
  "chokidar": "^4.0.3",
@@ -50,7 +50,7 @@
50
50
  "picocolors": "1.1.1",
51
51
  "prebundle": "1.3.4",
52
52
  "rsbuild-plugin-publint": "^0.3.2",
53
- "rslib": "npm:@rslib/core@0.10.4",
53
+ "rslib": "npm:@rslib/core@0.10.6",
54
54
  "rslog": "^1.2.9",
55
55
  "tsconfck": "3.1.6",
56
56
  "typescript": "^5.8.3",