@modern-js/uni-builder 0.0.0-nightly-20240104170621 → 0.0.0-nightly-20240105170635
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.d.ts +1 -1
- package/dist/rspack/index.js +2 -1
- package/dist/rspack/plugins/babel-post.d.ts +5 -0
- package/dist/rspack/plugins/babel-post.js +55 -0
- package/dist/shared/parseCommonConfig.js +27 -4
- package/dist/shared/plugins/splitChunk.js +2 -0
- package/dist/types.d.ts +3 -3
- package/package.json +23 -23
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
|
5
5
|
export { HtmlWebpackPlugin };
|
|
6
6
|
export type { CreateUniBuilderOptions, UniBuilderInstance, UniBuilderWebpackInstance, };
|
|
7
7
|
export type { BundlerChain, RsbuildPlugin, ChainedConfig, CopyPluginOptions, ChainIdentifier, NormalizedConfig, RspackConfig, CacheGroup, } from '@rsbuild/shared';
|
|
8
|
-
export type { UniBuilderConfig } from './types';
|
|
8
|
+
export type { UniBuilderConfig, UniBuilderPlugin } from './types';
|
|
9
9
|
export type { StartDevServerOptions } from './shared/devServer';
|
|
10
10
|
export declare function createUniBuilder(options: CreateUniBuilderOptions): Promise<UniBuilderInstance>;
|
|
11
11
|
export { logger, type Rspack, type RsbuildContext, type RsbuildConfig, } from '@rsbuild/core';
|
package/dist/rspack/index.js
CHANGED
|
@@ -45,9 +45,10 @@ async function parseConfig(uniBuilderConfig, options) {
|
|
|
45
45
|
if ((_uniBuilderConfig_tools = uniBuilderConfig.tools) === null || _uniBuilderConfig_tools === void 0 ? void 0 : _uniBuilderConfig_tools.babel) {
|
|
46
46
|
var _uniBuilderConfig_tools2;
|
|
47
47
|
const { pluginBabel } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-babel")));
|
|
48
|
+
const { pluginBabelPost } = await Promise.resolve().then(() => __toESM(require("./plugins/babel-post")));
|
|
48
49
|
rsbuildPlugins.push(pluginBabel({
|
|
49
50
|
babelLoaderOptions: (_uniBuilderConfig_tools2 = uniBuilderConfig.tools) === null || _uniBuilderConfig_tools2 === void 0 ? void 0 : _uniBuilderConfig_tools2.babel
|
|
50
|
-
}));
|
|
51
|
+
}), pluginBabelPost());
|
|
51
52
|
}
|
|
52
53
|
if (((_uniBuilderConfig_tools1 = uniBuilderConfig.tools) === null || _uniBuilderConfig_tools1 === void 0 ? void 0 : _uniBuilderConfig_tools1.styledComponents) !== false) {
|
|
53
54
|
var _uniBuilderConfig_tools3;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var babel_post_exports = {};
|
|
30
|
+
__export(babel_post_exports, {
|
|
31
|
+
pluginBabelPost: () => pluginBabelPost
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(babel_post_exports);
|
|
34
|
+
var import_isEqual = __toESM(require("lodash/isEqual"));
|
|
35
|
+
var import_plugin_babel = require("@rsbuild/plugin-babel");
|
|
36
|
+
const pluginBabelPost = () => ({
|
|
37
|
+
name: "uni-builder:babel-post",
|
|
38
|
+
pre: [
|
|
39
|
+
"rsbuild:babel"
|
|
40
|
+
],
|
|
41
|
+
setup(api) {
|
|
42
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
|
|
43
|
+
if (chain.module.rules.get(CHAIN_ID.RULE.JS)) {
|
|
44
|
+
const babelLoaderOptions = chain.module.rule(CHAIN_ID.RULE.JS).use(CHAIN_ID.USE.BABEL).get("options");
|
|
45
|
+
if (babelLoaderOptions && (0, import_isEqual.default)((0, import_plugin_babel.getDefaultBabelOptions)(), babelLoaderOptions)) {
|
|
46
|
+
chain.module.rule(CHAIN_ID.RULE.JS).uses.delete(CHAIN_ID.USE.BABEL);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
pluginBabelPost
|
|
55
|
+
});
|
|
@@ -91,8 +91,8 @@ async function getBrowserslistWithDefault(path, config, target) {
|
|
|
91
91
|
return DEFAULT_BROWSERSLIST[target];
|
|
92
92
|
}
|
|
93
93
|
async function parseCommonConfig(uniBuilderConfig, options) {
|
|
94
|
-
var _uniBuilderConfig_output, _uniBuilderConfig_output1, _uniBuilderConfig_output2, _uniBuilderConfig_html, _uniBuilderConfig_html1, _uniBuilderConfig_html2, _uniBuilderConfig_html3, _uniBuilderConfig_html4, _uniBuilderConfig_html5,
|
|
95
|
-
var _output, _output_distPath, _output1, _extraConfig, _html;
|
|
94
|
+
var _uniBuilderConfig_output, _uniBuilderConfig_output1, _uniBuilderConfig_output2, _uniBuilderConfig_html, _uniBuilderConfig_html1, _uniBuilderConfig_html2, _uniBuilderConfig_html3, _uniBuilderConfig_html4, _uniBuilderConfig_html5, _devServer_devMiddleware, _uniBuilderConfig_source, _uniBuilderConfig_output3, _uniBuilderConfig_security, _uniBuilderConfig_output4, _uniBuilderConfig_output5, _uniBuilderConfig_source1, _uniBuilderConfig_source2, _uniBuilderConfig_output6, _uniBuilderConfig_output7, _uniBuilderConfig_experiments, _uniBuilderConfig_tools, _uniBuilderConfig_output8, _uniBuilderConfig_output9, _uniBuilderConfig_tools1;
|
|
95
|
+
var _output, _output_distPath, _output1, _extraConfig, _html, _extraConfig1;
|
|
96
96
|
const { cwd, frameworkConfigPath, entry, target } = options;
|
|
97
97
|
const rsbuildConfig = (0, import_shared.deepmerge)({}, uniBuilderConfig);
|
|
98
98
|
const { dev = {}, html = {}, output = {}, tools = {} } = rsbuildConfig;
|
|
@@ -169,11 +169,34 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
169
169
|
extraConfig.html.templateParameters = (_, { entryName }) => uniBuilderConfig.html.templateParametersByEntries[entryName];
|
|
170
170
|
delete html.templateParametersByEntries;
|
|
171
171
|
}
|
|
172
|
+
var _tools;
|
|
173
|
+
(_tools = (_extraConfig1 = extraConfig).tools) !== null && _tools !== void 0 ? _tools : _extraConfig1.tools = {};
|
|
174
|
+
extraConfig.tools.htmlPlugin = (config) => {
|
|
175
|
+
if (typeof config.templateParameters === "function") {
|
|
176
|
+
const originFn = config.templateParameters;
|
|
177
|
+
config.templateParameters = (...args) => {
|
|
178
|
+
const res = originFn(...args);
|
|
179
|
+
return {
|
|
180
|
+
title: config.title,
|
|
181
|
+
meta: void 0,
|
|
182
|
+
...res
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
};
|
|
172
187
|
if (dev.progressBar === void 0) {
|
|
173
188
|
dev.progressBar = true;
|
|
174
189
|
}
|
|
175
|
-
|
|
176
|
-
|
|
190
|
+
const devServer = (0, import_shared.mergeChainedOptions)({
|
|
191
|
+
defaults: {
|
|
192
|
+
devMiddleware: {
|
|
193
|
+
writeToDisk: (file) => !file.includes(".hot-update.")
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
options: tools.devServer,
|
|
197
|
+
mergeFn: import_shared.deepmerge
|
|
198
|
+
});
|
|
199
|
+
dev.writeToDisk = (_devServer_devMiddleware = devServer.devMiddleware) === null || _devServer_devMiddleware === void 0 ? void 0 : _devServer_devMiddleware.writeToDisk;
|
|
177
200
|
const server = (0, import_shared.isProd)() ? {} : {
|
|
178
201
|
port: dev.port,
|
|
179
202
|
host: dev.host
|
|
@@ -57,6 +57,8 @@ const pluginSplitChunks = () => ({
|
|
|
57
57
|
}
|
|
58
58
|
chain.optimization.splitChunks({
|
|
59
59
|
...currentConfig,
|
|
60
|
+
// rspack chunks type mismatch with webpack
|
|
61
|
+
// @ts-expect-error
|
|
60
62
|
cacheGroups: {
|
|
61
63
|
...currentConfig.cacheGroups,
|
|
62
64
|
...(0, import_shared.createCacheGroups)(groups)
|
package/dist/types.d.ts
CHANGED
|
@@ -42,13 +42,13 @@ export type DisableSourceMapOption = boolean | {
|
|
|
42
42
|
export type UniBuilderExtraConfig = {
|
|
43
43
|
tools?: {
|
|
44
44
|
styledComponents?: false | PluginStyledComponentsOptions;
|
|
45
|
-
devServer?: {
|
|
45
|
+
devServer?: ChainedConfig<{
|
|
46
46
|
before?: RequestHandler[];
|
|
47
47
|
after?: RequestHandler[];
|
|
48
48
|
client?: DevConfig['client'];
|
|
49
49
|
compress?: ServerConfig['compress'];
|
|
50
50
|
devMiddleware?: {
|
|
51
|
-
writeToDisk
|
|
51
|
+
writeToDisk?: DevConfig['writeToDisk'];
|
|
52
52
|
};
|
|
53
53
|
headers?: ServerConfig['headers'];
|
|
54
54
|
historyApiFallback?: ServerConfig['historyApiFallback'];
|
|
@@ -56,7 +56,7 @@ export type UniBuilderExtraConfig = {
|
|
|
56
56
|
https?: DevServerHttpsOptions;
|
|
57
57
|
setupMiddlewares?: DevConfig['setupMiddlewares'];
|
|
58
58
|
proxy?: ServerConfig['proxy'];
|
|
59
|
-
}
|
|
59
|
+
}>;
|
|
60
60
|
/**
|
|
61
61
|
* Configure the [Pug](https://pugjs.org/) template engine.
|
|
62
62
|
*/
|
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-20240105170635",
|
|
4
4
|
"description": "Unified builder for Modern.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,21 +26,21 @@
|
|
|
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.2.
|
|
30
|
-
"@rsbuild/core": "0.2.
|
|
31
|
-
"@rsbuild/plugin-assets-retry": "0.2.
|
|
32
|
-
"@rsbuild/plugin-babel": "0.2.
|
|
33
|
-
"@rsbuild/plugin-check-syntax": "0.2.
|
|
34
|
-
"@rsbuild/plugin-css-minimizer": "0.2.
|
|
35
|
-
"@rsbuild/plugin-pug": "0.2.
|
|
36
|
-
"@rsbuild/plugin-react": "0.2.
|
|
37
|
-
"@rsbuild/plugin-rem": "0.2.
|
|
38
|
-
"@rsbuild/plugin-source-build": "0.2.
|
|
39
|
-
"@rsbuild/plugin-styled-components": "0.2.
|
|
40
|
-
"@rsbuild/plugin-svgr": "0.2.
|
|
41
|
-
"@rsbuild/plugin-type-check": "0.2.
|
|
42
|
-
"@rsbuild/shared": "0.2.
|
|
43
|
-
"@rsbuild/webpack": "0.2.
|
|
29
|
+
"@rsbuild/babel-preset": "0.2.17",
|
|
30
|
+
"@rsbuild/core": "0.2.17",
|
|
31
|
+
"@rsbuild/plugin-assets-retry": "0.2.17",
|
|
32
|
+
"@rsbuild/plugin-babel": "0.2.17",
|
|
33
|
+
"@rsbuild/plugin-check-syntax": "0.2.17",
|
|
34
|
+
"@rsbuild/plugin-css-minimizer": "0.2.17",
|
|
35
|
+
"@rsbuild/plugin-pug": "0.2.17",
|
|
36
|
+
"@rsbuild/plugin-react": "0.2.17",
|
|
37
|
+
"@rsbuild/plugin-rem": "0.2.17",
|
|
38
|
+
"@rsbuild/plugin-source-build": "0.2.17",
|
|
39
|
+
"@rsbuild/plugin-styled-components": "0.2.17",
|
|
40
|
+
"@rsbuild/plugin-svgr": "0.2.17",
|
|
41
|
+
"@rsbuild/plugin-type-check": "0.2.17",
|
|
42
|
+
"@rsbuild/shared": "0.2.17",
|
|
43
|
+
"@rsbuild/webpack": "0.2.17",
|
|
44
44
|
"@swc/helpers": "0.5.3",
|
|
45
45
|
"babel-loader": "9.1.3",
|
|
46
46
|
"babel-plugin-import": "1.13.5",
|
|
@@ -62,19 +62,19 @@
|
|
|
62
62
|
"webpack": "^5.89.0",
|
|
63
63
|
"webpack-manifest-plugin": "5.0.0",
|
|
64
64
|
"webpack-subresource-integrity": "5.1.0",
|
|
65
|
-
"@modern-js/utils": "0.0.0-nightly-
|
|
66
|
-
"@modern-js/server": "0.0.0-nightly-
|
|
67
|
-
"@modern-js/prod-server": "0.0.0-nightly-
|
|
65
|
+
"@modern-js/utils": "0.0.0-nightly-20240105170635",
|
|
66
|
+
"@modern-js/server": "0.0.0-nightly-20240105170635",
|
|
67
|
+
"@modern-js/prod-server": "0.0.0-nightly-20240105170635"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@rsbuild/plugin-swc": "0.2.
|
|
70
|
+
"@rsbuild/plugin-swc": "0.2.17",
|
|
71
71
|
"@types/lodash": "^4.14.202",
|
|
72
72
|
"react": "^18.2.0",
|
|
73
73
|
"react-dom": "^18.2.0",
|
|
74
74
|
"typescript": "^5.3.0",
|
|
75
|
-
"@
|
|
76
|
-
"@scripts/build": "0.0.0-nightly-
|
|
77
|
-
"@
|
|
75
|
+
"@scripts/vitest-config": "0.0.0-nightly-20240105170635",
|
|
76
|
+
"@scripts/build": "0.0.0-nightly-20240105170635",
|
|
77
|
+
"@modern-js/builder-plugin-node-polyfill": "0.0.0-nightly-20240105170635"
|
|
78
78
|
},
|
|
79
79
|
"publishConfig": {
|
|
80
80
|
"access": "public",
|