@umijs/bundler-webpack 4.0.0-rc.13 → 4.0.0-rc.16

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 (42) hide show
  1. package/client/client/client.js +15 -7
  2. package/dist/build.js +48 -58
  3. package/dist/cli.js +6 -15
  4. package/dist/client/client.js +48 -53
  5. package/dist/config/_sampleFeature.js +6 -17
  6. package/dist/config/assetRules.js +44 -55
  7. package/dist/config/bundleAnalyzerPlugin.js +12 -23
  8. package/dist/config/compressPlugin.js +68 -76
  9. package/dist/config/config.d.ts +1 -0
  10. package/dist/config/config.js +177 -184
  11. package/dist/config/copyPlugin.js +29 -40
  12. package/dist/config/cssRules.js +93 -83
  13. package/dist/config/definePlugin.js +11 -19
  14. package/dist/config/detectDeadCodePlugin.js +16 -21
  15. package/dist/config/fastRefreshPlugin.js +11 -22
  16. package/dist/config/forkTSCheckerPlugin.js +11 -22
  17. package/dist/config/harmonyLinkingErrorPlugin.js +3 -14
  18. package/dist/config/ignorePlugin.js +10 -21
  19. package/dist/config/javaScriptRules.d.ts +1 -0
  20. package/dist/config/javaScriptRules.js +149 -136
  21. package/dist/config/manifestPlugin.js +10 -18
  22. package/dist/config/miniCSSExtractPlugin.js +12 -23
  23. package/dist/config/nodePolyfill.js +14 -20
  24. package/dist/config/nodePrefixPlugin.js +8 -19
  25. package/dist/config/progressPlugin.js +7 -18
  26. package/dist/config/purgecssWebpackPlugin.js +15 -26
  27. package/dist/config/speedMeasureWebpackPlugin.js +12 -23
  28. package/dist/config/svgRules.js +43 -47
  29. package/dist/dev.js +103 -100
  30. package/dist/loader/svgr.js +4 -13
  31. package/dist/loader/swc.js +9 -14
  32. package/dist/plugins/ESBuildCSSMinifyPlugin.js +23 -34
  33. package/dist/plugins/ParcelCSSMinifyPlugin.js +30 -32
  34. package/dist/plugins/RuntimePublicPathPlugin.js +1 -1
  35. package/dist/schema.js +19 -6
  36. package/dist/server/server.d.ts +1 -1
  37. package/dist/server/server.js +161 -182
  38. package/dist/server/ws.d.ts +3 -1
  39. package/dist/types.d.ts +3 -6
  40. package/package.json +10 -10
  41. package/dist/server/https.d.ts +0 -5
  42. package/dist/server/https.js +0 -73
@@ -13,21 +13,29 @@ import * as ErrorOverlay from 'react-error-overlay';
13
13
  import { MESSAGE_TYPE } from '../constants';
14
14
  import { formatWebpackMessages } from '../utils/formatWebpackMessages';
15
15
  console.log('[webpack] connecting...');
