@modern-js/uni-builder 0.0.0-nightly-20240201170631 → 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.
|
@@ -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 = [];
|
|
@@ -83,17 +97,7 @@ const pluginBabel = (options) => ({
|
|
|
83
97
|
});
|
|
84
98
|
applyPluginImport(baseBabelConfig, config2.source.transformImport);
|
|
85
99
|
applyPluginLodash(baseBabelConfig, config2.performance.transformLodash);
|
|
86
|
-
|
|
87
|
-
development: !isProd,
|
|
88
|
-
// Will use the native built-in instead of trying to polyfill
|
|
89
|
-
useBuiltIns: true,
|
|
90
|
-
useSpread: false,
|
|
91
|
-
runtime: isNewJsx ? "automatic" : "classic"
|
|
92
|
-
};
|
|
93
|
-
(_baseBabelConfig_presets = baseBabelConfig.presets) === null || _baseBabelConfig_presets === void 0 ? void 0 : _baseBabelConfig_presets.push([
|
|
94
|
-
require.resolve("@babel/preset-react"),
|
|
95
|
-
presetReactOptions
|
|
96
|
-
]);
|
|
100
|
+
(_baseBabelConfig_presets = baseBabelConfig.presets) === null || _baseBabelConfig_presets === void 0 ? void 0 : _baseBabelConfig_presets.push(getPresetReact(api.context.rootPath, isProd));
|
|
97
101
|
if (isProd) {
|
|
98
102
|
var _baseBabelConfig_plugins;
|
|
99
103
|
(_baseBabelConfig_plugins = baseBabelConfig.plugins) === null || _baseBabelConfig_plugins === void 0 ? void 0 : _baseBabelConfig_plugins.push([
|
|
@@ -181,5 +185,6 @@ function applyPluginImport(config, pluginImport) {
|
|
|
181
185
|
}
|
|
182
186
|
// Annotate the CommonJS export names for ESM import in node:
|
|
183
187
|
0 && (module.exports = {
|
|
188
|
+
getPresetReact,
|
|
184
189
|
pluginBabel
|
|
185
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",
|
|
@@ -64,9 +64,9 @@
|
|
|
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
72
|
"@rsbuild/plugin-swc": "0.3.7",
|
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
"react": "^18.2.0",
|
|
75
75
|
"react-dom": "^18.2.0",
|
|
76
76
|
"typescript": "^5.3.0",
|
|
77
|
-
"@
|
|
78
|
-
"@scripts/build": "0.0.0-nightly-
|
|
79
|
-
"@
|
|
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",
|