@rslib/core 0.10.6 → 0.11.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.
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)) {
@@ -1693,8 +1692,7 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
1693
1692
  type: 'modern-module'
1694
1693
  },
1695
1694
  chunkLoading: 'import',
1696
- workerChunkLoading: 'import',
1697
- wasmLoading: 'fetch'
1695
+ workerChunkLoading: 'import'
1698
1696
  },
1699
1697
  experiments: {
1700
1698
  outputModule: true
@@ -1723,8 +1721,7 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
1723
1721
  type: 'commonjs-static'
1724
1722
  },
1725
1723
  chunkLoading: 'require',
1726
- workerChunkLoading: 'async-node',
1727
- wasmLoading: 'async-node'
1724
+ workerChunkLoading: 'async-node'
1728
1725
  },
1729
1726
  plugins
1730
1727
  }
@@ -1765,6 +1762,15 @@ const composeFormatConfig = ({ format, bundle = true, umdName, pkgJson })=>{
1765
1762
  {
1766
1763
  if (false === bundle) throw new Error('When using "iife" format, "bundle" must be set to "true". Since the default value for "bundle" is "true", so you can either explicitly set it to "true" or remove the field entirely.');
1767
1764
  const config = {
1765
+ output: {
1766
+ minify: {
1767
+ jsOptions: {
1768
+ minimizerOptions: {
1769
+ module: true
1770
+ }
1771
+ }
1772
+ }
1773
+ },
1768
1774
  tools: {
1769
1775
  rspack: {
1770
1776
  module: {
@@ -2097,7 +2103,8 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
2097
2103
  const styleRedirectExtension = redirect.style?.extension ?? true;
2098
2104
  const jsRedirectPath = redirect.js?.path ?? true;
2099
2105
  const jsRedirectExtension = redirect.js?.extension ?? true;
2100
- const assetRedirect = redirect.asset ?? true;
2106
+ const assetRedirectPath = redirect.asset?.path ?? true;
2107
+ const assetRedirectExtension = redirect.asset?.extension ?? true;
2101
2108
  let resolver;
2102
2109
  return {
2103
2110
  resolvedJsRedirect: {
@@ -2131,20 +2138,20 @@ const composeBundlelessExternalConfig = (jsExtension, redirect, cssModulesAuto,
2131
2138
  }
2132
2139
  if (issuer) {
2133
2140
  let resolvedRequest = request;
2134
- const cssExternal = await cssExternalHandler(resolvedRequest, callback, jsExtension, cssModulesAuto, styleRedirectPath, styleRedirectExtension, redirectPath, issuer);
2141
+ const redirectedPath = await redirectPath(resolvedRequest);
2142
+ const cssExternal = await cssExternalHandler(resolvedRequest, callback, jsExtension, cssModulesAuto, styleRedirectPath, styleRedirectExtension, redirectedPath, issuer);
2135
2143
  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
- }
2144
+ if (void 0 === redirectedPath) return callback(void 0, request);
2145
+ if (jsRedirectPath) resolvedRequest = redirectedPath;
2141
2146
  if (resolvedRequest.startsWith('.')) {
2142
2147
  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}`;
2148
+ if (ext) if (JS_EXTENSIONS_PATTERN.test(resolvedRequest)) {
2149
+ if (jsRedirectExtension) resolvedRequest = resolvedRequest.replace(/\.[^.]+$/, jsExtension);
2150
+ } else {
2151
+ resolvedRequest = assetRedirectPath ? redirectedPath : request;
2152
+ if (assetRedirectExtension) resolvedRequest = resolvedRequest.replace(/\.[^.]+$/, jsExtension);
2153
+ }
2154
+ else if (jsRedirectExtension) resolvedRequest = `${resolvedRequest}${jsExtension}`;
2148
2155
  }
2149
2156
  return callback(void 0, resolvedRequest);
2150
2157
  }
@@ -2172,6 +2179,7 @@ const composeDtsConfig = async (libConfig, format, dtsExtension)=>{
2172
2179
  abortOnError: dts?.abortOnError,
2173
2180
  dtsExtension: dts?.autoExtension ? dtsExtension : '.d.ts',
2174
2181
  autoExternal: getAutoExternalDefaultValue(format, autoExternal),
2182
+ alias: dts?.alias,
2175
2183
  banner: banner?.dts,
2176
2184
  footer: footer?.dts,
2177
2185
  redirect: redirect?.dts
@@ -2996,7 +3004,7 @@ const applyCommonOptions = (cli)=>{
2996
3004
  function runCli() {
2997
3005
  const cli = dist('rslib');
2998
3006
  cli.help();
2999
- cli.version("0.10.6");
3007
+ cli.version("0.11.1");
3000
3008
  applyCommonOptions(cli);
3001
3009
  const buildCommand = cli.command('build', 'build the library for production');
3002
3010
  const inspectCommand = cli.command('inspect', 'inspect the Rsbuild / Rspack configs of Rslib projects');
@@ -3067,8 +3075,8 @@ function prepareCli() {
3067
3075
  initNodeEnv();
3068
3076
  const { npm_execpath } = process.env;
3069
3077
  if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
3070
- logger.greet(` Rslib v0.10.6\n`);
3078
+ logger.greet(` Rslib v0.11.1\n`);
3071
3079
  }
3072
- const src_version = "0.10.6";
3080
+ const src_version = "0.11.1";
3073
3081
  var __webpack_exports__rspack = __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack;
3074
3082
  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 {};
@@ -52,6 +52,12 @@ export type Dts = {
52
52
  * @see {@link https://rslib.rs/config/lib/dts#dtsautoextension}
53
53
  */
54
54
  autoExtension?: boolean;
55
+ /**
56
+ * Set the alias for declaration files, similar to the `compilerOptions.paths` option in `tsconfig.json`.
57
+ * @defaultValue `{}`
58
+ * @see {@link https://rslib.rs/config/lib/dts#dtsalias}
59
+ */
60
+ alias?: Record<string, string>;
55
61
  } | boolean;
56
62
  export type AutoExternal = boolean | {
57
63
  /**
@@ -146,6 +152,18 @@ export type StyleRedirect = {
146
152
  */
147
153
  extension?: boolean;
148
154
  };
155
+ export type AssetRedirect = {
156
+ /**
157
+ * Whether to automatically redirect the import paths of asset output files.
158
+ * @defaultValue `true`
159
+ */
160
+ path?: boolean;
161
+ /**
162
+ * Whether to automatically redirect the file extension to import paths based on the asset output files.
163
+ * @defaultValue `true`
164
+ */
165
+ extension?: boolean;
166
+ };
149
167
  export type DtsRedirect = {
150
168
  /**
151
169
  * Whether to automatically redirect the import paths of TypeScript declaration output files.
@@ -164,7 +182,7 @@ export type Redirect = {
164
182
  /** Controls the redirect of the import paths of output style files. */
165
183
  style?: StyleRedirect;
166
184
  /** Controls the redirect of the import paths of output asset files. */
167
- asset?: boolean;
185
+ asset?: AssetRedirect;
168
186
  /** Controls the redirect of the import paths of output TypeScript declaration files. */
169
187
  dts?: DtsRedirect;
170
188
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rslib/core",
3
- "version": "0.10.6",
3
+ "version": "0.11.1",
4
4
  "description": "The Rsbuild-based library development tool.",
5
5
  "homepage": "https://rslib.rs",
6
6
  "bugs": {
@@ -36,24 +36,24 @@
36
36
  "types.d.ts"
37
37
  ],
38
38
  "dependencies": {
39
- "@rsbuild/core": "~1.4.7",
39
+ "@rsbuild/core": "~1.4.12",
40
40
  "tinyglobby": "^0.2.14",
41
- "rsbuild-plugin-dts": "0.10.6"
41
+ "rsbuild-plugin-dts": "0.11.1"
42
42
  },
43
43
  "devDependencies": {
44
- "@module-federation/rsbuild-plugin": "^0.17.0",
44
+ "@module-federation/rsbuild-plugin": "^0.17.1",
45
45
  "@types/fs-extra": "^11.0.4",
46
46
  "cac": "^6.7.14",
47
47
  "chokidar": "^4.0.3",
48
48
  "fs-extra": "^11.3.0",
49
- "memfs": "^4.17.2",
49
+ "memfs": "^4.28.0",
50
50
  "picocolors": "1.1.1",
51
- "prebundle": "1.3.4",
51
+ "prebundle": "1.4.0",
52
52
  "rsbuild-plugin-publint": "^0.3.2",
53
- "rslib": "npm:@rslib/core@0.10.5",
53
+ "rslib": "npm:@rslib/core@0.11.0",
54
54
  "rslog": "^1.2.9",
55
55
  "tsconfck": "3.1.6",
56
- "typescript": "^5.8.3",
56
+ "typescript": "^5.9.2",
57
57
  "@rslib/tsconfig": "0.0.1"
58
58
  },
59
59
  "peerDependencies": {