@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.
Files changed (40) hide show
  1. package/dist/cli/commands.js +34 -17
  2. package/dist/cli/config.js +49 -28
  3. package/dist/cli/index.js +35 -24
  4. package/dist/cli/provider.js +42 -23
  5. package/dist/createBuilder.js +33 -16
  6. package/dist/index.js +30 -21
  7. package/dist/plugins/antd.js +27 -17
  8. package/dist/plugins/arco.js +30 -14
  9. package/dist/plugins/asset.js +41 -15
  10. package/dist/plugins/assetsRetry.js +38 -12
  11. package/dist/plugins/bundleAnalyzer.js +35 -9
  12. package/dist/plugins/cache.js +49 -24
  13. package/dist/plugins/checkSyntax.js +37 -11
  14. package/dist/plugins/cleanOutput.js +35 -9
  15. package/dist/plugins/define.d.ts +2 -0
  16. package/dist/plugins/define.js +66 -0
  17. package/dist/plugins/devtool.js +26 -9
  18. package/dist/plugins/entry.js +36 -10
  19. package/dist/plugins/externals.js +24 -7
  20. package/dist/plugins/fileSize.js +66 -40
  21. package/dist/plugins/html.js +63 -46
  22. package/dist/plugins/index.js +67 -40
  23. package/dist/plugins/inlineChunk.js +41 -15
  24. package/dist/plugins/moment.js +24 -7
  25. package/dist/plugins/networkPerformance.js +27 -10
  26. package/dist/plugins/nodeAddons.js +39 -14
  27. package/dist/plugins/performance.js +24 -7
  28. package/dist/plugins/preloadOrPrefetch.js +27 -10
  29. package/dist/plugins/rem.js +40 -15
  30. package/dist/plugins/sourceBuild.d.ts +1 -1
  31. package/dist/plugins/sourceBuild.js +45 -27
  32. package/dist/plugins/splitChunks.js +55 -37
  33. package/dist/plugins/startUrl.js +39 -21
  34. package/dist/plugins/svg.js +51 -29
  35. package/dist/plugins/target.js +26 -9
  36. package/dist/plugins/toml.js +26 -9
  37. package/dist/plugins/tsChecker.js +39 -14
  38. package/dist/plugins/wasm.js +28 -11
  39. package/dist/plugins/yaml.js +26 -9
  40. package/package.json +17 -9
@@ -1,13 +1,26 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "builderPluginExternals", {
6
- enumerable: true,
7
- get: function() {
8
- return builderPluginExternals;
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
+ });
@@ -1,36 +1,49 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
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
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- filterAsset: function() {
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
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
21
- const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
22
- const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
23
- const _chalk = /* @__PURE__ */ _interop_require_default._(require("@modern-js/utils/chalk"));
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 _chalk.default.bold.red;
41
+ return import_chalk.default.bold.red;
29
42
  }
30
43
  if (size > 100 * 1e3) {
31
- return _chalk.default.yellow;
44
+ return import_chalk.default.yellow;
32
45
  }
