@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
|
@@ -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 externals_exports = {};
|
|
20
|
+
__export(externals_exports, {
|
|
21
|
+
builderPluginExternals: () => builderPluginExternals
|
|
10
22
|
});
|
|
23
|
+
module.exports = __toCommonJS(externals_exports);
|
|
11
24
|
function builderPluginExternals() {
|
|
12
25
|
return {
|
|
13
26
|
name: "builder-plugin-externals",
|
|
@@ -29,3 +42,7 @@ function builderPluginExternals() {
|
|
|
29
42
|
}
|
|
30
43
|
};
|
|
31
44
|
}
|
|
45
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
46
|
+
0 && (module.exports = {
|
|
47
|
+
builderPluginExternals
|
|
48
|
+
});
|
package/dist/plugins/fileSize.js
CHANGED
|
@@ -1,36 +1,49 @@
|
|
|
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 filterAsset;
|
|
15
|
-
},
|
|
16
|
-
builderPluginFileSize: function() {
|
|
17
|
-
return builderPluginFileSize;
|
|
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 fileSize_exports = {};
|
|
30
|
+
__export(fileSize_exports, {
|
|
31
|
+
builderPluginFileSize: () => builderPluginFileSize,
|
|
32
|
+
filterAsset: () => filterAsset
|
|
19
33
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const _buildershared = require("@modern-js/builder-shared");
|
|
34
|
+
module.exports = __toCommonJS(fileSize_exports);
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
var import_chalk = __toESM(require("@modern-js/utils/chalk"));
|
|
37
|
+
var import_builder_shared = require("@modern-js/builder-shared");
|
|
25
38
|
const filterAsset = (asset) => !/\.map$/.test(asset) && !/\.LICENSE\.txt$/.test(asset);
|
|
26
39
|
const getAssetColor = (size) => {
|
|
27
40
|
if (size > 300 * 1e3) {
|
|
28
|
-
return
|
|
41
|
+
return import_chalk.default.bold.red;
|
|
29
42
|
}
|
|
30
43
|
if (size > 100 * 1e3) {
|
|
31
|
-
return
|
|
44
|
+
return import_chalk.default.yellow;
|
|
32
45
|
}
|
|
33
|
-
return
|
|
46
|
+
return import_chalk.default.green;
|
|
34
47
|
};
|
|
35
48
|
async function printHeader(longestFileLength, longestLabelLength) {
|
|
36
49
|
const longestLengths = [
|
|
@@ -49,21 +62,25 @@ async function printHeader(longestFileLength, longestLabelLength) {
|
|
|
49
62
|
}
|
|
50
63
|
return `${prev + curLabel} `;
|
|
51
64
|
}, " ");
|
|
52
|
-
|
|
65
|
+
import_builder_shared.logger.log(import_chalk.default.bold.blue(headerRow));
|
|
53
66
|
}
|
|
54
67
|
async function printFileSizes(stats, distPath) {
|
|
55
|
-
const { fs, filesize, gzipSize, stripAnsi } = await Promise.resolve().then(() =>
|
|
68
|
+
const { fs, filesize, gzipSize, stripAnsi } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
56
69
|
const formatAsset = (asset) => {
|
|
57
|
-
const contents = fs.readFileSync(
|
|
70
|
+
const contents = fs.readFileSync(import_path.default.join(distPath, asset.name));
|
|
58
71
|
const size = contents.length;
|
|
59
72
|
const gzippedSize = gzipSize.sync(contents);
|
|
60
73
|
return {
|
|
61
74
|
size,
|
|
62
|
-
folder:
|
|
63
|
-
name:
|
|
75
|
+
folder: import_path.default.join(import_path.default.basename(distPath), import_path.default.dirname(asset.name)),
|
|
76
|
+
name: import_path.default.basename(asset.name),
|
|
64
77
|
gzippedSize,
|
|
65
|
-
sizeLabel: filesize(size
|
|
66
|
-
|
|
78
|
+
sizeLabel: filesize(size, {
|
|
79
|
+
round: 1
|
|
80
|
+
}),
|
|
81
|
+
gzipSizeLabel: getAssetColor(gzippedSize)(filesize(gzippedSize, {
|
|
82
|
+
round: 1
|
|
83
|
+
}))
|
|
67
84
|
};
|
|
68
85
|
};
|
|
69
86
|
const multiStats = "stats" in stats ? stats.stats : [
|
|
@@ -88,8 +105,8 @@ async function printFileSizes(stats, distPath) {
|
|
|
88
105
|
}
|
|
89
106
|
assets.sort((a, b) => b.size - a.size);
|
|
90
107
|
const longestLabelLength = Math.max(...assets.map((a) => stripAnsi(a.sizeLabel).length));
|
|
91
|
-
const longestFileLength = Math.max(...assets.map((a) => stripAnsi(a.folder +
|
|
92
|
-
|
|
108
|
+
const longestFileLength = Math.max(...assets.map((a) => stripAnsi(a.folder + import_path.default.sep + a.name).length));
|
|
109
|
+
import_builder_shared.logger.info(`Production file sizes:
|
|
93
110
|
`);
|
|
94
111
|
printHeader(longestFileLength, longestLabelLength);
|
|
95
112
|
let totalSize = 0;
|
|
@@ -97,7 +114,7 @@ async function printFileSizes(stats, distPath) {
|
|
|
97
114
|
assets.forEach((asset) => {
|
|
98
115
|
let { sizeLabel } = asset;
|
|
99
116
|
const { name, folder, gzipSizeLabel } = asset;
|
|
100
|
-
const fileNameLength = stripAnsi(folder +
|
|
117
|
+
const fileNameLength = stripAnsi(folder + import_path.default.sep + name).length;
|
|
101
118
|
const sizeLength = stripAnsi(sizeLabel).length;
|
|
102
119
|
totalSize += asset.size;
|
|
103
120
|
totalGzipSize += asset.gzippedSize;
|
|
@@ -105,16 +122,20 @@ async function printFileSizes(stats, distPath) {
|
|
|
105
122
|
const rightPadding = " ".repeat(longestLabelLength - sizeLength);
|
|
106
123
|
sizeLabel += rightPadding;
|
|
107
124
|
}
|
|
108
|
-
let fileNameLabel =
|
|
125
|
+
let fileNameLabel = import_chalk.default.dim(asset.folder + import_path.default.sep) + import_chalk.default.cyan(asset.name);
|
|
109
126
|
if (fileNameLength < longestFileLength) {
|
|
110
127
|
const rightPadding = " ".repeat(longestFileLength - fileNameLength);
|
|
111
128
|
fileNameLabel += rightPadding;
|
|
112
129
|
}
|
|
113
|
-
|
|
130
|
+
import_builder_shared.logger.log(` ${fileNameLabel} ${sizeLabel} ${gzipSizeLabel}`);
|
|
114
131
|
});
|
|
115
|
-
const totalSizeLabel = `${
|
|
116
|
-
|
|
117
|
-
|
|
132
|
+
const totalSizeLabel = `${import_chalk.default.bold.blue("Total size:")} ${filesize(totalSize, {
|
|
133
|
+
round: 1
|
|
134
|
+
})}`;
|
|
135
|
+
const gzippedSizeLabel = `${import_chalk.default.bold.blue("Gzipped size:")} ${filesize(totalGzipSize, {
|
|
136
|
+
round: 1
|
|
137
|
+
})}`;
|
|
138
|
+
import_builder_shared.logger.log(`
|
|
118
139
|
${totalSizeLabel}
|
|
119
140
|
${gzippedSizeLabel}
|
|
120
141
|
`);
|
|
@@ -128,10 +149,15 @@ const builderPluginFileSize = () => ({
|
|
|
128
149
|
try {
|
|
129
150
|
await printFileSizes(stats, api.context.distPath);
|
|
130
151
|
} catch (err) {
|
|
131
|
-
|
|
132
|
-
|
|
152
|
+
import_builder_shared.logger.error("Failed to print file size.");
|
|
153
|
+
import_builder_shared.logger.error(err);
|
|
133
154
|
}
|
|
134
155
|
}
|
|
135
156
|
});
|
|
136
157
|
}
|
|
137
158
|
});
|
|
159
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
160
|
+
0 && (module.exports = {
|
|
161
|
+
builderPluginFileSize,
|
|
162
|
+
filterAsset
|
|
163
|
+
});
|
package/dist/plugins/html.js
CHANGED
|
@@ -1,34 +1,46 @@
|
|
|
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 applyInjectTags;
|
|
15
|
-
},
|
|
16
|
-
builderPluginHtml: function() {
|
|
17
|
-
return builderPluginHtml;
|
|
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 html_exports = {};
|
|
30
|
+
__export(html_exports, {
|
|
31
|
+
applyInjectTags: () => applyInjectTags,
|
|
32
|
+
builderPluginHtml: () => builderPluginHtml
|
|
19
33
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const _lodash = /* @__PURE__ */ _interop_require_default._(require("@modern-js/utils/lodash"));
|
|
34
|
+
module.exports = __toCommonJS(html_exports);
|
|
35
|
+
var import_path = __toESM(require("path"));
|
|
36
|
+
var import_builder_shared = require("@modern-js/builder-shared");
|
|
37
|
+
var import_lodash = __toESM(require("@modern-js/utils/lodash"));
|
|
25
38
|
async function getTemplateParameters(entryName, config, assetPrefix) {
|
|
26
|
-
|
|
27
|
-
const { applyOptionsChain } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
|
|
39
|
+
const { applyOptionsChain } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
28
40
|
const { mountId, templateParameters, templateParametersByEntries } = config.html;
|
|
29
|
-
const meta = await (0,
|
|
30
|
-
const title = (0,
|
|
31
|
-
const templateParams = (
|
|
41
|
+
const meta = await (0, import_builder_shared.getMetaTags)(entryName, config);
|
|
42
|
+
const title = (0, import_builder_shared.getTitle)(entryName, config);
|
|
43
|
+
const templateParams = (templateParametersByEntries === null || templateParametersByEntries === void 0 ? void 0 : templateParametersByEntries[entryName]) || templateParameters;
|
|
32
44
|
const baseParameters = {
|
|
33
45
|
meta,
|
|
34
46
|
title,
|
|
@@ -51,7 +63,7 @@ async function getTemplateParameters(entryName, config, assetPrefix) {
|
|
|
51
63
|
};
|
|
52
64
|
}
|
|
53
65
|
async function getChunks(entryName, entryValue) {
|
|
54
|
-
const { isPlainObject } = await Promise.resolve().then(() =>
|
|
66
|
+
const { isPlainObject } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
55
67
|
const dependOn = [];
|
|
56
68
|
if (isPlainObject(entryValue)) {
|
|
57
69
|
dependOn.push(...entryValue.dependOn);
|
|
@@ -64,13 +76,13 @@ async function getChunks(entryName, entryValue) {
|
|
|
64
76
|
const applyInjectTags = (api) => {
|
|
65
77
|
api.modifyBundlerChain(async (chain, { HtmlPlugin, CHAIN_ID }) => {
|
|
66
78
|
const config = api.getNormalizedConfig();
|
|
67
|
-
const tags =
|
|
68
|
-
const tagsByEntries =
|
|
69
|
-
const shouldByEntries =
|
|
79
|
+
const tags = import_lodash.default.castArray(config.html.tags).filter(Boolean);
|
|
80
|
+
const tagsByEntries = import_lodash.default.mapValues(config.html.tagsByEntries, (tags2) => import_lodash.default.castArray(tags2).filter(Boolean));
|
|
81
|
+
const shouldByEntries = import_lodash.default.some(tagsByEntries, "length");
|
|
70
82
|
if (!tags.length && !shouldByEntries) {
|
|
71
83
|
return;
|
|
72
84
|
}
|
|
73
|
-
const { HtmlTagsPlugin } = await Promise.resolve().then(() =>
|
|
85
|
+
const { HtmlTagsPlugin } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-shared")));
|
|
74
86
|
const sharedOptions = {
|
|
75
87
|
HtmlPlugin,
|
|
76
88
|
append: true,
|
|
@@ -104,11 +116,11 @@ const builderPluginHtml = () => ({
|
|
|
104
116
|
const routesInfo = [];
|
|
105
117
|
api.modifyBundlerChain(async (chain, { HtmlPlugin, isProd, CHAIN_ID, target }) => {
|
|
106
118
|
const config = api.getNormalizedConfig();
|
|
107
|
-
if ((0,
|
|
119
|
+
if ((0, import_builder_shared.isHtmlDisabled)(config, target)) {
|
|
108
120
|
return;
|
|
109
121
|
}
|
|
110
|
-
const { removeTailSlash, applyOptionsChain } = await Promise.resolve().then(() =>
|
|
111
|
-
const minify = await (0,
|
|
122
|
+
const { removeTailSlash, applyOptionsChain } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
123
|
+
const minify = await (0, import_builder_shared.getMinify)(isProd, config);
|
|
112
124
|
const assetPrefix = removeTailSlash(chain.output.get("publicPath") || "");
|
|
113
125
|
const entries = chain.entryPoints.entries() || {};
|
|
114
126
|
const entryNames = Object.keys(entries);
|
|
@@ -117,10 +129,10 @@ const builderPluginHtml = () => ({
|
|
|
117
129
|
await Promise.all(entryNames.map(async (entryName, index) => {
|
|
118
130
|
const entryValue = entries[entryName].values();
|
|
119
131
|
const chunks = await getChunks(entryName, entryValue);
|
|
120
|
-
const inject = (0,
|
|
121
|
-
const favicon = (0,
|
|
132
|
+
const inject = (0, import_builder_shared.getInject)(entryName, config);
|
|
133
|
+
const favicon = (0, import_builder_shared.getFavicon)(entryName, config);
|
|
122
134
|
const filename = htmlPaths[entryName];
|
|
123
|
-
const template = (0,
|
|
135
|
+
const template = (0, import_builder_shared.getTemplatePath)(entryName, config);
|
|
124
136
|
const templateParameters = await getTemplateParameters(entryName, config, assetPrefix);
|
|
125
137
|
const pluginOptions = {
|
|
126
138
|
chunks,
|
|
@@ -132,7 +144,7 @@ const builderPluginHtml = () => ({
|
|
|
132
144
|
scriptLoading: config.html.scriptLoading
|
|
133
145
|
};
|
|
134
146
|
if (favicon) {
|
|
135
|
-
if ((0,
|
|
147
|
+
if ((0, import_builder_shared.isURL)(favicon)) {
|
|
136
148
|
faviconUrls.push({
|
|
137
149
|
filename,
|
|
138
150
|
url: favicon
|
|
@@ -158,7 +170,7 @@ const builderPluginHtml = () => ({
|
|
|
158
170
|
if (config.security) {
|
|
159
171
|
const { nonce } = config.security;
|
|
160
172
|
if (nonce) {
|
|
161
|
-
const { HtmlNoncePlugin } = await Promise.resolve().then(() =>
|
|
173
|
+
const { HtmlNoncePlugin } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-shared")));
|
|
162
174
|
chain.plugin(CHAIN_ID.PLUGIN.HTML_NONCE).use(HtmlNoncePlugin, [
|
|
163
175
|
{
|
|
164
176
|
nonce,
|
|
@@ -170,7 +182,7 @@ const builderPluginHtml = () => ({
|
|
|
170
182
|
if (config.html) {
|
|
171
183
|
const { appIcon, crossorigin } = config.html;
|
|
172
184
|
if (crossorigin) {
|
|
173
|
-
const { HtmlCrossOriginPlugin } = await Promise.resolve().then(() =>
|
|
185
|
+
const { HtmlCrossOriginPlugin } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-shared")));
|
|
174
186
|
const formattedCrossorigin = crossorigin === true ? "anonymous" : crossorigin;
|
|
175
187
|
chain.plugin(CHAIN_ID.PLUGIN.HTML_CROSS_ORIGIN).use(HtmlCrossOriginPlugin, [
|
|
176
188
|
{
|
|
@@ -181,7 +193,7 @@ const builderPluginHtml = () => ({
|
|
|
181
193
|
chain.output.crossOriginLoading(formattedCrossorigin);
|
|
182
194
|
}
|
|
183
195
|
if (faviconUrls.length) {
|
|
184
|
-
const { HtmlFaviconUrlPlugin } = await Promise.resolve().then(() =>
|
|
196
|
+
const { HtmlFaviconUrlPlugin } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-shared")));
|
|
185
197
|
chain.plugin(CHAIN_ID.PLUGIN.FAVICON_URL).use(HtmlFaviconUrlPlugin, [
|
|
186
198
|
{
|
|
187
199
|
faviconUrls,
|
|
@@ -190,9 +202,9 @@ const builderPluginHtml = () => ({
|
|
|
190
202
|
]);
|
|
191
203
|
}
|
|
192
204
|
if (appIcon) {
|
|
193
|
-
const { HtmlAppIconPlugin } = await Promise.resolve().then(() =>
|
|
194
|
-
const distDir = (0,
|
|
195
|
-
const iconPath =
|
|
205
|
+
const { HtmlAppIconPlugin } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-shared")));
|
|
206
|
+
const distDir = (0, import_builder_shared.getDistPath)(config.output, "image");
|
|
207
|
+
const iconPath = import_path.default.isAbsolute(appIcon) ? appIcon : import_path.default.join(api.context.rootPath, appIcon);
|
|
196
208
|
chain.plugin(CHAIN_ID.PLUGIN.APP_ICON).use(HtmlAppIconPlugin, [
|
|
197
209
|
{
|
|
198
210
|
iconPath,
|
|
@@ -204,9 +216,9 @@ const builderPluginHtml = () => ({
|
|
|
204
216
|
}
|
|
205
217
|
});
|
|
206
218
|
const emitRouteJson = async () => {
|
|
207
|
-
const { fs, ROUTE_SPEC_FILE } = await Promise.resolve().then(() =>
|
|
208
|
-
const routeFilePath =
|
|
209
|
-
if (!await (0,
|
|
219
|
+
const { fs, ROUTE_SPEC_FILE } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
220
|
+
const routeFilePath = import_path.default.join(api.context.distPath, ROUTE_SPEC_FILE);
|
|
221
|
+
if (!await (0, import_builder_shared.isFileExists)(routeFilePath) && routesInfo.length) {
|
|
210
222
|
await fs.outputFile(routeFilePath, JSON.stringify({
|
|
211
223
|
routes: routesInfo
|
|
212
224
|
}, null, 2));
|
|
@@ -217,3 +229,8 @@ const builderPluginHtml = () => ({
|
|
|
217
229
|
applyInjectTags(api);
|
|
218
230
|
}
|
|
219
231
|
});
|
|
232
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
233
|
+
0 && (module.exports = {
|
|
234
|
+
applyInjectTags,
|
|
235
|
+
builderPluginHtml
|
|
236
|
+
});
|
package/dist/plugins/index.js
CHANGED
|
@@ -1,47 +1,74 @@
|
|
|
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 plugins_exports = {};
|
|
30
|
+
__export(plugins_exports, {
|
|
31
|
+
plugins: () => plugins
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
33
|
+
module.exports = __toCommonJS(plugins_exports);
|
|
34
|
+
var import_builder_shared = require("@modern-js/builder-shared");
|
|
13
35
|
const plugins = {
|
|
14
|
-
html: () => Promise.resolve().then(() =>
|
|
15
|
-
cleanOutput: () => Promise.resolve().then(() =>
|
|
16
|
-
startUrl: () => Promise.resolve().then(() =>
|
|
17
|
-
fileSize: () => Promise.resolve().then(() =>
|
|
18
|
-
devtool: () => Promise.resolve().then(() =>
|
|
19
|
-
target: () => Promise.resolve().then(() =>
|
|
20
|
-
entry: () => Promise.resolve().then(() =>
|
|
21
|
-
cache: () => Promise.resolve().then(() =>
|
|
22
|
-
yaml: () => Promise.resolve().then(() =>
|
|
23
|
-
toml: () => Promise.resolve().then(() =>
|
|
24
|
-
svg: () => Promise.resolve().then(() =>
|
|
25
|
-
splitChunks: () => Promise.resolve().then(() =>
|
|
26
|
-
inlineChunk: () => Promise.resolve().then(() =>
|
|
27
|
-
bundleAnalyzer: () => Promise.resolve().then(() =>
|
|
28
|
-
font: () => Promise.resolve().then(() =>
|
|
29
|
-
image: () => Promise.resolve().then(() =>
|
|
30
|
-
media: () => Promise.resolve().then(() =>
|
|
31
|
-
assetsRetry: () => Promise.resolve().then(() =>
|
|
32
|
-
antd: () => Promise.resolve().then(() =>
|
|
33
|
-
arco: () => Promise.resolve().then(() =>
|
|
34
|
-
tsChecker: () => Promise.resolve().then(() =>
|
|
35
|
-
checkSyntax: () => Promise.resolve().then(() =>
|
|
36
|
-
rem: () => Promise.resolve().then(() =>
|
|
37
|
-
wasm: () => Promise.resolve().then(() =>
|
|
38
|
-
moment: () => Promise.resolve().then(() =>
|
|
39
|
-
nodeAddons: () => Promise.resolve().then(() =>
|
|
40
|
-
externals: () => Promise.resolve().then(() =>
|
|
41
|
-
sourceBuild: () => Promise.resolve().then(() =>
|
|
36
|
+
html: () => Promise.resolve().then(() => __toESM(require("./html"))).then((m) => m.builderPluginHtml()),
|
|
37
|
+
cleanOutput: () => Promise.resolve().then(() => __toESM(require("./cleanOutput"))).then((m) => m.builderPluginCleanOutput()),
|
|
38
|
+
startUrl: () => Promise.resolve().then(() => __toESM(require("./startUrl"))).then((m) => m.builderPluginStartUrl()),
|
|
39
|
+
fileSize: () => Promise.resolve().then(() => __toESM(require("./fileSize"))).then((m) => m.builderPluginFileSize()),
|
|
40
|
+
devtool: () => Promise.resolve().then(() => __toESM(require("./devtool"))).then((m) => m.builderPluginDevtool()),
|
|
41
|
+
target: () => Promise.resolve().then(() => __toESM(require("./target"))).then((m) => m.builderPluginTarget()),
|
|
42
|
+
entry: () => Promise.resolve().then(() => __toESM(require("./entry"))).then((m) => m.builderPluginEntry()),
|
|
43
|
+
cache: () => Promise.resolve().then(() => __toESM(require("./cache"))).then((m) => m.builderPluginCache()),
|
|
44
|
+
yaml: () => Promise.resolve().then(() => __toESM(require("./yaml"))).then((m) => m.builderPluginYaml()),
|
|
45
|
+
toml: () => Promise.resolve().then(() => __toESM(require("./toml"))).then((m) => m.builderPluginToml()),
|
|
46
|
+
svg: () => Promise.resolve().then(() => __toESM(require("./svg"))).then((m) => m.builderPluginSvg()),
|
|
47
|
+
splitChunks: () => Promise.resolve().then(() => __toESM(require("./splitChunks"))).then((m) => m.builderPluginSplitChunks()),
|
|
48
|
+
inlineChunk: () => Promise.resolve().then(() => __toESM(require("./inlineChunk"))).then((m) => m.builderPluginInlineChunk()),
|
|
49
|
+
bundleAnalyzer: () => Promise.resolve().then(() => __toESM(require("./bundleAnalyzer"))).then((m) => m.builderPluginBundleAnalyzer()),
|
|
50
|
+
font: () => Promise.resolve().then(() => __toESM(require("./asset"))).then((m) => m.builderAssetPlugin("font", import_builder_shared.FONT_EXTENSIONS)),
|
|
51
|
+
image: () => Promise.resolve().then(() => __toESM(require("./asset"))).then((m) => m.builderAssetPlugin("image", import_builder_shared.IMAGE_EXTENSIONS)),
|
|
52
|
+
media: () => Promise.resolve().then(() => __toESM(require("./asset"))).then((m) => m.builderAssetPlugin("media", import_builder_shared.MEDIA_EXTENSIONS)),
|
|
53
|
+
assetsRetry: () => Promise.resolve().then(() => __toESM(require("./assetsRetry"))).then((m) => m.builderPluginAssetsRetry()),
|
|
54
|
+
antd: () => Promise.resolve().then(() => __toESM(require("./antd"))).then((m) => m.builderPluginAntd()),
|
|
55
|
+
arco: () => Promise.resolve().then(() => __toESM(require("./arco"))).then((m) => m.builderPluginArco()),
|
|
56
|
+
tsChecker: () => Promise.resolve().then(() => __toESM(require("./tsChecker"))).then((m) => m.builderPluginTsChecker()),
|
|
57
|
+
checkSyntax: () => Promise.resolve().then(() => __toESM(require("./checkSyntax"))).then((m) => m.builderPluginCheckSyntax()),
|
|
58
|
+
rem: () => Promise.resolve().then(() => __toESM(require("./rem"))).then((m) => m.builderPluginRem()),
|
|
59
|
+
wasm: () => Promise.resolve().then(() => __toESM(require("./wasm"))).then((m) => m.builderPluginWasm()),
|
|
60
|
+
moment: () => Promise.resolve().then(() => __toESM(require("./moment"))).then((m) => m.builderPluginMoment()),
|
|
61
|
+
nodeAddons: () => Promise.resolve().then(() => __toESM(require("./nodeAddons"))).then((m) => m.builderPluginNodeAddons()),
|
|
62
|
+
externals: () => Promise.resolve().then(() => __toESM(require("./externals"))).then((m) => m.builderPluginExternals()),
|
|
63
|
+
sourceBuild: () => Promise.resolve().then(() => __toESM(require("./sourceBuild"))).then((m) => m.builderPluginSourceBuild({
|
|
42
64
|
sourceField: "source"
|
|
43
65
|
})),
|
|
44
|
-
networkPerformance: () => Promise.resolve().then(() =>
|
|
45
|
-
preloadOrPrefetch: () => Promise.resolve().then(() =>
|
|
46
|
-
performance: () => Promise.resolve().then(() =>
|
|
66
|
+
networkPerformance: () => Promise.resolve().then(() => __toESM(require("./networkPerformance"))).then((m) => m.builderPluginNetworkPerformance()),
|
|
67
|
+
preloadOrPrefetch: () => Promise.resolve().then(() => __toESM(require("./preloadOrPrefetch"))).then((m) => m.builderPluginPreloadOrPrefetch()),
|
|
68
|
+
performance: () => Promise.resolve().then(() => __toESM(require("./performance"))).then((m) => m.builderPluginPerformance()),
|
|
69
|
+
define: () => Promise.resolve().then(() => __toESM(require("./define"))).then((m) => m.builderPluginDefine())
|
|
47
70
|
};
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
plugins
|
|
74
|
+
});
|
|
@@ -1,24 +1,46 @@
|
|
|
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 inlineChunk_exports = {};
|
|
30
|
+
__export(inlineChunk_exports, {
|
|
31
|
+
builderPluginInlineChunk: () => builderPluginInlineChunk
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
33
|
+
module.exports = __toCommonJS(inlineChunk_exports);
|
|
34
|
+
var import_builder_shared = require("@modern-js/builder-shared");
|
|
13
35
|
const builderPluginInlineChunk = () => ({
|
|
14
36
|
name: "builder-plugin-inline-chunk",
|
|
15
37
|
setup(api) {
|
|
16
38
|
api.modifyBundlerChain(async (chain, { target, CHAIN_ID, isProd, HtmlPlugin }) => {
|
|
17
39
|
const config = api.getNormalizedConfig();
|
|
18
|
-
if ((0,
|
|
40
|
+
if ((0, import_builder_shared.isHtmlDisabled)(config, target) || !isProd) {
|
|
19
41
|
return;
|
|
20
42
|
}
|
|
21
|
-
const { InlineChunkHtmlPlugin } = await Promise.resolve().then(() =>
|
|
43
|
+
const { InlineChunkHtmlPlugin } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-shared")));
|
|
22
44
|
const {
|
|
23
45
|
disableInlineRuntimeChunk,
|
|
24
46
|
enableInlineStyles,
|
|
@@ -28,16 +50,16 @@ const builderPluginInlineChunk = () => ({
|
|
|
28
50
|
const scriptTests = [];
|
|
29
51
|
const styleTests = [];
|
|
30
52
|
if (enableInlineScripts) {
|
|
31
|
-
scriptTests.push(enableInlineScripts === true ?
|
|
53
|
+
scriptTests.push(enableInlineScripts === true ? import_builder_shared.JS_REGEX : enableInlineScripts);
|
|
32
54
|
}
|
|
33
55
|
if (enableInlineStyles) {
|
|
34
|
-
styleTests.push(enableInlineStyles === true ?
|
|
56
|
+
styleTests.push(enableInlineStyles === true ? import_builder_shared.CSS_REGEX : enableInlineStyles);
|
|
35
57
|
}
|
|
36
58
|
if (!disableInlineRuntimeChunk) {
|
|
37
59
|
scriptTests.push(
|
|
38
60
|
// RegExp like /builder-runtime([.].+)?\.js$/
|
|
39
61
|
// matches builder-runtime.js and builder-runtime.123456.js
|
|
40
|
-
new RegExp(`${
|
|
62
|
+
new RegExp(`${import_builder_shared.RUNTIME_CHUNK_NAME}([.].+)?\\.js$`)
|
|
41
63
|
);
|
|
42
64
|
}
|
|
43
65
|
chain.plugin(CHAIN_ID.PLUGIN.INLINE_HTML).use(InlineChunkHtmlPlugin, [
|
|
@@ -45,7 +67,7 @@ const builderPluginInlineChunk = () => ({
|
|
|
45
67
|
{
|
|
46
68
|
styleTests,
|
|
47
69
|
scriptTests,
|
|
48
|
-
distPath: (0,
|
|
70
|
+
distPath: (0, import_builder_shared.pick)(config.output.distPath, [
|
|
49
71
|
"js",
|
|
50
72
|
"css"
|
|
51
73
|
])
|
|
@@ -54,3 +76,7 @@ const builderPluginInlineChunk = () => ({
|
|
|
54
76
|
});
|
|
55
77
|
}
|
|
56
78
|
});
|
|
79
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
80
|
+
0 && (module.exports = {
|
|
81
|
+
builderPluginInlineChunk
|
|
82
|
+
});
|