16
- function getSocketHost() {
17
- let l = location;
16
+ function getHost() {
18
17
  if (process.env.SOCKET_SERVER) {
19
- l = new URL(process.env.SOCKET_SERVER);
18
+ return new URL(process.env.SOCKET_SERVER);
20
19
  }
21
- const host = l.host;
22
- const isHttps = l.protocol === 'https:';
20
+ return location;
21
+ }
22
+ function getSocketUrl() {
23
+ let h = getHost();
24
+ const host = h.host;
25
+ const isHttps = h.protocol === 'https:';
23
26
  return `${isHttps ? 'wss' : 'ws'}://${host}`;
24
27
  }
28
+ function getPingUrl() {
29
+ const h = getHost();
30
+ return `${h.protocol}//${h.host}/__umi_ping`;
31
+ }
25
32
  let pingTimer = null;
26
33
  let isFirstCompilation = true;
27
34
  let mostRecentCompilationHash = null;
28
35
  let hasCompileErrors = false;
29
36
  let hadRuntimeError = false;
30
- const socket = new WebSocket(getSocketHost(), 'webpack-hmr');
37
+ const pingUrl = getPingUrl();
38
+ const socket = new WebSocket(getSocketUrl(), 'webpack-hmr');
31
39
  socket.addEventListener('message', ({ data }) => __awaiter(void 0, void 0, void 0, function* () {
32
40
  data = JSON.parse(data);
33
41
  if (data.type === 'connected') {
@@ -45,7 +53,7 @@ function waitForSuccessfulPing(ms = 1000) {
45
53
  // eslint-disable-next-line no-constant-condition
46
54
  while (true) {
47
55
  try {
48
- yield fetch(`/__umi_ping`);
56
+ yield fetch(pingUrl);
49
57
  break;
50
58
  }
51
59
  catch (e) {
package/dist/build.js CHANGED
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -17,57 +8,56 @@ const utils_1 = require("@umijs/utils");
17
8
  const webpack_1 = __importDefault(require("../compiled/webpack"));
18
9
  const config_1 = require("./config/config");
19
10
  const types_1 = require("./types");
20
- function build(opts) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- const webpackConfig = yield (0, config_1.getConfig)({
23
- cwd: opts.cwd,
24
- rootDir: opts.rootDir,
25
- env: types_1.Env.production,
26
- entry: opts.entry,
27
- userConfig: opts.config,
28
- analyze: process.env.ANALYZE,
29
- babelPreset: opts.babelPreset,
30
- extraBabelPlugins: [
31
- ...(opts.beforeBabelPlugins || []),
32
- ...(opts.extraBabelPlugins || []),
33
- ],
34
- extraBabelPresets: [
35
- ...(opts.beforeBabelPresets || []),
36
- ...(opts.extraBabelPresets || []),
37
- ],
38
- chainWebpack: opts.chainWebpack,
39
- modifyWebpackConfig: opts.modifyWebpackConfig,
40
- cache: opts.cache,
41
- });
42
- let isFirstCompile = true;
43
- return new Promise((resolve, reject) => {
44
- utils_1.rimraf.sync(webpackConfig.output.path);
45
- const compiler = (0, webpack_1.default)(webpackConfig);
46
- compiler.run((err, stats) => {
47
- var _a;
48
- (_a = opts.onBuildComplete) === null || _a === void 0 ? void 0 : _a.call(opts, {
49
- err,
50
- stats,
51
- isFirstCompile,
52
- time: stats ? stats.endTime - stats.startTime : null,
53
- });
54
- isFirstCompile = false;
55
- if (err || (stats === null || stats === void 0 ? void 0 : stats.hasErrors())) {
56
- if (err) {
57
- // console.error(err);
58
- reject(err);
59
- }
60
- if (stats) {
61
- const errorMsg = stats.toString('errors-only');
62
- // console.error(errorMsg);
63
- reject(new Error(errorMsg));
64
- }
11
+ async function build(opts) {
12
+ const webpackConfig = await (0, config_1.getConfig)({
13
+ cwd: opts.cwd,
14
+ rootDir: opts.rootDir,
15
+ env: types_1.Env.production,
16
+ entry: opts.entry,
17
+ userConfig: opts.config,
18
+ analyze: process.env.ANALYZE,
19
+ babelPreset: opts.babelPreset,
20
+ extraBabelPlugins: [
21
+ ...(opts.beforeBabelPlugins || []),
22
+ ...(opts.extraBabelPlugins || []),
23
+ ],
24
+ extraBabelPresets: [
25
+ ...(opts.beforeBabelPresets || []),
26
+ ...(opts.extraBabelPresets || []),
27
+ ],
28
+ extraBabelIncludes: opts.config.extraBabelIncludes,
29
+ chainWebpack: opts.chainWebpack,
30
+ modifyWebpackConfig: opts.modifyWebpackConfig,
31
+ cache: opts.cache,
32
+ });
33
+ let isFirstCompile = true;
34
+ return new Promise((resolve, reject) => {
35
+ utils_1.rimraf.sync(webpackConfig.output.path);
36
+ const compiler = (0, webpack_1.default)(webpackConfig);
37
+ compiler.run((err, stats) => {
38
+ var _a;
39
+ (_a = opts.onBuildComplete) === null || _a === void 0 ? void 0 : _a.call(opts, {
40
+ err,
41
+ stats,
42
+ isFirstCompile,
43
+ time: stats ? stats.endTime - stats.startTime : null,
44
+ });
45
+ isFirstCompile = false;
46
+ if (err || (stats === null || stats === void 0 ? void 0 : stats.hasErrors())) {
47
+ if (err) {
48
+ // console.error(err);
49
+ reject(err);
65
50
  }
66
- else {
67
- resolve(stats);
51
+ if (stats) {
52
+ const errorMsg = stats.toString('errors-only');
53
+ // console.error(errorMsg);
54
+ reject(new Error(errorMsg));
68
55
  }
69
- compiler.close(() => { });
70
- });
56
+ }
57
+ else {
58
+ resolve(stats);
59
+ }
60
+ compiler.close(() => { });
71
61
  });
72
62
  });
73
63
  }
package/dist/cli.js CHANGED
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -40,11 +31,11 @@ if ((0, fs_1.existsSync)(configFile)) {
40
31
  }
41
32
  Object.assign(config, args);
42
33
  if (command === 'build') {
43
- (() => __awaiter(void 0, void 0, void 0, function* () {
34
+ (async () => {
44
35
  process.env.NODE_ENV = 'production';
45
36
  (0, assert_1.default)(entry, `Build failed: entry not found.`);
46
37
  try {
47
- yield (0, build_1.build)({
38
+ await (0, build_1.build)({
48
39
  config,
49
40
  cwd,
50
41
  entry: {
@@ -55,14 +46,14 @@ if (command === 'build') {
55
46
  catch (e) {
56
47
  console.error(e);
57
48
  }
58
- }))();
49
+ })();
59
50
  }
60
51
  else if (command === 'dev') {
61
- (() => __awaiter(void 0, void 0, void 0, function* () {
52
+ (async () => {
62
53
  process.env.NODE_ENV = 'development';
63
54
  try {
64
55
  (0, assert_1.default)(entry, `Build failed: entry not found.`);
65
- yield (0, dev_1.dev)({
56
+ await (0, dev_1.dev)({
66
57
  config,
67
58
  cwd,
68
59
  port: process.env.PORT,
@@ -77,7 +68,7 @@ else if (command === 'dev') {
77
68
  catch (e) {
78
69
  console.error(e);
79
70
  }
80
- }))();
71
+ })();
81
72
  }
82
73
  else {
83
74
  error(`Unsupported command ${command}.`);
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
35
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
36
27
  };
@@ -41,22 +32,30 @@ const ErrorOverlay = __importStar(require("react-error-overlay"));
41
32
  const constants_1 = require("../constants");
42
33
  const formatWebpackMessages_1 = require("../utils/formatWebpackMessages");
43
34
  console.log('[webpack] connecting...');
44
- function getSocketHost() {
45
- let l = location;
35
+ function getHost() {
46
36
  if (process.env.SOCKET_SERVER) {
47
- l = new URL(process.env.SOCKET_SERVER);
37
+ return new URL(process.env.SOCKET_SERVER);
48
38
  }
49
- const host = l.host;
50
- const isHttps = l.protocol === 'https:';
39
+ return location;
40
+ }
41
+ function getSocketUrl() {
42
+ let h = getHost();
43
+ const host = h.host;
44
+ const isHttps = h.protocol === 'https:';
51
45
  return `${isHttps ? 'wss' : 'ws'}://${host}`;
52
46
  }
47
+ function getPingUrl() {
48
+ const h = getHost();
49
+ return `${h.protocol}//${h.host}/__umi_ping`;
50
+ }
53
51
  let pingTimer = null;
54
52
  let isFirstCompilation = true;
55
53
  let mostRecentCompilationHash = null;
56
54
  let hasCompileErrors = false;
57
55
  let hadRuntimeError = false;
58
- const socket = new WebSocket(getSocketHost(), 'webpack-hmr');
59
- socket.addEventListener('message', ({ data }) => __awaiter(void 0, void 0, void 0, function* () {
56
+ const pingUrl = getPingUrl();
57
+ const socket = new WebSocket(getSocketUrl(), 'webpack-hmr');
58
+ socket.addEventListener('message', async ({ data }) => {
60
59
  data = JSON.parse(data);
61
60
  if (data.type === 'connected') {
62
61
  console.log(`[webpack] connected.`);
@@ -67,28 +66,26 @@ socket.addEventListener('message', ({ data }) => __awaiter(void 0, void 0, void
67
66
  else {
68
67
  handleMessage(data).catch(console.error);
69
68
  }
70
- }));
71
- function waitForSuccessfulPing(ms = 1000) {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- // eslint-disable-next-line no-constant-condition
74
- while (true) {
75
- try {
76
- yield fetch(`/__umi_ping`);
77
- break;
78
- }
79
- catch (e) {
80
- yield new Promise((resolve) => setTimeout(resolve, ms));
81
- }
69
+ });
70
+ async function waitForSuccessfulPing(ms = 1000) {
71
+ // eslint-disable-next-line no-constant-condition
72
+ while (true) {
73
+ try {
74
+ await fetch(pingUrl);
75
+ break;
82
76
  }
83
- });
77
+ catch (e) {
78
+ await new Promise((resolve) => setTimeout(resolve, ms));
79
+ }
80
+ }
84
81
  }
85
- socket.addEventListener('close', () => __awaiter(void 0, void 0, void 0, function* () {
82
+ socket.addEventListener('close', async () => {
86
83
  if (pingTimer)
87
84
  clearInterval(pingTimer);
88
85
  console.info('[webpack] Dev server disconnected. Polling for restart...');
89
- yield waitForSuccessfulPing();
86
+ await waitForSuccessfulPing();
90
87
  location.reload();
91
- }));
88
+ });
92
89
  ErrorOverlay.startReportingRuntimeErrors({
93
90
  onError: function () {
94
91
  hadRuntimeError = true;
@@ -226,25 +223,23 @@ function tryApplyUpdates(onHotUpdateSuccess) {
226
223
  handleApplyUpdates(err, null);
227
224
  });
228
225
  }
229
- function handleMessage(payload) {
230
- return __awaiter(this, void 0, void 0, function* () {
231
- // console.log('[payload]', payload);
232
- switch (payload.type) {
233
- case constants_1.MESSAGE_TYPE.hash:
234
- handleAvailableHash(payload.data);
235
- break;
236
- case constants_1.MESSAGE_TYPE.stillOk:
237
- case constants_1.MESSAGE_TYPE.ok:
238
- handleSuccess();
239
- break;
240
- case constants_1.MESSAGE_TYPE.errors:
241
- handleErrors(payload.data);
242
- break;
243
- case constants_1.MESSAGE_TYPE.warnings:
244
- handleWarnings(payload.data);
245
- break;
246
- default:
247
- // Do nothing
248
- }
249
- });
226
+ async function handleMessage(payload) {
227
+ // console.log('[payload]', payload);
228
+ switch (payload.type) {
229
+ case constants_1.MESSAGE_TYPE.hash:
230
+ handleAvailableHash(payload.data);
231
+ break;
232
+ case constants_1.MESSAGE_TYPE.stillOk:
233
+ case constants_1.MESSAGE_TYPE.ok:
234
+ handleSuccess();
235
+ break;
236
+ case constants_1.MESSAGE_TYPE.errors:
237
+ handleErrors(payload.data);
238
+ break;
239
+ case constants_1.MESSAGE_TYPE.warnings:
240
+ handleWarnings(payload.data);
241
+ break;
242
+ default:
243
+ // Do nothing
244
+ }
250
245
  }
@@ -1,22 +1,11 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.addSampleFeature = void 0;
13
- function addSampleFeature(opts) {
14
- return __awaiter(this, void 0, void 0, function* () {
15
- const { config, userConfig, cwd, env } = opts;
16
- config;
17
- userConfig;
18
- cwd;
19
- env;
20
- });
4
+ async function addSampleFeature(opts) {
5
+ const { config, userConfig, cwd, env } = opts;
6
+ config;
7
+ userConfig;
8
+ cwd;
9
+ env;
21
10
  }
22
11
  exports.addSampleFeature = addSampleFeature;
@@ -1,61 +1,50 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.addAssetRules = void 0;
13
- function addAssetRules(opts) {
14
- return __awaiter(this, void 0, void 0, function* () {
15
- const { config, userConfig } = opts;
16
- const inlineLimit = parseInt(userConfig.inlineLimit || '10000', 10);
17
- const rule = config.module.rule('asset');
18
- rule
19
- .oneOf('avif')
20
- .test(/\.avif$/)
21
- .type('asset')
22
- .mimetype('image/avif')
23
- .parser({
24
- dataUrlCondition: {
25
- maxSize: inlineLimit,
26
- },
27
- })
28
- .generator({
29
- filename: `${opts.staticPathPrefix}[name].[hash:8].[ext]`,
30
- });
31
- rule
32
- .oneOf('image')
33
- .test(/\.(bmp|gif|jpg|jpeg|png)$/)
34
- .type('asset')
35
- .parser({
36
- dataUrlCondition: {
37
- maxSize: inlineLimit,
38
- },
39
- })
40
- .generator({
41
- filename: `${opts.staticPathPrefix}[name].[hash:8].[ext]`,
42
- });
43
- const fallback = rule
44
- .oneOf('fallback')
45
- .exclude.add(/^$/) /* handle data: resources */
46
- .add(/\.(js|mjs|jsx|ts|tsx)$/)
47
- .add(/\.(css|less|sass|scss|stylus)$/)
48
- .add(/\.html$/)
49
- .add(/\.json$/);
50
- if (userConfig.mdx) {
51
- fallback.add(/\.mdx?$/);
52
- }
53
- fallback
54
- .end()
55
- .type('asset/resource')
56
- .generator({
57
- filename: `${opts.staticPathPrefix}[name].[hash:8].[ext]`,
58
- });
4
+ async function addAssetRules(opts) {
5
+ const { config, userConfig } = opts;
6
+ const inlineLimit = parseInt(userConfig.inlineLimit || '10000', 10);
7
+ const rule = config.module.rule('asset');
8
+ rule
9
+ .oneOf('avif')
10
+ .test(/\.avif$/)
11
+ .type('asset')
12
+ .mimetype('image/avif')
13
+ .parser({
14
+ dataUrlCondition: {
15
+ maxSize: inlineLimit,
16
+ },
17
+ })
18
+ .generator({
19
+ filename: `${opts.staticPathPrefix}[name].[hash:8].[ext]`,
20
+ });
21
+ rule
22
+ .oneOf('image')
23
+ .test(/\.(bmp|gif|jpg|jpeg|png)$/)
24
+ .type('asset')
25
+ .parser({
26
+ dataUrlCondition: {
27
+ maxSize: inlineLimit,
28
+ },
29
+ })
30
+ .generator({
31
+ filename: `${opts.staticPathPrefix}[name].[hash:8].[ext]`,
32
+ });
33
+ const fallback = rule
34
+ .oneOf('fallback')
35
+ .exclude.add(/^$/) /* handle data: resources */
36
+ .add(/\.(js|mjs|jsx|ts|tsx)$/)
37
+ .add(/\.(css|less|sass|scss|stylus)$/)
38
+ .add(/\.html$/)
39
+ .add(/\.json$/);
40
+ if (userConfig.mdx) {
41
+ fallback.add(/\.mdx?$/);
42
+ }
43
+ fallback
44
+ .end()
45
+ .type('asset/resource')
46
+ .generator({
47
+ filename: `${opts.staticPathPrefix}[name].[hash:8].[ext]`,
59
48
  });
60
49
  }
61
50
  exports.addAssetRules = addAssetRules;
@@ -1,30 +1,19 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.addBundleAnalyzerPlugin = void 0;
13
4
  // @ts-ignore
14
5
  const webpack_bundle_analyzer_1 = require("@umijs/bundler-webpack/compiled/webpack-bundle-analyzer");
15
- function addBundleAnalyzerPlugin(opts) {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- const { config } = opts;
18
- config.plugin('webpack-bundle-analyzer').use(webpack_bundle_analyzer_1.BundleAnalyzerPlugin, [
19
- // https://github.com/webpack-contrib/webpack-bundle-analyzer
20
- {
21
- analyzerMode: 'server',
22
- analyzerPort: process.env.ANALYZE_PORT || 8888,
23
- openAnalyzer: false,
24
- logLevel: 'info',
25
- defaultSizes: 'parsed',
26
- },
27
- ]);
28
- });
6
+ async function addBundleAnalyzerPlugin(opts) {
7
+ const { config } = opts;
8
+ config.plugin('webpack-bundle-analyzer').use(webpack_bundle_analyzer_1.BundleAnalyzerPlugin, [
9
+ // https://github.com/webpack-contrib/webpack-bundle-analyzer
10
+ {
11
+ analyzerMode: 'server',
12
+ analyzerPort: process.env.ANALYZE_PORT || 8888,
13
+ openAnalyzer: false,
14
+ logLevel: 'info',
15
+ defaultSizes: 'parsed',
16
+ },
17
+ ]);
29
18
  }
30
19
  exports.addBundleAnalyzerPlugin = addBundleAnalyzerPlugin;