@modern-js/builder 2.35.1 → 2.37.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 +55 -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 +28 -11
- 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 +60 -38
- package/dist/plugins/html.js +62 -44
- 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 +38 -12
- 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 +38 -12
- package/dist/plugins/wasm.js +28 -11
- package/dist/plugins/yaml.js +26 -9
- package/package.json +19 -10
|
@@ -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,18 +62,18 @@ 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
78
|
sizeLabel: filesize(size, {
|
|
66
79
|
round: 1
|
|
@@ -92,8 +105,8 @@ async function printFileSizes(stats, distPath) {
|
|
|
92
105
|
}
|
|
93
106
|
assets.sort((a, b) => b.size - a.size);
|
|
94
107
|
const longestLabelLength = Math.max(...assets.map((a) => stripAnsi(a.sizeLabel).length));
|
|
95
|
-
const longestFileLength = Math.max(...assets.map((a) => stripAnsi(a.folder +
|
|
96
|
-
|
|
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:
|
|
97
110
|
`);
|
|
98
111
|
printHeader(longestFileLength, longestLabelLength);
|
|
99
112
|
let totalSize = 0;
|
|
@@ -101,7 +114,7 @@ async function printFileSizes(stats, distPath) {
|
|
|
101
114
|
assets.forEach((asset) => {
|
|
102
115
|
let { sizeLabel } = asset;
|
|
103
116
|
const { name, folder, gzipSizeLabel } = asset;
|
|
104
|
-
const fileNameLength = stripAnsi(folder +
|
|
117
|
+
const fileNameLength = stripAnsi(folder + import_path.default.sep + name).length;
|
|
105
118
|
const sizeLength = stripAnsi(sizeLabel).length;
|
|
106
119
|
totalSize += asset.size;
|
|
107
120
|
totalGzipSize += asset.gzippedSize;
|
|
@@ -109,16 +122,20 @@ async function printFileSizes(stats, distPath) {
|
|
|
109
122
|
const rightPadding = " ".repeat(longestLabelLength - sizeLength);
|
|
110
123
|
sizeLabel += rightPadding;
|
|
111
124
|
}
|
|
112
|
-
let fileNameLabel =
|
|
125
|
+
let fileNameLabel = import_chalk.default.dim(asset.folder + import_path.default.sep) + import_chalk.default.cyan(asset.name);
|
|
113
126
|
if (fileNameLength < longestFileLength) {
|
|
114
127
|
const rightPadding = " ".repeat(longestFileLength - fileNameLength);
|
|
115
128
|
fileNameLabel += rightPadding;
|
|
116
129
|
}
|
|
117
|
-
|
|
130
|
+
import_builder_shared.logger.log(` ${fileNameLabel} ${sizeLabel} ${gzipSizeLabel}`);
|
|
118
131
|
});
|
|
119
|
-
const totalSizeLabel = `${
|
|
120
|
-
|
|
121
|
-
|
|
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(`
|
|
122
139
|
${totalSizeLabel}
|
|
123
140
|
${gzippedSizeLabel}
|
|
124
141
|
`);
|
|
@@ -132,10 +149,15 @@ const builderPluginFileSize = () => ({
|
|
|
132
149
|
try {
|
|
133
150
|
await printFileSizes(stats, api.context.distPath);
|
|
134
151
|
} catch (err) {
|
|
135
|
-
|
|
136
|
-
|
|
152
|
+
import_builder_shared.logger.error("Failed to print file size.");
|
|
153
|
+
import_builder_shared.logger.error(err);
|
|
137
154
|
}
|
|
138
155
|
}
|
|
139
156
|
});
|
|
140
157
|
}
|
|
141
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,32 +1,45 @@
|
|
|
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
|
-
const { applyOptionsChain } = await Promise.resolve().then(() =>
|
|
39
|
+
const { applyOptionsChain } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
27
40
|
const { mountId, templateParameters, templateParametersByEntries } = config.html;
|
|
28
|
-
const meta = await (0,
|
|
29
|
-
const title = (0,
|
|
41
|
+
const meta = await (0, import_builder_shared.getMetaTags)(entryName, config);
|
|
42
|
+
const title = (0, import_builder_shared.getTitle)(entryName, config);
|
|
30
43
|
const templateParams = (templateParametersByEntries === null || templateParametersByEntries === void 0 ? void 0 : templateParametersByEntries[entryName]) || templateParameters;
|
|
31
44
|
const baseParameters = {
|
|
32
45
|
meta,
|
|
@@ -50,7 +63,7 @@ async function getTemplateParameters(entryName, config, assetPrefix) {
|
|
|
50
63
|
};
|
|
51
64
|
}
|
|
52
65
|
async function getChunks(entryName, entryValue) {
|
|
53
|
-
const { isPlainObject } = await Promise.resolve().then(() =>
|
|
66
|
+
const { isPlainObject } = await Promise.resolve().then(() => __toESM(require("@modern-js/utils")));
|
|
54
67
|
const dependOn = [];
|
|
55
68
|
if (isPlainObject(entryValue)) {
|
|
56
69
|
dependOn.push(...entryValue.dependOn);
|
|
@@ -63,13 +76,13 @@ async function getChunks(entryName, entryValue) {
|
|
|
63
76
|
const applyInjectTags = (api) => {
|
|
64
77
|
api.modifyBundlerChain(async (chain, { HtmlPlugin, CHAIN_ID }) => {
|
|
65
78
|
const config = api.getNormalizedConfig();
|
|
66
|
-
const tags =
|
|
67
|
-
const tagsByEntries =
|
|
68
|
-
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");
|
|
69
82
|
if (!tags.length && !shouldByEntries) {
|
|
70
83
|
return;
|
|
71
84
|
}
|
|
72
|
-
const { HtmlTagsPlugin } = await Promise.resolve().then(() =>
|
|
85
|
+
const { HtmlTagsPlugin } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-shared")));
|
|
73
86
|
const sharedOptions = {
|
|
74
87
|
HtmlPlugin,
|
|
75
88
|
append: true,
|
|
@@ -103,11 +116,11 @@ const builderPluginHtml = () => ({
|
|
|
103
116
|
const routesInfo = [];
|
|
104
117
|
api.modifyBundlerChain(async (chain, { HtmlPlugin, isProd, CHAIN_ID, target }) => {
|
|
105
118
|
const config = api.getNormalizedConfig();
|
|
106
|
-
if ((0,
|
|
119
|
+
if ((0, import_builder_shared.isHtmlDisabled)(config, target)) {
|
|
107
120
|
return;
|
|
108
121
|
}
|
|
109
|
-
const { removeTailSlash, applyOptionsChain } = await Promise.resolve().then(() =>
|
|
110
|
-
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);
|
|
111
124
|
const assetPrefix = removeTailSlash(chain.output.get("publicPath") || "");
|
|
112
125
|
const entries = chain.entryPoints.entries() || {};
|
|
113
126
|
const entryNames = Object.keys(entries);
|
|
@@ -116,10 +129,10 @@ const builderPluginHtml = () => ({
|
|
|
116
129
|
await Promise.all(entryNames.map(async (entryName, index) => {
|
|
117
130
|
const entryValue = entries[entryName].values();
|
|
118
131
|
const chunks = await getChunks(entryName, entryValue);
|
|
119
|
-
const inject = (0,
|
|
120
|
-
const favicon = (0,
|
|
132
|
+
const inject = (0, import_builder_shared.getInject)(entryName, config);
|
|
133
|
+
const favicon = (0, import_builder_shared.getFavicon)(entryName, config);
|
|
121
134
|
const filename = htmlPaths[entryName];
|
|
122
|
-
const template = (0,
|
|
135
|
+
const template = (0, import_builder_shared.getTemplatePath)(entryName, config);
|
|
123
136
|
const templateParameters = await getTemplateParameters(entryName, config, assetPrefix);
|
|
124
137
|
const pluginOptions = {
|
|
125
138
|
chunks,
|
|
@@ -131,7 +144,7 @@ const builderPluginHtml = () => ({
|
|
|
131
144
|
scriptLoading: config.html.scriptLoading
|
|
132
145
|
};
|
|
133
146
|
if (favicon) {
|
|
134
|
-
if ((0,
|
|
147
|
+
if ((0, import_builder_shared.isURL)(favicon)) {
|
|
135
148
|
faviconUrls.push({
|
|
136
149
|
filename,
|
|
137
150
|
url: favicon
|
|
@@ -157,7 +170,7 @@ const builderPluginHtml = () => ({
|
|
|
157
170
|
if (config.security) {
|
|
158
171
|
const { nonce } = config.security;
|
|
159
172
|
if (nonce) {
|
|
160
|
-
const { HtmlNoncePlugin } = await Promise.resolve().then(() =>
|
|
173
|
+
const { HtmlNoncePlugin } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-shared")));
|
|
161
174
|
chain.plugin(CHAIN_ID.PLUGIN.HTML_NONCE).use(HtmlNoncePlugin, [
|
|
162
175
|
{
|
|
163
176
|
nonce,
|
|
@@ -169,7 +182,7 @@ const builderPluginHtml = () => ({
|
|
|
169
182
|
if (config.html) {
|
|
170
183
|
const { appIcon, crossorigin } = config.html;
|
|
171
184
|
if (crossorigin) {
|
|
172
|
-
const { HtmlCrossOriginPlugin } = await Promise.resolve().then(() =>
|
|
185
|
+
const { HtmlCrossOriginPlugin } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-shared")));
|
|
173
186
|
const formattedCrossorigin = crossorigin === true ? "anonymous" : crossorigin;
|
|
174
187
|
chain.plugin(CHAIN_ID.PLUGIN.HTML_CROSS_ORIGIN).use(HtmlCrossOriginPlugin, [
|
|
175
188
|
{
|
|
@@ -180,7 +193,7 @@ const builderPluginHtml = () => ({
|
|
|
180
193
|
chain.output.crossOriginLoading(formattedCrossorigin);
|
|
181
194
|
}
|
|
182
195
|
if (faviconUrls.length) {
|
|
183
|
-
const { HtmlFaviconUrlPlugin } = await Promise.resolve().then(() =>
|
|
196
|
+
const { HtmlFaviconUrlPlugin } = await Promise.resolve().then(() => __toESM(require("@modern-js/builder-shared")));
|
|
184
197
|
chain.plugin(CHAIN_ID.PLUGIN.FAVICON_URL).use(HtmlFaviconUrlPlugin, [
|
|
185
198
|
{
|
|
186
199
|
faviconUrls,
|
|
@@ -189,9 +202,9 @@ const builderPluginHtml = () => ({
|
|
|
189
202
|
]);
|
|
190
203
|
}
|
|
191
204
|
if (appIcon) {
|
|
192
|
-
const { HtmlAppIconPlugin } = await Promise.resolve().then(() =>
|
|
193
|
-
const distDir = (0,
|
|
194
|
-
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);
|
|
195
208
|
chain.plugin(CHAIN_ID.PLUGIN.APP_ICON).use(HtmlAppIconPlugin, [
|
|
196
209
|
{
|
|
197
210
|
iconPath,
|
|
@@ -203,9 +216,9 @@ const builderPluginHtml = () => ({
|
|
|
203
216
|
}
|
|
204
217
|
});
|
|
205
218
|
const emitRouteJson = async () => {
|
|
206
|
-
const { fs, ROUTE_SPEC_FILE } = await Promise.resolve().then(() =>
|
|
207
|
-
const routeFilePath =
|
|
208
|
-
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) {
|
|
209
222
|
await fs.outputFile(routeFilePath, JSON.stringify({
|
|
210
223
|
routes: routesInfo
|
|
211
224
|
}, null, 2));
|
|
@@ -216,3 +229,8 @@ const builderPluginHtml = () => ({
|
|
|
216
229
|
applyInjectTags(api);
|
|
217
230
|
}
|
|
218
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
|
+
});
|