@rsbuild/shared
Advanced tools
Comparing version 0.4.10 to 0.4.11
@@ -17,3 +17,3 @@ import type { RsbuildConfig, BundlerChainRule, NormalizedConfig, InspectConfigOptions } from './types'; | ||
export type GetTypeByPath<T extends string, C extends Record<string, any>> = T extends `${infer K}[${infer P}]${infer S}` ? GetTypeByPath<`${K}.${P}${S}`, C> : T extends `${infer K}.${infer P}` ? GetTypeByPath<P, K extends '' ? C : NonNullable<C[K]>> : C[T]; | ||
export declare function getMinify(isProd: boolean, config: NormalizedConfig): Promise<false | { | ||
export declare function getHtmlMinifyOptions(isProd: boolean, config: NormalizedConfig): Promise<false | { | ||
removeComments: boolean; | ||
@@ -20,0 +20,0 @@ useShortDoctype: boolean; |
@@ -33,3 +33,3 @@ "use strict"; | ||
getDefaultStyledComponentsConfig: () => getDefaultStyledComponentsConfig, | ||
getMinify: () => getMinify, | ||
getHtmlMinifyOptions: () => getHtmlMinifyOptions, | ||
outputInspectConfigFiles: () => outputInspectConfigFiles, | ||
@@ -45,2 +45,3 @@ pickRsbuildConfig: () => pickRsbuildConfig, | ||
var import_minimize = require("./minimize"); | ||
var import_minimize2 = require("./minimize"); | ||
async function outputInspectConfigFiles({ | ||
@@ -91,8 +92,8 @@ rsbuildConfig, | ||
} | ||
async function getMinify(isProd, config) { | ||
if (config.output.disableMinimize || !isProd) { | ||
async function getHtmlMinifyOptions(isProd, config) { | ||
if (config.output.disableMinimize || !isProd || !config.output.minify || !(0, import_minimize2.parseMinifyOptions)(config).minifyHtml) { | ||
return false; | ||
} | ||
const minifyJS = (await (0, import_minimize.getTerserMinifyOptions)(config)).terserOptions; | ||
return { | ||
const htmlMinifyDefaultOptions = { | ||
removeComments: false, | ||
@@ -110,2 +111,4 @@ useShortDoctype: true, | ||
}; | ||
const htmlMinifyOptions = (0, import_minimize2.parseMinifyOptions)(config).htmlOptions; | ||
return typeof htmlMinifyOptions === "object" ? (0, import_utils.deepmerge)(htmlMinifyDefaultOptions, htmlMinifyOptions) : htmlMinifyDefaultOptions; | ||
} | ||
@@ -165,3 +168,3 @@ async function stringifyConfig(config, verbose) { | ||
getDefaultStyledComponentsConfig, | ||
getMinify, | ||
getHtmlMinifyOptions, | ||
outputInspectConfigFiles, | ||
@@ -168,0 +171,0 @@ pickRsbuildConfig, |
@@ -1,4 +0,11 @@ | ||
import type { NormalizedConfig, TerserPluginOptions } from './types'; | ||
import type { HTMLPluginOptions, NormalizedConfig, TerserPluginOptions } from './types'; | ||
import type { SwcJsMinimizerRspackPluginOptions } from '@rspack/core'; | ||
export declare function getTerserMinifyOptions(config: NormalizedConfig): Promise<TerserPluginOptions>; | ||
export declare const getSwcMinimizerOptions: (config: NormalizedConfig) => SwcJsMinimizerRspackPluginOptions; | ||
export declare const parseMinifyOptions: (config: NormalizedConfig, isProd?: boolean) => { | ||
minifyJs: boolean; | ||
minifyCss: boolean; | ||
minifyHtml: boolean; | ||
jsOptions?: SwcJsMinimizerRspackPluginOptions; | ||
htmlOptions?: HTMLPluginOptions['minify']; | ||
}; |
"use strict"; | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
@@ -18,2 +20,10 @@ var __export = (target, all) => { | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
// If the importer is in node compatibility mode or this is not an ESM | ||
// file that has been converted to a CommonJS file using a Babel- | ||
// compatible transform (i.e. "__esModule" has not been set), then set | ||
// "default" to the CommonJS "module.exports" for node compatibility. | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
@@ -23,3 +33,4 @@ var minimize_exports = {}; | ||
getSwcMinimizerOptions: () => getSwcMinimizerOptions, | ||
getTerserMinifyOptions: () => getTerserMinifyOptions | ||
getTerserMinifyOptions: () => getTerserMinifyOptions, | ||
parseMinifyOptions: () => parseMinifyOptions | ||
}); | ||
@@ -29,2 +40,3 @@ module.exports = __toCommonJS(minimize_exports); | ||
var import_mergeChainedOptions = require("./mergeChainedOptions"); | ||
var import_deepmerge = __toESM(require("../compiled/deepmerge")); | ||
function applyRemoveConsole(options, config) { | ||
@@ -116,8 +128,41 @@ if (!options.terserOptions) { | ||
options.format.asciiOnly = config.output.charset === "ascii"; | ||
const jsOptions = parseMinifyOptions(config).jsOptions; | ||
if (jsOptions) { | ||
return (0, import_deepmerge.default)(options, jsOptions); | ||
} | ||
return options; | ||
}; | ||
const parseMinifyOptions = (config, isProd = true) => { | ||
const minify = config.output.minify; | ||
if (minify === false || !isProd) { | ||
return { | ||
minifyJs: false, | ||
minifyCss: false, | ||
minifyHtml: false, | ||
jsOptions: void 0, | ||
htmlOptions: void 0 | ||
}; | ||
} | ||
if (minify === true) { | ||
return { | ||
minifyJs: true, | ||
minifyCss: true, | ||
minifyHtml: true, | ||
jsOptions: void 0, | ||
htmlOptions: void 0 | ||
}; | ||
} | ||
return { | ||
minifyJs: minify.js !== false, | ||
minifyCss: minify.css !== false, | ||
minifyHtml: minify.html !== false, | ||
jsOptions: minify.jsOptions, | ||
htmlOptions: minify.htmlOptions | ||
}; | ||
}; | ||
// Annotate the CommonJS export names for ESM import in node: | ||
0 && (module.exports = { | ||
getSwcMinimizerOptions, | ||
getTerserMinifyOptions | ||
getTerserMinifyOptions, | ||
parseMinifyOptions | ||
}); |
import type { RspackConfig } from '../rspack'; | ||
import type { RsbuildTarget } from '../rsbuild'; | ||
import type { CopyRspackPluginOptions, Externals } from '@rspack/core'; | ||
import type { CopyRspackPluginOptions, Externals, SwcJsMinimizerRspackPluginOptions } from '@rspack/core'; | ||
import type { HTMLPluginOptions } from '../../types'; | ||
export type DistPathConfig = { | ||
@@ -134,2 +135,24 @@ /** | ||
}; | ||
export type Minify = boolean | { | ||
/** | ||
* Whether to enable JavaScript minification. | ||
*/ | ||
js?: boolean; | ||
/** | ||
* Minimizer options of JavaScript, which will be passed to swc. | ||
*/ | ||
jsOptions?: SwcJsMinimizerRspackPluginOptions; | ||
/** | ||
* Whether to enable CSS minimization. | ||
*/ | ||
css?: boolean; | ||
/** | ||
* Whether to enable HTML minimization. | ||
*/ | ||
html?: boolean; | ||
/** | ||
* Minimizer options of HTML, which will be passed to html-rspack-plugin. | ||
*/ | ||
htmlOptions?: HTMLPluginOptions['minify']; | ||
}; | ||
export type CopyPluginOptions = CopyRspackPluginOptions; | ||
@@ -199,5 +222,10 @@ export type InlineChunkTestFunction = (params: { | ||
* Whether to disable code minification in production build. | ||
* @deprecated will be removed in v0.5.0, use `minify` instead. | ||
*/ | ||
disableMinimize?: boolean; | ||
/** | ||
* Whether to disable code minification in production build. | ||
*/ | ||
minify?: Minify; | ||
/** | ||
* Whether to generate source map files, and which format of source map to generate | ||
@@ -252,2 +280,3 @@ */ | ||
disableMinimize: boolean; | ||
minify: Minify; | ||
enableCssModuleTSDeclaration: boolean; | ||
@@ -254,0 +283,0 @@ inlineScripts: boolean | InlineChunkTest; |
@@ -5,3 +5,3 @@ import type { ArrayOrNot, WebpackChain, ChainedConfig, FileFilterUtil, ChainedConfigWithUtils } from '../utils'; | ||
import type { ModifyBundlerChainUtils, ModifyChainUtils } from '../hooks'; | ||
import type { RspackConfig, RspackRule } from '../rspack'; | ||
import type { RspackRule, RspackConfig, BuiltinSwcLoaderOptions } from '../rspack'; | ||
import type { Options as HTMLPluginOptions } from 'html-webpack-plugin'; | ||
@@ -11,2 +11,3 @@ import type { BundlerPluginInstance } from '../bundlerConfig'; | ||
export type { HTMLPluginOptions }; | ||
export type ToolsSwcConfig = ChainedConfig<BuiltinSwcLoaderOptions>; | ||
export type ToolsAutoprefixerConfig = ChainedConfig<AutoprefixerOptions>; | ||
@@ -75,2 +76,6 @@ export type ToolsSassConfig = ChainedConfigWithUtils<SassLoaderOptions, { | ||
/** | ||
* Configure the `builtin:swc-loader` of Rspack. | ||
*/ | ||
swc?: ToolsSwcConfig; | ||
/** | ||
* Configure Rspack. | ||
@@ -77,0 +82,0 @@ * @requires rspack |
{ | ||
"name": "@rsbuild/shared", | ||
"version": "0.4.10", | ||
"version": "0.4.11", | ||
"description": "The internal shared modules and dependencies of Rsbuild.", | ||
@@ -126,3 +126,3 @@ "homepage": "https://rsbuild.dev", | ||
"dependencies": { | ||
"@rspack/core": "0.5.5", | ||
"@rspack/core": "0.5.6", | ||
"caniuse-lite": "^1.0.30001583", | ||
@@ -129,0 +129,0 @@ "postcss": "^8.4.33" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7716820
23038
+ Added@rspack/binding@0.5.6(transitive)
+ Added@rspack/binding-darwin-arm64@0.5.6(transitive)
+ Added@rspack/binding-darwin-x64@0.5.6(transitive)
+ Added@rspack/binding-linux-arm64-gnu@0.5.6(transitive)
+ Added@rspack/binding-linux-arm64-musl@0.5.6(transitive)
+ Added@rspack/binding-linux-x64-gnu@0.5.6(transitive)
+ Added@rspack/binding-linux-x64-musl@0.5.6(transitive)
+ Added@rspack/binding-win32-arm64-msvc@0.5.6(transitive)
+ Added@rspack/binding-win32-ia32-msvc@0.5.6(transitive)
+ Added@rspack/binding-win32-x64-msvc@0.5.6(transitive)
+ Added@rspack/core@0.5.6(transitive)
- Removed@rspack/binding@0.5.5(transitive)
- Removed@rspack/binding-darwin-arm64@0.5.5(transitive)
- Removed@rspack/binding-darwin-x64@0.5.5(transitive)
- Removed@rspack/binding-linux-arm64-gnu@0.5.5(transitive)
- Removed@rspack/binding-linux-arm64-musl@0.5.5(transitive)
- Removed@rspack/binding-linux-x64-gnu@0.5.5(transitive)
- Removed@rspack/binding-linux-x64-musl@0.5.5(transitive)
- Removed@rspack/binding-win32-arm64-msvc@0.5.5(transitive)
- Removed@rspack/binding-win32-ia32-msvc@0.5.5(transitive)
- Removed@rspack/binding-win32-x64-msvc@0.5.5(transitive)
- Removed@rspack/core@0.5.5(transitive)
- Removedansi-escapes@4.3.2(transitive)
- Removedhas-flag@4.0.0(transitive)
- Removedsupports-color@7.2.0(transitive)
- Removedsupports-hyperlinks@2.3.0(transitive)
- Removedterminal-link@2.1.1(transitive)
- Removedtype-fest@0.21.3(transitive)
Updated@rspack/core@0.5.6