@modern-js/uni-builder 2.57.1 → 2.58.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.
@@ -42,7 +42,7 @@ var import_runtimeChunk = require("./plugins/runtimeChunk");
42
42
  var import_frameworkConfig = require("./plugins/frameworkConfig");
43
43
  var import_splitChunk = require("./plugins/splitChunk");
44
44
  var import_plugin_css_minimizer = require("@rsbuild/plugin-css-minimizer");
45
- var import_postcssLegacy = require("./plugins/postcssLegacy");
45
+ var import_postcss = require("./plugins/postcss");
46
46
  var import_devtools = require("./plugins/devtools");
47
47
  var import_emitRouteFile = require("./plugins/emitRouteFile");
48
48
  var import_antd = require("./plugins/antd");
@@ -80,9 +80,9 @@ const isUseCssSourceMap = (disableSourceMap = {}) => {
80
80
  };
81
81
  async function parseCommonConfig(uniBuilderConfig, options) {
82
82
  var _uniBuilderConfig_output, _uniBuilderConfig_tools;
83
- var _output_distPath, _output, _extraConfig, _html, _extraConfig1;
83
+ var _rsbuildConfig_tools, _output_distPath, _output, _extraConfig, _html, _extraConfig1;
84
84
  const { frameworkConfigPath } = options;
85
- const { plugins: [...plugins] = [], performance: { ...performanceConfig } = {}, output: { disableFilenameHash, enableLatestDecorators, cssModuleLocalIdentName, enableInlineScripts, disableCssExtract, enableInlineStyles, enableCssModuleTSDeclaration, disableCssModuleExtension, disableTsChecker, disableSvgr, svgDefaultExport, assetsRetry, enableAssetFallback, enableAssetManifest, disableSourceMap, convertToRem, disableMinimize, polyfill, dataUriLimit = 1e4, distPath = {}, ...outputConfig } = {}, html: { disableHtmlFolder, metaByEntries, titleByEntries, faviconByEntries, injectByEntries, templateByEntries, templateParametersByEntries, tagsByEntries, tags, ...htmlConfig } = {}, source: { alias, globalVars, resolveMainFields, resolveExtensionPrefix, ...sourceConfig } = {}, dev, security: { checkSyntax, sri, ...securityConfig } = {}, tools: { devServer, tsChecker, minifyCss, less, sass, htmlPlugin, ...toolsConfig } = {}, environments = {} } = uniBuilderConfig;
85
+ const { plugins: [...plugins] = [], performance: { ...performanceConfig } = {}, output: { disableFilenameHash, enableLatestDecorators, cssModuleLocalIdentName, enableInlineScripts, disableCssExtract, enableInlineStyles, enableCssModuleTSDeclaration, disableCssModuleExtension, disableTsChecker, disableSvgr, svgDefaultExport, assetsRetry, enableAssetFallback, enableAssetManifest, disableSourceMap, convertToRem, disableMinimize, polyfill, dataUriLimit = 1e4, distPath = {}, ...outputConfig } = {}, html: { disableHtmlFolder, metaByEntries, titleByEntries, faviconByEntries, injectByEntries, templateByEntries, templateParametersByEntries, tagsByEntries, tags, ...htmlConfig } = {}, source: { alias, globalVars, resolveMainFields, resolveExtensionPrefix, ...sourceConfig } = {}, dev, security: { checkSyntax, sri, ...securityConfig } = {}, tools: { devServer, tsChecker, minifyCss, less, sass, htmlPlugin, autoprefixer, ...toolsConfig } = {}, environments = {} } = uniBuilderConfig;
86
86
  const rsbuildConfig = {
87
87
  plugins,
88
88
  output: {
@@ -101,6 +101,8 @@ async function parseCommonConfig(uniBuilderConfig, options) {
101
101
  environments
102
102
  };
103
103
  rsbuildConfig.tools.htmlPlugin = htmlPlugin;
104
+ var _lightningcssLoader;
105
+ (_lightningcssLoader = (_rsbuildConfig_tools = rsbuildConfig.tools).lightningcssLoader) !== null && _lightningcssLoader !== void 0 ? _lightningcssLoader : _rsbuildConfig_tools.lightningcssLoader = false;
104
106
  const { html = {}, output = {}, source = {} } = rsbuildConfig;
105
107
  if (enableLatestDecorators) {
106
108
  source.decorators = {
@@ -299,7 +301,9 @@ async function parseCommonConfig(uniBuilderConfig, options) {
299
301
  rsbuildPlugins.push((0, import_plugin_css_minimizer.pluginCssMinimizer)({
300
302
  pluginOptions: minifyCss
301
303
  }));
302
- rsbuildPlugins.push((0, import_postcssLegacy.pluginPostcssLegacy)());
304
+ rsbuildPlugins.push((0, import_postcss.pluginPostcss)({
305
+ autoprefixer
306
+ }));
303
307
  if (enableAssetManifest) {
304
308
  const { pluginManifest } = await Promise.resolve().then(() => __toESM(require("./plugins/manifest")));
305
309
  rsbuildPlugins.push(pluginManifest());
@@ -87,9 +87,7 @@ const pluginHtmlMinifierTerser = () => ({
87
87
  setup(api) {
88
88
  api.modifyBundlerChain(async (chain, { isProd, environment }) => {
89
89
  const { output, tools: { htmlPlugin } } = environment.config;
90
- if (!isProd || output.minify === false || htmlPlugin === false) {
91
- return;
92
- }
90
+ const disableHtmlMinify = !isProd || output.minify === false || htmlPlugin === false;
93
91
  const { minify } = await Promise.resolve().then(() => __toESM(require("html-minifier-terser")));
94
92
  const pluginRecord = chain.plugins.entries();
95
93
  const minifyOptions = getMinifyOptions(environment.config);
@@ -103,7 +101,7 @@ const pluginHtmlMinifierTerser = () => ({
103
101
  const name = (item === null || item === void 0 ? void 0 : item.name) || ((_item_constructor = item.constructor) === null || _item_constructor === void 0 ? void 0 : _item_constructor.name);
104
102
  return name === "HtmlRspackPlugin";
105
103
  });
106
- if (isHtmlRspackPlugin) {
104
+ if (isHtmlRspackPlugin && !disableHtmlMinify) {
107
105
  chain.plugin(id).tap((options) => {
108
106
  if (!options.length) {
109
107
  return options;
@@ -125,6 +123,10 @@ const pluginHtmlMinifierTerser = () => ({
125
123
  if (!options.length || options[0].minify) {
126
124
  return options;
127
125
  }
126
+ if (disableHtmlMinify) {
127
+ options[0].minify = false;
128
+ return options;
129
+ }
128
130
  const userMinifyOption = options[0].minify;
129
131
  options[0].minify = userMinifyOption ? (0, import_ts_deepmerge.merge)(minifyOptions, userMinifyOption) : minifyOptions;
130
132
  return options;
@@ -0,0 +1,5 @@
1
+ import type { RsbuildPlugin } from '@rsbuild/core';
2
+ import type { ToolsAutoprefixerConfig } from '../../types';
3
+ export declare const pluginPostcss: ({ autoprefixer, }: {
4
+ autoprefixer?: ToolsAutoprefixerConfig | undefined;
5
+ }) => RsbuildPlugin;
@@ -16,24 +16,28 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var postcssLegacy_exports = {};
20
- __export(postcssLegacy_exports, {
21
- pluginPostcssLegacy: () => pluginPostcssLegacy
19
+ var postcss_exports = {};
20
+ __export(postcss_exports, {
21
+ pluginPostcss: () => pluginPostcss
22
22
  });
23
- module.exports = __toCommonJS(postcssLegacy_exports);
23
+ module.exports = __toCommonJS(postcss_exports);
24
24
  var import_utils = require("@modern-js/utils");
25
25
  var import_getCssSupport = require("../getCssSupport");
26
- const pluginPostcssLegacy = () => ({
26
+ const pluginPostcss = ({ autoprefixer }) => ({
27
27
  name: "uni-builder:postcss-plugins",
28
+ pre: [
29
+ "uni-builder:environment-defaults-plugin"
30
+ ],
28
31
  setup(api) {
29
32
  api.modifyEnvironmentConfig((config, { mergeEnvironmentConfig }) => {
30
33
  var _config_output;
31
34
  if (config.output.target !== "web") {
32
- return;
35
+ return config;
33
36
  }
34
37
  const cssSupport = (0, import_getCssSupport.getCssSupport)(config.output.overrideBrowserslist);
35
38
  const enableExtractCSS = !((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.injectStyles);
36
39
  const enableCssMinify = !enableExtractCSS && import_utils.isProd;
40
+ const enableAutoprefixer = config.tools.lightningcssLoader === false;
37
41
  const plugins = [
38
42
  require("postcss-flexbugs-fixes"),
39
43
  !cssSupport.customProperties && require("postcss-custom-properties"),
@@ -52,13 +56,20 @@ const pluginPostcssLegacy = () => ({
52
56
  mergeLonghand: false
53
57
  }
54
58
  ]
55
- }) : false
59
+ }) : false,
60
+ // The last insert autoprefixer
61
+ enableAutoprefixer && require("autoprefixer")((0, import_utils.applyOptionsChain)({
62
+ flexbox: "no-2009",
63
+ overrideBrowserslist: config.output.overrideBrowserslist
64
+ }, autoprefixer))
56
65
  ].filter(Boolean);
57
66
  return mergeEnvironmentConfig(
58
67
  {
59
68
  tools: {
60
- postcss: (opts) => {
61
- opts.postcssOptions.plugins.push(...plugins);
69
+ postcss: {
70
+ postcssOptions: {
71
+ plugins
72
+ }
62
73
  }
63
74
  }
64
75
  },
@@ -70,5 +81,5 @@ const pluginPostcssLegacy = () => ({
70
81
  });
71
82
  // Annotate the CommonJS export names for ESM import in node:
72
83
  0 && (module.exports = {
73
- pluginPostcssLegacy
84
+ pluginPostcss
74
85
  });
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ConfigChainWithContext, ConfigChain, DevConfig, RsbuildConfig, RsbuildTarget, Polyfill, ScriptInject, ServerConfig, RsbuildPluginAPI, OutputConfig, DistPathConfig, Rspack, RequestHandler, NodeEnv, HtmlTagDescriptor, RsbuildPlugin } from '@rsbuild/core';
1
+ import type { ConfigChainWithContext, ConfigChain, DevConfig, RsbuildConfig, RsbuildTarget, Polyfill, ScriptInject, ServerConfig, RsbuildPluginAPI, OutputConfig, DistPathConfig, Rspack, RequestHandler, HtmlTagDescriptor, RsbuildPlugin } from '@rsbuild/core';
2
2
  import type { PluginAssetsRetryOptions } from '@rsbuild/plugin-assets-retry';
3
3
  import type { PluginStyledComponentsOptions } from '@rsbuild/plugin-styled-components';
4
4
  import type { PluginRemOptions } from '@rsbuild/plugin-rem';
@@ -15,6 +15,7 @@ import type { AliasOption } from '@modern-js/utils';
15
15
  import type { PluginSourceBuildOptions } from '@rsbuild/plugin-source-build';
16
16
  import type TerserPlugin from 'terser-webpack-plugin';
17
17
  import type { Options as HTMLPluginOptions } from 'html-webpack-plugin';
18
+ import type { Options as AutoprefixerOptions } from 'autoprefixer';
18
19
  type ArrayOrNot<T> = T | T[];
19
20
  export type Stats = Omit<Rspack.Stats, '#private' | 'hash' | 'startTime' | 'endTime'>;
20
21
  export type RspackConfig = Rspack.Configuration;
@@ -47,7 +48,7 @@ export type CreateUniBuilderOptions = {
47
48
  } & Partial<CreateBuilderCommonOptions>;
48
49
  export type GlobalVars = Record<string, any>;
49
50
  export type ChainedGlobalVars = ConfigChainWithContext<GlobalVars, {
50
- env: NodeEnv;
51
+ env: string;
51
52
  target: RsbuildTarget;
52
53
  }>;
53
54
  export type ModuleScopes = Array<string | RegExp>;
@@ -78,8 +79,13 @@ export type ToolsDevServerConfig = ConfigChain<{
78
79
  }>;
79
80
  export type TerserPluginOptions = TerserPlugin.BasePluginOptions & TerserPlugin.DefinedDefaultMinimizerAndOptions<TerserPlugin.TerserOptions>;
80
81
  export type ToolsTerserConfig = ConfigChain<TerserPluginOptions>;
82
+ export type ToolsAutoprefixerConfig = ConfigChain<AutoprefixerOptions>;
81
83
  export type UniBuilderExtraConfig = {
82
84
  tools?: {
85
+ /**
86
+ * Modify the config of [autoprefixer](https://github.com/postcss/autoprefixer)
87
+ */
88
+ autoprefixer?: ToolsAutoprefixerConfig;
83
89
  htmlPlugin?: boolean | ConfigChainWithContext<HTMLPluginOptions, {
84
90
  entryName: string;
85
91
  entryValue: (string | string[] | Rspack.EntryDescription)[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@modern-js/uni-builder",
3
- "version": "2.57.1",
3
+ "version": "2.58.1",
4
4
  "description": "Unified builder for Modern.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,25 +26,26 @@
26
26
  "@babel/preset-react": "^7.22.15",
27
27
  "@babel/types": "^7.24.7",
28
28
  "@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
29
- "@rsbuild/core": "1.0.1-beta.3",
30
- "@rsbuild/plugin-sass": "1.0.1-beta.3",
31
- "@rsbuild/plugin-less": "1.0.1-beta.3",
32
- "@rsbuild/plugin-assets-retry": "1.0.1-beta.3",
33
- "@rsbuild/plugin-babel": "1.0.1-beta.3",
34
- "@rsbuild/plugin-check-syntax": "1.0.1-beta.3",
35
- "@rsbuild/plugin-css-minimizer": "1.0.1",
36
- "@rsbuild/plugin-pug": "1.0.1",
37
- "@rsbuild/plugin-react": "1.0.1-beta.3",
38
- "@rsbuild/plugin-rem": "1.0.1-beta.3",
39
- "@rsbuild/plugin-source-build": "1.0.1-beta.3",
40
- "@rsbuild/plugin-styled-components": "1.0.1-beta.3",
41
- "@rsbuild/plugin-svgr": "1.0.1-beta.3",
42
- "@rsbuild/plugin-type-check": "1.0.1-beta.3",
43
- "@rsbuild/plugin-typed-css-modules": "1.0.1",
44
- "@rsbuild/plugin-toml": "1.0.0",
45
- "@rsbuild/plugin-yaml": "1.0.1",
46
- "@rsbuild/webpack": "1.0.1-beta.3",
29
+ "@rsbuild/core": "1.0.1-beta.13",
30
+ "@rsbuild/plugin-assets-retry": "1.0.1-beta.13",
31
+ "@rsbuild/plugin-babel": "1.0.1-beta.13",
32
+ "@rsbuild/plugin-check-syntax": "1.0.1",
33
+ "@rsbuild/plugin-css-minimizer": "1.0.2",
34
+ "@rsbuild/plugin-less": "1.0.1-beta.13",
35
+ "@rsbuild/plugin-pug": "1.0.2",
36
+ "@rsbuild/plugin-react": "1.0.1-beta.13",
37
+ "@rsbuild/plugin-rem": "1.0.1",
38
+ "@rsbuild/plugin-sass": "1.0.1-beta.13",
39
+ "@rsbuild/plugin-source-build": "1.0.1",
40
+ "@rsbuild/plugin-styled-components": "1.0.1",
41
+ "@rsbuild/plugin-svgr": "1.0.1-beta.13",
42
+ "@rsbuild/plugin-toml": "1.0.1",
43
+ "@rsbuild/plugin-type-check": "1.0.1-beta.13",
44
+ "@rsbuild/plugin-typed-css-modules": "1.0.2",
45
+ "@rsbuild/plugin-yaml": "1.0.2",
46
+ "@rsbuild/webpack": "1.0.1-beta.13",
47
47
  "@swc/helpers": "0.5.3",
48
+ "autoprefixer": "10.4.19",
48
49
  "babel-loader": "9.1.3",
49
50
  "babel-plugin-import": "1.13.5",
50
51
  "babel-plugin-styled-components": "1.13.3",
@@ -52,9 +53,10 @@
52
53
  "browserslist": "4.23.1",
53
54
  "cssnano": "6.0.1",
54
55
  "glob": "^9.3.5",
55
- "html-webpack-plugin": "5.5.3",
56
56
  "html-minifier-terser": "^7.2.0",
57
+ "html-webpack-plugin": "5.5.3",
57
58
  "lodash": "^4.17.21",
59
+ "picocolors": "^1.0.1",
58
60
  "postcss": "^8.4.35",
59
61
  "postcss-custom-properties": "13.1.5",
60
62
  "postcss-flexbugs-fixes": "5.0.2",
@@ -63,7 +65,6 @@
63
65
  "postcss-media-minmax": "5.0.0",
64
66
  "postcss-nesting": "12.0.1",
65
67
  "postcss-page-break": "3.0.4",
66
- "picocolors": "^1.0.1",
67
68
  "react-refresh": "^0.14.0",
68
69
  "rspack-manifest-plugin": "5.0.0",
69
70
  "terser-webpack-plugin": "5.3.10",
@@ -71,19 +72,19 @@
71
72
  "ts-loader": "9.4.4",
72
73
  "webpack": "^5.93.0",
73
74
  "webpack-subresource-integrity": "5.1.0",
74
- "@modern-js/utils": "2.57.1",
75
- "@modern-js/babel-preset": "2.57.1"
75
+ "@modern-js/babel-preset": "2.58.1",
76
+ "@modern-js/utils": "2.58.1"
76
77
  },
77
78
  "devDependencies": {
78
- "@rsbuild/plugin-swc": "1.0.1-beta.3",
79
+ "@rsbuild/plugin-swc": "1.0.1-beta.13",
79
80
  "@types/html-minifier-terser": "^7.0.2",
80
81
  "@types/lodash": "^4.14.202",
81
82
  "react": "^18.2.0",
82
83
  "react-dom": "^18.2.0",
83
84
  "terser": "^5.31.1",
84
85
  "typescript": "^5.3.0",
85
- "@scripts/build": "2.57.1",
86
- "@scripts/vitest-config": "2.57.1"
86
+ "@scripts/build": "2.58.1",
87
+ "@scripts/vitest-config": "2.58.1"
87
88
  },
88
89
  "publishConfig": {
89
90
  "access": "public",
@@ -1,2 +0,0 @@
1
- import type { RsbuildPlugin } from '@rsbuild/core';
2
- export declare const pluginPostcssLegacy: () => RsbuildPlugin;