@modern-js/builder 2.35.0 → 2.36.0
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/cli/commands.js +34 -17
- package/dist/cli/config.js +49 -28
- package/dist/cli/index.js +35 -24
- package/dist/cli/provider.js +42 -23
- package/dist/createBuilder.js +33 -16
- package/dist/index.js +30 -21
- package/dist/plugins/antd.js +27 -17
- package/dist/plugins/arco.js +30 -14
- package/dist/plugins/asset.js +41 -15
- package/dist/plugins/assetsRetry.js +38 -12
- package/dist/plugins/bundleAnalyzer.js +35 -9
- package/dist/plugins/cache.js +49 -24
- package/dist/plugins/checkSyntax.js +37 -11
- package/dist/plugins/cleanOutput.js +35 -9
- package/dist/plugins/define.d.ts +2 -0
- package/dist/plugins/define.js +66 -0
- package/dist/plugins/devtool.js +26 -9
- package/dist/plugins/entry.js +36 -10
- package/dist/plugins/externals.js +24 -7
- package/dist/plugins/fileSize.js +66 -40
- package/dist/plugins/html.js +63 -46
- package/dist/plugins/index.js +67 -40
- package/dist/plugins/inlineChunk.js +41 -15
- package/dist/plugins/moment.js +24 -7
- package/dist/plugins/networkPerformance.js +27 -10
- package/dist/plugins/nodeAddons.js +39 -14
- package/dist/plugins/performance.js +24 -7
- package/dist/plugins/preloadOrPrefetch.js +27 -10
- package/dist/plugins/rem.js +40 -15
- package/dist/plugins/sourceBuild.d.ts +1 -1
- package/dist/plugins/sourceBuild.js +45 -27
- package/dist/plugins/splitChunks.js +55 -37
- package/dist/plugins/startUrl.js +39 -21
- package/dist/plugins/svg.js +51 -29
- package/dist/plugins/target.js +26 -9
- package/dist/plugins/toml.js +26 -9
- package/dist/plugins/tsChecker.js +39 -14
- package/dist/plugins/wasm.js +28 -11
- package/dist/plugins/yaml.js +26 -9
- package/package.json +17 -9
package/dist/plugins/moment.js
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var moment_exports = {};
|
|
20
|
+
__export(moment_exports, {
|
|
21
|
+
builderPluginMoment: () => builderPluginMoment
|
|
10
22
|
});
|
|
23
|
+
module.exports = __toCommonJS(moment_exports);
|
|
11
24
|
const builderPluginMoment = () => ({
|
|
12
25
|
name: "builder-plugin-moment",
|
|
13
26
|
setup(api) {
|
|
@@ -24,3 +37,7 @@ const builderPluginMoment = () => ({
|
|
|
24
37
|
});
|
|
25
38
|
}
|
|
26
39
|
});
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
builderPluginMoment
|
|
43
|
+
});
|
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var networkPerformance_exports = {};
|
|
20
|
+
__export(networkPerformance_exports, {
|
|
21
|
+
builderPluginNetworkPerformance: () => builderPluginNetworkPerformance
|
|
10
22
|
});
|
|
11
|
-
|
|
23
|
+
module.exports = __toCommonJS(networkPerformance_exports);
|
|
24
|
+
var import_builder_shared = require("@modern-js/builder-shared");
|
|
12
25
|
const builderPluginNetworkPerformance = () => ({
|
|
13
26
|
name: `builder-plugin-network-performance`,
|
|
14
27
|
setup(api) {
|
|
@@ -19,14 +32,14 @@ const builderPluginNetworkPerformance = () => ({
|
|
|
19
32
|
return;
|
|
20
33
|
}
|
|
21
34
|
if (dnsPrefetch) {
|
|
22
|
-
chain.plugin(CHAIN_ID.PLUGIN.HTML_DNS_PREFETCH).use(
|
|
35
|
+
chain.plugin(CHAIN_ID.PLUGIN.HTML_DNS_PREFETCH).use(import_builder_shared.HtmlNetworkPerformancePlugin, [
|
|
23
36
|
dnsPrefetch,
|
|
24
37
|
"dnsPrefetch",
|
|
25
38
|
HtmlPlugin
|
|
26
39
|
]);
|
|
27
40
|
}
|
|
28
41
|
if (preconnect) {
|
|
29
|
-
chain.plugin(CHAIN_ID.PLUGIN.HTML_PRECONNECT).use(
|
|
42
|
+
chain.plugin(CHAIN_ID.PLUGIN.HTML_PRECONNECT).use(import_builder_shared.HtmlNetworkPerformancePlugin, [
|
|
30
43
|
preconnect,
|
|
31
44
|
"preconnect",
|
|
32
45
|
HtmlPlugin
|
|
@@ -35,3 +48,7 @@ const builderPluginNetworkPerformance = () => ({
|
|
|
35
48
|
});
|
|
36
49
|
}
|
|
37
50
|
});
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
builderPluginNetworkPerformance
|
|
54
|
+
});
|
|
@@ -1,15 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 });
|
|
9
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 nodeAddons_exports = {};
|
|
30
|
+
__export(nodeAddons_exports, {
|
|
31
|
+
builderPluginNodeAddons: () => builderPluginNodeAddons
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
33
|
+
module.exports = __toCommonJS(nodeAddons_exports);
|
|
34
|
+
var import_builder_shared = require("@modern-js/builder-shared");
|
|
13
35
|
const builderPluginNodeAddons = () => ({
|
|
14
36
|
name: "builder-plugin-node-addons",
|
|
15
37
|
setup(api) {
|
|
@@ -17,7 +39,7 @@ const builderPluginNodeAddons = () => ({
|
|
|
17
39
|
if (!isServer && !isServiceWorker) {
|
|
18
40
|
return;
|
|
19
41
|
}
|
|
20
|
-
const { chalk, pkgUp } = await Promise.resolve().then(() =>
|
|
42
|
+
const { chalk, pkgUp } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
21
43
|
const getDistName = (resource) => {
|
|
22
44
|
const pkgJSON = pkgUp.sync({
|
|
23
45
|
cwd: resource
|
|
@@ -26,10 +48,9 @@ const builderPluginNodeAddons = () => ({
|
|
|
26
48
|
throw new Error(`Failed to compile Node.js addons, couldn't find the package.json of ${chalk.yellow(resource)}.`);
|
|
27
49
|
}
|
|
28
50
|
const getFilename = (resource2, pkgName2) => {
|
|
29
|
-
var _match;
|
|
30
51
|
const reg = new RegExp(`node_modules/${pkgName2}/(.+)`);
|
|
31
52
|
const match = resource2.match(reg);
|
|
32
|
-
const filename =
|
|
53
|
+
const filename = match === null || match === void 0 ? void 0 : match[1];
|
|
33
54
|
if (!filename) {
|
|
34
55
|
return "[name].[ext]";
|
|
35
56
|
}
|
|
@@ -37,12 +58,16 @@ const builderPluginNodeAddons = () => ({
|
|
|
37
58
|
};
|
|
38
59
|
const { name: pkgName } = require(pkgJSON);
|
|
39
60
|
const config = api.getNormalizedConfig();
|
|
40
|
-
const serverPath = (0,
|
|
61
|
+
const serverPath = (0, import_builder_shared.getDistPath)(config.output, "server");
|
|
41
62
|
return `${serverPath}/${getFilename(resource, pkgName)}`;
|
|
42
63
|
};
|
|
43
|
-
chain.module.rule(CHAIN_ID.RULE.NODE).test(/\.node$/).use(CHAIN_ID.USE.NODE).loader((0,
|
|
64
|
+
chain.module.rule(CHAIN_ID.RULE.NODE).test(/\.node$/).use(CHAIN_ID.USE.NODE).loader((0, import_builder_shared.getSharedPkgCompiledPath)("node-loader")).options({
|
|
44
65
|
name: getDistName
|
|
45
66
|
});
|
|
46
67
|
});
|
|
47
68
|
}
|
|
48
69
|
});
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
builderPluginNodeAddons
|
|
73
|
+
});
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var performance_exports = {};
|
|
20
|
+
__export(performance_exports, {
|
|
21
|
+
builderPluginPerformance: () => builderPluginPerformance
|
|
10
22
|
});
|
|
23
|
+
module.exports = __toCommonJS(performance_exports);
|
|
11
24
|
function applyProfile({ chain, config }) {
|
|
12
25
|
const { profile } = config.performance;
|
|
13
26
|
if (!profile) {
|
|
@@ -47,3 +60,7 @@ const builderPluginPerformance = () => ({
|
|
|
47
60
|
});
|
|
48
61
|
}
|
|
49
62
|
});
|
|
63
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
+
0 && (module.exports = {
|
|
65
|
+
builderPluginPerformance
|
|
66
|
+
});
|
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var preloadOrPrefetch_exports = {};
|
|
20
|
+
__export(preloadOrPrefetch_exports, {
|
|
21
|
+
builderPluginPreloadOrPrefetch: () => builderPluginPreloadOrPrefetch
|
|
10
22
|
});
|
|
11
|
-
|
|
23
|
+
module.exports = __toCommonJS(preloadOrPrefetch_exports);
|
|
24
|
+
var import_builder_shared = require("@modern-js/builder-shared");
|
|
12
25
|
const builderPluginPreloadOrPrefetch = () => ({
|
|
13
26
|
name: `builder-plugin-preload-or-prefetch`,
|
|
14
27
|
setup(api) {
|
|
@@ -20,7 +33,7 @@ const builderPluginPreloadOrPrefetch = () => ({
|
|
|
20
33
|
}
|
|
21
34
|
const HTMLCount = chain.entryPoints.values().length;
|
|
22
35
|
if (prefetch) {
|
|
23
|
-
chain.plugin(CHAIN_ID.PLUGIN.HTML_PREFETCH).use(
|
|
36
|
+
chain.plugin(CHAIN_ID.PLUGIN.HTML_PREFETCH).use(import_builder_shared.HTMLPreloadOrPrefetchPlugin, [
|
|
24
37
|
prefetch,
|
|
25
38
|
"prefetch",
|
|
26
39
|
HtmlPlugin,
|
|
@@ -28,7 +41,7 @@ const builderPluginPreloadOrPrefetch = () => ({
|
|
|
28
41
|
]);
|
|
29
42
|
}
|
|
30
43
|
if (preload) {
|
|
31
|
-
chain.plugin(CHAIN_ID.PLUGIN.HTML_PRELOAD).use(
|
|
44
|
+
chain.plugin(CHAIN_ID.PLUGIN.HTML_PRELOAD).use(import_builder_shared.HTMLPreloadOrPrefetchPlugin, [
|
|
32
45
|
preload,
|
|
33
46
|
"preload",
|
|
34
47
|
HtmlPlugin,
|
|
@@ -38,3 +51,7 @@ const builderPluginPreloadOrPrefetch = () => ({
|
|
|
38
51
|
});
|
|
39
52
|
}
|
|
40
53
|
});
|
|
54
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
55
|
+
0 && (module.exports = {
|
|
56
|
+
builderPluginPreloadOrPrefetch
|
|
57
|
+
});
|
package/dist/plugins/rem.js
CHANGED
|
@@ -1,17 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 });
|
|
9
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 rem_exports = {};
|
|
30
|
+
__export(rem_exports, {
|
|
31
|
+
builderPluginRem: () => builderPluginRem
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const _buildershared = require("@modern-js/builder-shared");
|
|
33
|
+
module.exports = __toCommonJS(rem_exports);
|
|
34
|
+
var import_lodash = __toESM(require("@modern-js/utils/lodash"));
|
|
35
|
+
var import_builder_shared = require("@modern-js/builder-shared");
|
|
15
36
|
const defaultOptions = {
|
|
16
37
|
enableRuntime: true,
|
|
17
38
|
rootFontSize: 50
|
|
@@ -35,7 +56,7 @@ const builderPluginRem = () => ({
|
|
|
35
56
|
...defaultOptions,
|
|
36
57
|
...typeof convertToRem === "boolean" ? {} : convertToRem
|
|
37
58
|
};
|
|
38
|
-
const { default: PxToRemPlugin } = await Promise.resolve((0,
|
|
59
|
+
const { default: PxToRemPlugin } = await Promise.resolve().then(() => __toESM(require((0, import_builder_shared.getSharedPkgCompiledPath)("postcss-pxtorem"))));
|
|
39
60
|
const applyRules = [
|
|
40
61
|
CHAIN_ID.RULE.CSS,
|
|
41
62
|
CHAIN_ID.RULE.LESS,
|
|
@@ -48,7 +69,7 @@ const builderPluginRem = () => ({
|
|
|
48
69
|
propList: [
|
|
49
70
|
"*"
|
|
50
71
|
],
|
|
51
|
-
...
|
|
72
|
+
...import_lodash.default.cloneDeep(userOptions.pxtorem || {})
|
|
52
73
|
});
|
|
53
74
|
applyRules.forEach((name) => {
|
|
54
75
|
chain.module.rules.has(name) && chain.module.rule(name).use(CHAIN_ID.USE.POSTCSS).tap((options = {}) => {
|
|
@@ -69,8 +90,8 @@ const builderPluginRem = () => ({
|
|
|
69
90
|
return;
|
|
70
91
|
}
|
|
71
92
|
const entries = Object.keys(chain.entryPoints.entries() || {});
|
|
72
|
-
const distDir = (0,
|
|
73
|
-
chain.plugin(CHAIN_ID.PLUGIN.AUTO_SET_ROOT_SIZE).use(
|
|
93
|
+
const distDir = (0, import_builder_shared.getDistPath)(config.output, "js");
|
|
94
|
+
chain.plugin(CHAIN_ID.PLUGIN.AUTO_SET_ROOT_SIZE).use(import_builder_shared.AutoSetRootFontSizePlugin, [
|
|
74
95
|
userOptions,
|
|
75
96
|
entries,
|
|
76
97
|
HtmlPlugin,
|
|
@@ -79,3 +100,7 @@ const builderPluginRem = () => ({
|
|
|
79
100
|
});
|
|
80
101
|
}
|
|
81
102
|
});
|
|
103
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
104
|
+
0 && (module.exports = {
|
|
105
|
+
builderPluginRem
|
|
106
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type BuilderPlugin } from '@modern-js/builder-shared';
|
|
2
2
|
import type { BuilderPluginAPI as WebpackBuilderPluginAPI } from '@modern-js/builder-webpack-provider';
|
|
3
3
|
import type { BuilderPluginAPI as RspackBuilderPluginAPI } from '@modern-js/builder-rspack-provider';
|
|
4
|
-
import { type Project, type ExtraMonorepoStrategies } from '@
|
|
4
|
+
import { type Project, type ExtraMonorepoStrategies } from '@rsbuild/monorepo-utils';
|
|
5
5
|
export declare const pluginName = "builder-plugin-source-build";
|
|
6
6
|
export declare const getSourceInclude: (options: {
|
|
7
7
|
projects: Project[];
|
|
@@ -1,31 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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) => {
|
|
6
9
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return pluginName;
|
|
15
|
-
},
|
|
16
|
-
getSourceInclude: function() {
|
|
17
|
-
return getSourceInclude;
|
|
18
|
-
},
|
|
19
|
-
builderPluginSourceBuild: function() {
|
|
20
|
-
return builderPluginSourceBuild;
|
|
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 });
|
|
21
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 sourceBuild_exports = {};
|
|
30
|
+
__export(sourceBuild_exports, {
|
|
31
|
+
builderPluginSourceBuild: () => builderPluginSourceBuild,
|
|
32
|
+
getSourceInclude: () => getSourceInclude,
|
|
33
|
+
pluginName: () => pluginName
|
|
22
34
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const log = (0,
|
|
35
|
+
module.exports = __toCommonJS(sourceBuild_exports);
|
|
36
|
+
var import_builder_shared = require("@modern-js/builder-shared");
|
|
37
|
+
var import_monorepo_utils = require("@rsbuild/monorepo-utils");
|
|
38
|
+
var import_utils = require("@modern-js/utils");
|
|
39
|
+
var import_path = __toESM(require("path"));
|
|
40
|
+
const log = (0, import_utils.debug)("BUILDER_PLUGIN_SOURCE_BUILD");
|
|
29
41
|
const pluginName = "builder-plugin-source-build";
|
|
30
42
|
const getSourceInclude = async (options) => {
|
|
31
43
|
const { projects, sourceField } = options;
|
|
@@ -52,10 +64,10 @@ function builderPluginSourceBuild(options) {
|
|
|
52
64
|
if (!sourceBuild) {
|
|
53
65
|
return;
|
|
54
66
|
}
|
|
55
|
-
projects = await (0,
|
|
67
|
+
projects = await (0, import_monorepo_utils.getDependentProjects)(projectName || projectRootPath, {
|
|
56
68
|
cwd: projectRootPath,
|
|
57
69
|
recursive: true,
|
|
58
|
-
filter: (0,
|
|
70
|
+
filter: (0, import_monorepo_utils.filterByField)(sourceField),
|
|
59
71
|
extraMonorepoStrategies
|
|
60
72
|
});
|
|
61
73
|
const includes = await getSourceInclude({
|
|
@@ -89,7 +101,7 @@ function builderPluginSourceBuild(options) {
|
|
|
89
101
|
const { TS_CONFIG_PATHS } = CHAIN_ID.RESOLVE_PLUGIN;
|
|
90
102
|
if (chain.resolve.plugins.has(TS_CONFIG_PATHS)) {
|
|
91
103
|
chain.resolve.plugin(TS_CONFIG_PATHS).tap((options2) => {
|
|
92
|
-
const references = projects.map((project) =>
|
|
104
|
+
const references = projects.map((project) => import_path.default.join(project.dir, import_builder_shared.TS_CONFIG_FILE)).filter((filePath) => import_utils.fs.existsSync(filePath)).map((filePath) => import_path.default.relative(projectRootPath, filePath));
|
|
93
105
|
return options2.map((option) => ({
|
|
94
106
|
...option,
|
|
95
107
|
references
|
|
@@ -101,3 +113,9 @@ function builderPluginSourceBuild(options) {
|
|
|
101
113
|
}
|
|
102
114
|
};
|
|
103
115
|
}
|
|
116
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
117
|
+
0 && (module.exports = {
|
|
118
|
+
builderPluginSourceBuild,
|
|
119
|
+
getSourceInclude,
|
|
120
|
+
pluginName
|
|
121
|
+
});
|
|
@@ -1,26 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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) => {
|
|
6
9
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return createDependenciesRegExp;
|
|
15
|
-
},
|
|
16
|
-
builderPluginSplitChunks: function() {
|
|
17
|
-
return builderPluginSplitChunks;
|
|
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 });
|
|
18
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 splitChunks_exports = {};
|
|
30
|
+
__export(splitChunks_exports, {
|
|
31
|
+
builderPluginSplitChunks: () => builderPluginSplitChunks,
|
|
32
|
+
createDependenciesRegExp: () => createDependenciesRegExp
|
|
19
33
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const _buildershared = require("@modern-js/builder-shared");
|
|
34
|
+
module.exports = __toCommonJS(splitChunks_exports);
|
|
35
|
+
var import_assert = __toESM(require("assert"));
|
|
36
|
+
var import_builder_shared = require("@modern-js/builder-shared");
|
|
24
37
|
function getUserDefinedCacheGroups(forceSplitting) {
|
|
25
38
|
const cacheGroups = {};
|
|
26
39
|
const pairs = Array.isArray(forceSplitting) ? forceSplitting.map((regexp, index) => [
|
|
@@ -45,7 +58,7 @@ const createDependenciesRegExp = (...dependencies) => {
|
|
|
45
58
|
return new RegExp(expr);
|
|
46
59
|
};
|
|
47
60
|
async function splitByExperience(ctx) {
|
|
48
|
-
const { isPackageInstalled } = await Promise.resolve().then(() =>
|
|
61
|
+
const { isPackageInstalled } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
49
62
|
const { override, polyfill, rootPath, defaultConfig, userDefinedCacheGroups } = ctx;
|
|
50
63
|
const experienceCacheGroup = {};
|
|
51
64
|
const packageRegExps = {
|
|
@@ -64,7 +77,7 @@ async function splitByExperience(ctx) {
|
|
|
64
77
|
packageRegExps.semi = createDependenciesRegExp(/@(ies|douyinfe)[\\/]semi-.*/);
|
|
65
78
|
}
|
|
66
79
|
if (polyfill === "entry" || polyfill === "usage") {
|
|
67
|
-
packageRegExps.polyfill = createDependenciesRegExp("core-js", "@babel/runtime", "@swc/helpers");
|
|
80
|
+
packageRegExps.polyfill = createDependenciesRegExp("tslib", "core-js", "@babel/runtime", "@swc/helpers");
|
|
68
81
|
}
|
|
69
82
|
Object.entries(packageRegExps).forEach(([name, test]) => {
|
|
70
83
|
const key = `lib-${name}`;
|
|
@@ -75,8 +88,8 @@ async function splitByExperience(ctx) {
|
|
|
75
88
|
reuseExistingChunk: true
|
|
76
89
|
};
|
|
77
90
|
});
|
|
78
|
-
(0,
|
|
79
|
-
(0,
|
|
91
|
+
(0, import_assert.default)(defaultConfig !== false);
|
|
92
|
+
(0, import_assert.default)(override !== false);
|
|
80
93
|
return {
|
|
81
94
|
...defaultConfig,
|
|
82
95
|
...override,
|
|
@@ -90,8 +103,8 @@ async function splitByExperience(ctx) {
|
|
|
90
103
|
}
|
|
91
104
|
function splitByModule(ctx) {
|
|
92
105
|
const { override, userDefinedCacheGroups, defaultConfig } = ctx;
|
|
93
|
-
(0,
|
|
94
|
-
(0,
|
|
106
|
+
(0, import_assert.default)(defaultConfig !== false);
|
|
107
|
+
(0, import_assert.default)(override !== false);
|
|
95
108
|
return {
|
|
96
109
|
...defaultConfig,
|
|
97
110
|
minSize: 0,
|
|
@@ -103,10 +116,10 @@ function splitByModule(ctx) {
|
|
|
103
116
|
// Core group
|
|
104
117
|
vendors: {
|
|
105
118
|
priority: -10,
|
|
106
|
-
test:
|
|
119
|
+
test: import_builder_shared.NODE_MODULES_REGEX,
|
|
107
120
|
// todo: not support in rspack
|
|
108
|
-
name(
|
|
109
|
-
return (0,
|
|
121
|
+
name(module2) {
|
|
122
|
+
return (0, import_builder_shared.getPackageNameFromModulePath)(module2.context);
|
|
110
123
|
}
|
|
111
124
|
},
|
|
112
125
|
...override.cacheGroups
|
|
@@ -115,9 +128,9 @@ function splitByModule(ctx) {
|
|
|
115
128
|
}
|
|
116
129
|
function splitBySize(ctx) {
|
|
117
130
|
const { override, userDefinedCacheGroups, defaultConfig, builderConfig } = ctx;
|
|
118
|
-
(0,
|
|
119
|
-
(0,
|
|
120
|
-
(0,
|
|
131
|
+
(0, import_assert.default)(defaultConfig !== false);
|
|
132
|
+
(0, import_assert.default)(override !== false);
|
|
133
|
+
(0, import_assert.default)(builderConfig.strategy === "split-by-size");
|
|
121
134
|
var _builderConfig_minSize, _builderConfig_maxSize;
|
|
122
135
|
return {
|
|
123
136
|
...defaultConfig,
|
|
@@ -133,8 +146,8 @@ function splitBySize(ctx) {
|
|
|
133
146
|
}
|
|
134
147
|
function splitCustom(ctx) {
|
|
135
148
|
const { override, userDefinedCacheGroups, defaultConfig } = ctx;
|
|
136
|
-
(0,
|
|
137
|
-
(0,
|
|
149
|
+
(0, import_assert.default)(defaultConfig !== false);
|
|
150
|
+
(0, import_assert.default)(override !== false);
|
|
138
151
|
return {
|
|
139
152
|
...defaultConfig,
|
|
140
153
|
...override,
|
|
@@ -150,11 +163,11 @@ function allInOne(_ctx) {
|
|
|
150
163
|
}
|
|
151
164
|
function singleVendor(ctx) {
|
|
152
165
|
const { override, defaultConfig, userDefinedCacheGroups } = ctx;
|
|
153
|
-
(0,
|
|
154
|
-
(0,
|
|
166
|
+
(0, import_assert.default)(defaultConfig !== false);
|
|
167
|
+
(0, import_assert.default)(override !== false);
|
|
155
168
|
const singleVendorCacheGroup = {
|
|
156
169
|
singleVendor: {
|
|
157
|
-
test:
|
|
170
|
+
test: import_builder_shared.NODE_MODULES_REGEX,
|
|
158
171
|
priority: 0,
|
|
159
172
|
chunks: "all",
|
|
160
173
|
name: "vendor",
|
|
@@ -223,10 +236,15 @@ function builderPluginSplitChunks() {
|
|
|
223
236
|
chain.optimization.splitChunks(splitChunksOptions);
|
|
224
237
|
if (chunkSplit.strategy !== "all-in-one") {
|
|
225
238
|
chain.optimization.runtimeChunk({
|
|
226
|
-
name:
|
|
239
|
+
name: import_builder_shared.RUNTIME_CHUNK_NAME
|
|
227
240
|
});
|
|
228
241
|
}
|
|
229
242
|
});
|
|
230
243
|
}
|
|
231
244
|
};
|
|
232
245
|
}
|
|
246
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
247
|
+
0 && (module.exports = {
|
|
248
|
+
builderPluginSplitChunks,
|
|
249
|
+
createDependenciesRegExp
|
|
250
|
+
});
|