@modern-js/uni-builder 0.0.0-nightly-20240131170643 → 0.0.0-nightly-20240202170715
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.
|
@@ -40,10 +40,9 @@ const pluginBabelPost = () => ({
|
|
|
40
40
|
],
|
|
41
41
|
setup(api) {
|
|
42
42
|
api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
|
|
43
|
-
const config = api.getNormalizedConfig();
|
|
44
43
|
if (chain.module.rules.get(CHAIN_ID.RULE.JS)) {
|
|
45
44
|
const babelLoaderOptions = chain.module.rule(CHAIN_ID.RULE.JS).use(CHAIN_ID.USE.BABEL).get("options");
|
|
46
|
-
if (babelLoaderOptions && (0, import_isEqual.default)((0, import_plugin_babel.getDefaultBabelOptions)(
|
|
45
|
+
if (babelLoaderOptions && (0, import_isEqual.default)((0, import_plugin_babel.getDefaultBabelOptions)(), babelLoaderOptions)) {
|
|
47
46
|
chain.module.rule(CHAIN_ID.RULE.JS).uses.delete(CHAIN_ID.USE.BABEL);
|
|
48
47
|
}
|
|
49
48
|
}
|
|
@@ -92,11 +92,20 @@ async function getBrowserslistWithDefault(path, config, target) {
|
|
|
92
92
|
}
|
|
93
93
|
return DEFAULT_BROWSERSLIST[target];
|
|
94
94
|
}
|
|
95
|
+
const isUseCssSourceMap = (disableSourceMap = {}) => {
|
|
96
|
+
if (typeof disableSourceMap === "boolean") {
|
|
97
|
+
return !disableSourceMap;
|
|
98
|
+
}
|
|
99
|
+
if (disableSourceMap.css === void 0) {
|
|
100
|
+
return process.env.NODE_ENV !== "production";
|
|
101
|
+
}
|
|
102
|
+
return !disableSourceMap.css;
|
|
103
|
+
};
|
|
95
104
|
async function parseCommonConfig(uniBuilderConfig, options) {
|
|
96
105
|
var _newDevServerConfig_devMiddleware, _uniBuilderConfig_output, _uniBuilderConfig_tools;
|
|
97
106
|
var _output, _output_distPath, _output_distPath1, _output1, _extraConfig, _html, _extraConfig1;
|
|
98
107
|
const { cwd, frameworkConfigPath, entry, target } = options;
|
|
99
|
-
const { plugins: [...plugins] = [], performance: { ...performanceConfig } = {}, output: {
|
|
108
|
+
const { plugins: [...plugins] = [], performance: { ...performanceConfig } = {}, output: { cssModuleLocalIdentName, enableInlineScripts, disableCssExtract, enableInlineStyles, disableCssModuleExtension, disableTsChecker, disableSvgr, svgDefaultExport, assetsRetry, enableAssetFallback, disableSourceMap, convertToRem, ...outputConfig } = {}, html: { disableHtmlFolder, metaByEntries, titleByEntries, faviconByEntries, injectByEntries, templateByEntries, templateParametersByEntries, ...htmlConfig } = {}, source: { alias, globalVars, resolveMainFields, resolveExtensionPrefix, ...sourceConfig } = {}, dev: { port, host, https, ...devConfig } = {}, security: { checkSyntax, sri, ...securityConfig } = {}, tools: { devServer, tsChecker, minifyCss, ...toolsConfig } = {} } = uniBuilderConfig;
|
|
100
109
|
const rsbuildConfig = {
|
|
101
110
|
plugins,
|
|
102
111
|
output: outputConfig,
|
|
@@ -110,17 +119,17 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
110
119
|
dev: devConfig,
|
|
111
120
|
security: securityConfig
|
|
112
121
|
};
|
|
113
|
-
const { dev = {}, html = {}, output = {}
|
|
114
|
-
if (enableLatestDecorators) {
|
|
115
|
-
source.decorators = {
|
|
116
|
-
version: "2022-03"
|
|
117
|
-
};
|
|
118
|
-
}
|
|
122
|
+
const { dev = {}, html = {}, output = {} } = rsbuildConfig;
|
|
119
123
|
if (cssModuleLocalIdentName) {
|
|
120
124
|
var _output2;
|
|
121
125
|
(_output2 = output).cssModules || (_output2.cssModules = {});
|
|
122
126
|
output.cssModules.localIdentName = cssModuleLocalIdentName;
|
|
123
127
|
}
|
|
128
|
+
if (isUseCssSourceMap(disableSourceMap)) {
|
|
129
|
+
var _output3;
|
|
130
|
+
(_output3 = output).sourceMap || (_output3.sourceMap = {});
|
|
131
|
+
output.sourceMap.css = true;
|
|
132
|
+
}
|
|
124
133
|
var _distPath;
|
|
125
134
|
(_distPath = (_output = output).distPath) !== null && _distPath !== void 0 ? _distPath : _output.distPath = {};
|
|
126
135
|
var _html1;
|
|
@@ -130,8 +139,8 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
130
139
|
var _polyfill;
|
|
131
140
|
(_polyfill = (_output1 = output).polyfill) !== null && _polyfill !== void 0 ? _polyfill : _output1.polyfill = "entry";
|
|
132
141
|
if (disableCssModuleExtension) {
|
|
133
|
-
var
|
|
134
|
-
(
|
|
142
|
+
var _output4, _output_cssModules;
|
|
143
|
+
(_output4 = output).cssModules || (_output4.cssModules = {});
|
|
135
144
|
var _auto;
|
|
136
145
|
(_auto = (_output_cssModules = output.cssModules).auto) !== null && _auto !== void 0 ? _auto : _output_cssModules.auto = isLooseCssModules;
|
|
137
146
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -122,10 +122,6 @@ export type UniBuilderExtraConfig = {
|
|
|
122
122
|
resolveExtensionPrefix?: string | Partial<Record<RsbuildTarget, string>>;
|
|
123
123
|
};
|
|
124
124
|
output?: {
|
|
125
|
-
/**
|
|
126
|
-
* @deprecated use `source.decorators` instead
|
|
127
|
-
*/
|
|
128
|
-
enableLatestDecorators?: boolean;
|
|
129
125
|
/**
|
|
130
126
|
* @deprecated use `output.cssModules.localIdentName` instead
|
|
131
127
|
*/
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import { type RsbuildPlugin } from '@rsbuild/shared';
|
|
2
2
|
import { type PluginBabelOptions } from '@rsbuild/plugin-babel';
|
|
3
|
+
export declare const getPresetReact: (rootPath: string, isProd: boolean) => (string | {
|
|
4
|
+
development: boolean;
|
|
5
|
+
useBuiltIns: boolean;
|
|
6
|
+
useSpread: boolean;
|
|
7
|
+
runtime: string;
|
|
8
|
+
})[];
|
|
3
9
|
export declare const pluginBabel: (options?: PluginBabelOptions) => RsbuildPlugin;
|
|
@@ -28,22 +28,36 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var babel_exports = {};
|
|
30
30
|
__export(babel_exports, {
|
|
31
|
+
getPresetReact: () => getPresetReact,
|
|
31
32
|
pluginBabel: () => pluginBabel
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(babel_exports);
|
|
34
35
|
var import_cloneDeep = __toESM(require("lodash/cloneDeep"));
|
|
35
36
|
var import_web = require("@rsbuild/babel-preset/web");
|
|
36
37
|
var import_node = require("@rsbuild/babel-preset/node");
|
|
37
|
-
var
|
|
38
|
+
var import_utils = require("@modern-js/utils");
|
|
38
39
|
var import_shared = require("@rsbuild/shared");
|
|
39
40
|
var import_plugin_babel = require("@rsbuild/plugin-babel");
|
|
41
|
+
const getPresetReact = (rootPath, isProd) => {
|
|
42
|
+
const isNewJsx = (0, import_utils.isBeyondReact17)(rootPath);
|
|
43
|
+
const presetReactOptions = {
|
|
44
|
+
development: !isProd,
|
|
45
|
+
// Will use the native built-in instead of trying to polyfill
|
|
46
|
+
useBuiltIns: true,
|
|
47
|
+
useSpread: false,
|
|
48
|
+
runtime: isNewJsx ? "automatic" : "classic"
|
|
49
|
+
};
|
|
50
|
+
return [
|
|
51
|
+
require.resolve("@babel/preset-react"),
|
|
52
|
+
presetReactOptions
|
|
53
|
+
];
|
|
54
|
+
};
|
|
40
55
|
const pluginBabel = (options) => ({
|
|
41
56
|
name: "uni-builder:babel",
|
|
42
57
|
setup(api) {
|
|
43
58
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, target, isProd, isServer, isServiceWorker }) => {
|
|
44
59
|
const config = api.getNormalizedConfig();
|
|
45
60
|
const browserslist = await (0, import_shared.getBrowserslistWithDefault)(api.context.rootPath, config, target);
|
|
46
|
-
const isNewJsx = await (0, import_plugin_react.isBeyondReact17)(api.context.rootPath);
|
|
47
61
|
const getBabelOptions = (config2) => {
|
|
48
62
|
var _baseBabelConfig_presets;
|
|
49
63
|
const includes2 = [];
|
|
@@ -64,7 +78,9 @@ const pluginBabel = (options) => ({
|
|
|
64
78
|
}
|
|
65
79
|
}
|
|
66
80
|
};
|
|
67
|
-
const decoratorConfig =
|
|
81
|
+
const decoratorConfig = {
|
|
82
|
+
version: config2.output.enableLatestDecorators ? "2018-09" : "legacy"
|
|
83
|
+
};
|
|
68
84
|
const baseBabelConfig = isServer || isServiceWorker ? (0, import_node.getBabelConfigForNode)({
|
|
69
85
|
presetEnv: {
|
|
70
86
|
targets: [
|
|
@@ -81,17 +97,7 @@ const pluginBabel = (options) => ({
|
|
|
81
97
|
});
|
|
82
98
|
applyPluginImport(baseBabelConfig, config2.source.transformImport);
|
|
83
99
|
applyPluginLodash(baseBabelConfig, config2.performance.transformLodash);
|
|
84
|
-
|
|
85
|
-
development: !isProd,
|
|
86
|
-
// Will use the native built-in instead of trying to polyfill
|
|
87
|
-
useBuiltIns: true,
|
|
88
|
-
useSpread: false,
|
|
89
|
-
runtime: isNewJsx ? "automatic" : "classic"
|
|
90
|
-
};
|
|
91
|
-
(_baseBabelConfig_presets = baseBabelConfig.presets) === null || _baseBabelConfig_presets === void 0 ? void 0 : _baseBabelConfig_presets.push([
|
|
92
|
-
require.resolve("@babel/preset-react"),
|
|
93
|
-
presetReactOptions
|
|
94
|
-
]);
|
|
100
|
+
(_baseBabelConfig_presets = baseBabelConfig.presets) === null || _baseBabelConfig_presets === void 0 ? void 0 : _baseBabelConfig_presets.push(getPresetReact(api.context.rootPath, isProd));
|
|
95
101
|
if (isProd) {
|
|
96
102
|
var _baseBabelConfig_plugins;
|
|
97
103
|
(_baseBabelConfig_plugins = baseBabelConfig.plugins) === null || _baseBabelConfig_plugins === void 0 ? void 0 : _baseBabelConfig_plugins.push([
|
|
@@ -179,5 +185,6 @@ function applyPluginImport(config, pluginImport) {
|
|
|
179
185
|
}
|
|
180
186
|
// Annotate the CommonJS export names for ESM import in node:
|
|
181
187
|
0 && (module.exports = {
|
|
188
|
+
getPresetReact,
|
|
182
189
|
pluginBabel
|
|
183
190
|
});
|
|
@@ -34,6 +34,7 @@ module.exports = __toCommonJS(tsLoader_exports);
|
|
|
34
34
|
var import_shared = require("@rsbuild/shared");
|
|
35
35
|
var import_plugin_babel = require("@rsbuild/plugin-babel");
|
|
36
36
|
var import_web = require("@rsbuild/babel-preset/web");
|
|
37
|
+
var import_babel = require("./babel");
|
|
37
38
|
const pluginTsLoader = (options, babelOptions) => {
|
|
38
39
|
return {
|
|
39
40
|
name: "uni-builder:ts-loader",
|
|
@@ -44,7 +45,8 @@ const pluginTsLoader = (options, babelOptions) => {
|
|
|
44
45
|
"uni-builder:react"
|
|
45
46
|
],
|
|
46
47
|
setup(api) {
|
|
47
|
-
api.modifyBundlerChain(async (chain, { target, CHAIN_ID }) => {
|
|
48
|
+
api.modifyBundlerChain(async (chain, { isProd, target, CHAIN_ID }) => {
|
|
49
|
+
var _baseBabelConfig_presets;
|
|
48
50
|
const config = api.getNormalizedConfig();
|
|
49
51
|
const { rootPath } = api.context;
|
|
50
52
|
const browserslist = await (0, import_shared.getBrowserslistWithDefault)(rootPath, config, target);
|
|
@@ -54,6 +56,7 @@ const pluginTsLoader = (options, babelOptions) => {
|
|
|
54
56
|
useBuiltIns: (0, import_plugin_babel.getUseBuiltIns)(config)
|
|
55
57
|
}
|
|
56
58
|
});
|
|
59
|
+
(_baseBabelConfig_presets = baseBabelConfig.presets) === null || _baseBabelConfig_presets === void 0 ? void 0 : _baseBabelConfig_presets.push((0, import_babel.getPresetReact)(api.context.rootPath, isProd));
|
|
57
60
|
const babelUtils = (0, import_plugin_babel.getBabelUtils)(baseBabelConfig);
|
|
58
61
|
const babelLoaderOptions = (0, import_shared.mergeChainedOptions)({
|
|
59
62
|
defaults: baseBabelConfig,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/uni-builder",
|
|
3
|
-
"version": "0.0.0-nightly-
|
|
3
|
+
"version": "0.0.0-nightly-20240202170715",
|
|
4
4
|
"description": "Unified builder for Modern.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,23 +26,23 @@
|
|
|
26
26
|
"@babel/preset-react": "^7.22.15",
|
|
27
27
|
"@babel/types": "^7.23.0",
|
|
28
28
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
|
|
29
|
-
"@rsbuild/babel-preset": "0.3.
|
|
30
|
-
"@rsbuild/core": "0.3.
|
|
31
|
-
"@rsbuild/plugin-assets-retry": "0.3.
|
|
32
|
-
"@rsbuild/plugin-babel": "0.3.
|
|
33
|
-
"@rsbuild/plugin-check-syntax": "0.3.
|
|
34
|
-
"@rsbuild/plugin-css-minimizer": "0.3.
|
|
35
|
-
"@rsbuild/plugin-pug": "0.3.
|
|
36
|
-
"@rsbuild/plugin-react": "0.3.
|
|
37
|
-
"@rsbuild/plugin-rem": "0.3.
|
|
38
|
-
"@rsbuild/plugin-source-build": "0.3.
|
|
39
|
-
"@rsbuild/plugin-styled-components": "0.3.
|
|
40
|
-
"@rsbuild/plugin-svgr": "0.3.
|
|
41
|
-
"@rsbuild/plugin-type-check": "0.3.
|
|
42
|
-
"@rsbuild/plugin-toml": "0.3.
|
|
43
|
-
"@rsbuild/plugin-yaml": "0.3.
|
|
44
|
-
"@rsbuild/shared": "0.3.
|
|
45
|
-
"@rsbuild/webpack": "0.3.
|
|
29
|
+
"@rsbuild/babel-preset": "0.3.7",
|
|
30
|
+
"@rsbuild/core": "0.3.7",
|
|
31
|
+
"@rsbuild/plugin-assets-retry": "0.3.7",
|
|
32
|
+
"@rsbuild/plugin-babel": "0.3.7",
|
|
33
|
+
"@rsbuild/plugin-check-syntax": "0.3.7",
|
|
34
|
+
"@rsbuild/plugin-css-minimizer": "0.3.7",
|
|
35
|
+
"@rsbuild/plugin-pug": "0.3.7",
|
|
36
|
+
"@rsbuild/plugin-react": "0.3.7",
|
|
37
|
+
"@rsbuild/plugin-rem": "0.3.7",
|
|
38
|
+
"@rsbuild/plugin-source-build": "0.3.7",
|
|
39
|
+
"@rsbuild/plugin-styled-components": "0.3.7",
|
|
40
|
+
"@rsbuild/plugin-svgr": "0.3.7",
|
|
41
|
+
"@rsbuild/plugin-type-check": "0.3.7",
|
|
42
|
+
"@rsbuild/plugin-toml": "0.3.7",
|
|
43
|
+
"@rsbuild/plugin-yaml": "0.3.7",
|
|
44
|
+
"@rsbuild/shared": "0.3.7",
|
|
45
|
+
"@rsbuild/webpack": "0.3.7",
|
|
46
46
|
"@swc/helpers": "0.5.3",
|
|
47
47
|
"babel-loader": "9.1.3",
|
|
48
48
|
"babel-plugin-import": "1.13.5",
|
|
@@ -64,19 +64,19 @@
|
|
|
64
64
|
"webpack": "^5.89.0",
|
|
65
65
|
"webpack-manifest-plugin": "5.0.0",
|
|
66
66
|
"webpack-subresource-integrity": "5.1.0",
|
|
67
|
-
"@modern-js/utils": "0.0.0-nightly-
|
|
68
|
-
"@modern-js/server": "0.0.0-nightly-
|
|
69
|
-
"@modern-js/prod-server": "0.0.0-nightly-
|
|
67
|
+
"@modern-js/utils": "0.0.0-nightly-20240202170715",
|
|
68
|
+
"@modern-js/server": "0.0.0-nightly-20240202170715",
|
|
69
|
+
"@modern-js/prod-server": "0.0.0-nightly-20240202170715"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@rsbuild/plugin-swc": "0.3.
|
|
72
|
+
"@rsbuild/plugin-swc": "0.3.7",
|
|
73
73
|
"@types/lodash": "^4.14.202",
|
|
74
74
|
"react": "^18.2.0",
|
|
75
75
|
"react-dom": "^18.2.0",
|
|
76
76
|
"typescript": "^5.3.0",
|
|
77
|
-
"@scripts/
|
|
78
|
-
"@scripts/
|
|
79
|
-
"@modern-js/builder-plugin-node-polyfill": "0.0.0-nightly-
|
|
77
|
+
"@scripts/vitest-config": "0.0.0-nightly-20240202170715",
|
|
78
|
+
"@scripts/build": "0.0.0-nightly-20240202170715",
|
|
79
|
+
"@modern-js/builder-plugin-node-polyfill": "0.0.0-nightly-20240202170715"
|
|
80
80
|
},
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public",
|