33
- return _chalk.default.green;
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
- _buildershared.logger.log(_chalk.default.bold.blue(headerRow));
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(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
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(_path.default.join(distPath, asset.name));
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: _path.default.join(_path.default.basename(distPath), _path.default.dirname(asset.name)),
63
- name: _path.default.basename(asset.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
- gzipSizeLabel: getAssetColor(gzippedSize)(filesize(gzippedSize))
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 + _path.default.sep + a.name).length));
92
- _buildershared.logger.info(`File sizes after production build:
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 + _path.default.sep + name).length;
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 = _chalk.default.dim(asset.folder + _path.default.sep) + _chalk.default.cyan(asset.name);
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
- _buildershared.logger.log(` ${fileNameLabel} ${sizeLabel} ${gzipSizeLabel}`);
130
+ import_builder_shared.logger.log(` ${fileNameLabel} ${sizeLabel} ${gzipSizeLabel}`);
114
131
  });
115
- const totalSizeLabel = `${_chalk.default.bold.blue("Total size:")} ${filesize(totalSize)}`;
116
- const gzippedSizeLabel = `${_chalk.default.bold.blue("Gzipped size:")} ${filesize(totalGzipSize)}`;
117
- _buildershared.logger.log(`
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
- _buildershared.logger.error("Failed to print file size.");
132
- _buildershared.logger.error(err);
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
+ });
@@ -1,34 +1,46 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- function _export(target, all) {
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
- Object.defineProperty(target, name, {
8
- enumerable: true,
9
- get: all[name]
10
- });
11
- }
12
- _export(exports, {
13
- applyInjectTags: function() {
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
- const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
21
- const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
22
- const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
23
- const _buildershared = require("@modern-js/builder-shared");
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
- var _templateParametersByEntries;
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, _buildershared.getMetaTags)(entryName, config);
30
- const title = (0, _buildershared.getTitle)(entryName, config);
31
- const templateParams = ((_templateParametersByEntries = templateParametersByEntries) === null || _templateParametersByEntries === void 0 ? void 0 : _templateParametersByEntries[entryName]) || templateParameters;
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(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
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 = _lodash.default.castArray(config.html.tags).filter(Boolean);
68
- const tagsByEntries = _lodash.default.mapValues(config.html.tagsByEntries, (tags2) => _lodash.default.castArray(tags2).filter(Boolean));
69
- const shouldByEntries = _lodash.default.some(tagsByEntries, "length");
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(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/builder-shared")));
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, _buildershared.isHtmlDisabled)(config, target)) {
119
+ if ((0, import_builder_shared.isHtmlDisabled)(config, target)) {
108
120
  return;
109
121
  }
110
- const { removeTailSlash, applyOptionsChain } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
111
- const minify = await (0, _buildershared.getMinify)(isProd, config);
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, _buildershared.getInject)(entryName, config);
121
- const favicon = (0, _buildershared.getFavicon)(entryName, config);
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, _buildershared.getTemplatePath)(entryName, config);
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, _buildershared.isURL)(favicon)) {
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(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/builder-shared")));
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(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/builder-shared")));
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(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/builder-shared")));
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(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/builder-shared")));
194
- const distDir = (0, _buildershared.getDistPath)(config.output, "image");
195
- const iconPath = _path.default.isAbsolute(appIcon) ? appIcon : _path.default.join(api.context.rootPath, appIcon);
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(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/utils")));
208
- const routeFilePath = _path.default.join(api.context.distPath, ROUTE_SPEC_FILE);
209
- if (!await (0, _buildershared.isFileExists)(routeFilePath) && routesInfo.length) {
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
+ });
@@ -1,47 +1,74 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "plugins", {
6
- enumerable: true,
7
- get: function() {
8
- return plugins;
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
- const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
- const _buildershared = require("@modern-js/builder-shared");
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(() => /* @__PURE__ */ _interop_require_wildcard._(require("./html"))).then((m) => m.builderPluginHtml()),
15
- cleanOutput: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./cleanOutput"))).then((m) => m.builderPluginCleanOutput()),
16
- startUrl: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./startUrl"))).then((m) => m.builderPluginStartUrl()),
17
- fileSize: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./fileSize"))).then((m) => m.builderPluginFileSize()),
18
- devtool: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./devtool"))).then((m) => m.builderPluginDevtool()),
19
- target: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./target"))).then((m) => m.builderPluginTarget()),
20
- entry: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./entry"))).then((m) => m.builderPluginEntry()),
21
- cache: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./cache"))).then((m) => m.builderPluginCache()),
22
- yaml: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./yaml"))).then((m) => m.builderPluginYaml()),
23
- toml: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./toml"))).then((m) => m.builderPluginToml()),
24
- svg: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./svg"))).then((m) => m.builderPluginSvg()),
25
- splitChunks: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./splitChunks"))).then((m) => m.builderPluginSplitChunks()),
26
- inlineChunk: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./inlineChunk"))).then((m) => m.builderPluginInlineChunk()),
27
- bundleAnalyzer: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./bundleAnalyzer"))).then((m) => m.builderPluginBundleAnalyzer()),
28
- font: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./asset"))).then((m) => m.builderAssetPlugin("font", _buildershared.FONT_EXTENSIONS)),
29
- image: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./asset"))).then((m) => m.builderAssetPlugin("image", _buildershared.IMAGE_EXTENSIONS)),
30
- media: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./asset"))).then((m) => m.builderAssetPlugin("media", _buildershared.MEDIA_EXTENSIONS)),
31
- assetsRetry: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./assetsRetry"))).then((m) => m.builderPluginAssetsRetry()),
32
- antd: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./antd"))).then((m) => m.builderPluginAntd()),
33
- arco: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./arco"))).then((m) => m.builderPluginArco()),
34
- tsChecker: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./tsChecker"))).then((m) => m.builderPluginTsChecker()),
35
- checkSyntax: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./checkSyntax"))).then((m) => m.builderPluginCheckSyntax()),
36
- rem: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./rem"))).then((m) => m.builderPluginRem()),
37
- wasm: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./wasm"))).then((m) => m.builderPluginWasm()),
38
- moment: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./moment"))).then((m) => m.builderPluginMoment()),
39
- nodeAddons: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./nodeAddons"))).then((m) => m.builderPluginNodeAddons()),
40
- externals: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./externals"))).then((m) => m.builderPluginExternals()),
41
- sourceBuild: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./sourceBuild"))).then((m) => m.builderPluginSourceBuild({
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(() => /* @__PURE__ */ _interop_require_wildcard._(require("./networkPerformance"))).then((m) => m.builderPluginNetworkPerformance()),
45
- preloadOrPrefetch: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./preloadOrPrefetch"))).then((m) => m.builderPluginPreloadOrPrefetch()),
46
- performance: () => Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("./performance"))).then((m) => m.builderPluginPerformance())
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.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "builderPluginInlineChunk", {
6
- enumerable: true,
7
- get: function() {
8
- return builderPluginInlineChunk;
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
- const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
12
- const _buildershared = require("@modern-js/builder-shared");
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, _buildershared.isHtmlDisabled)(config, target) || !isProd) {
40
+ if ((0, import_builder_shared.isHtmlDisabled)(config, target) || !isProd) {
19
41
  return;
20
42
  }
21
- const { InlineChunkHtmlPlugin } = await Promise.resolve().then(() => /* @__PURE__ */ _interop_require_wildcard._(require("@modern-js/builder-shared")));
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 ? _buildershared.JS_REGEX : enableInlineScripts);
53
+ scriptTests.push(enableInlineScripts === true ? import_builder_shared.JS_REGEX : enableInlineScripts);
32
54
  }
33
55
  if (enableInlineStyles) {
34
- styleTests.push(enableInlineStyles === true ? _buildershared.CSS_REGEX : enableInlineStyles);
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(`${_buildershared.RUNTIME_CHUNK_NAME}([.].+)?\\.js$`)
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, _buildershared.pick)(config.output.distPath, [
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
+ });