@umijs/bundler-webpack 4.0.0-canary.20220428.1 → 4.0.0-canary.20220429.2

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 (99) hide show
  1. package/package.json +6 -8
  2. package/dist/build.d.ts +0 -20
  3. package/dist/build.js +0 -75
  4. package/dist/cli.d.ts +0 -1
  5. package/dist/cli.js +0 -90
  6. package/dist/client/client.d.ts +0 -1
  7. package/dist/client/client.js +0 -258
  8. package/dist/config/_sampleFeature.d.ts +0 -10
  9. package/dist/config/_sampleFeature.js +0 -22
  10. package/dist/config/assetRules.d.ts +0 -11
  11. package/dist/config/assetRules.js +0 -61
  12. package/dist/config/bundleAnalyzerPlugin.d.ts +0 -10
  13. package/dist/config/bundleAnalyzerPlugin.js +0 -30
  14. package/dist/config/compressPlugin.d.ts +0 -10
  15. package/dist/config/compressPlugin.js +0 -91
  16. package/dist/config/config.d.ts +0 -27
  17. package/dist/config/config.js +0 -226
  18. package/dist/config/copyPlugin.d.ts +0 -10
  19. package/dist/config/copyPlugin.js +0 -49
  20. package/dist/config/cssRules.d.ts +0 -11
  21. package/dist/config/cssRules.js +0 -98
  22. package/dist/config/definePlugin.d.ts +0 -15
  23. package/dist/config/definePlugin.js +0 -45
  24. package/dist/config/detectDeadCode.d.ts +0 -12
  25. package/dist/config/detectDeadCode.js +0 -120
  26. package/dist/config/detectDeadCodePlugin.d.ts +0 -9
  27. package/dist/config/detectDeadCodePlugin.js +0 -75
  28. package/dist/config/fastRefreshPlugin.d.ts +0 -12
  29. package/dist/config/fastRefreshPlugin.js +0 -34
  30. package/dist/config/forkTSCheckerPlugin.d.ts +0 -11
  31. package/dist/config/forkTSCheckerPlugin.js +0 -34
  32. package/dist/config/harmonyLinkingErrorPlugin.d.ts +0 -6
  33. package/dist/config/harmonyLinkingErrorPlugin.js +0 -42
  34. package/dist/config/ignorePlugin.d.ts +0 -10
  35. package/dist/config/ignorePlugin.js +0 -27
  36. package/dist/config/javaScriptRules.d.ts +0 -16
  37. package/dist/config/javaScriptRules.js +0 -188
  38. package/dist/config/manifestPlugin.d.ts +0 -11
  39. package/dist/config/manifestPlugin.js +0 -25
  40. package/dist/config/miniCSSExtractPlugin.d.ts +0 -11
  41. package/dist/config/miniCSSExtractPlugin.js +0 -33
  42. package/dist/config/nodePolyfill.d.ts +0 -10
  43. package/dist/config/nodePolyfill.js +0 -35
  44. package/dist/config/nodePrefixPlugin.d.ts +0 -11
  45. package/dist/config/nodePrefixPlugin.js +0 -25
  46. package/dist/config/progressPlugin.d.ts +0 -11
  47. package/dist/config/progressPlugin.js +0 -27
  48. package/dist/config/purgecssWebpackPlugin.d.ts +0 -10
  49. package/dist/config/purgecssWebpackPlugin.js +0 -32
  50. package/dist/config/speedMeasureWebpackPlugin.d.ts +0 -6
  51. package/dist/config/speedMeasureWebpackPlugin.js +0 -34
  52. package/dist/config/svgRules.d.ts +0 -12
  53. package/dist/config/svgRules.js +0 -57
  54. package/dist/constants.d.ts +0 -15
  55. package/dist/constants.js +0 -24
  56. package/dist/dev.d.ts +0 -25
  57. package/dist/dev.js +0 -145
  58. package/dist/index.d.ts +0 -8
  59. package/dist/index.js +0 -20
  60. package/dist/loader/svgr.d.ts +0 -4
  61. package/dist/loader/svgr.js +0 -67
  62. package/dist/loader/swc.d.ts +0 -4
  63. package/dist/loader/swc.js +0 -79
  64. package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts +0 -11
  65. package/dist/plugins/ESBuildCSSMinifyPlugin.js +0 -63
  66. package/dist/plugins/ParcelCSSMinifyPlugin.d.ts +0 -10
  67. package/dist/plugins/ParcelCSSMinifyPlugin.js +0 -75
  68. package/dist/plugins/ProgressPlugin.d.ts +0 -15
  69. package/dist/plugins/ProgressPlugin.js +0 -44
  70. package/dist/plugins/RuntimePublicPathPlugin.d.ts +0 -4
  71. package/dist/plugins/RuntimePublicPathPlugin.js +0 -20
  72. package/dist/plugins/_SamplePlugin.d.ts +0 -9
  73. package/dist/plugins/_SamplePlugin.js +0 -14
  74. package/dist/requireHook.d.ts +0 -1
  75. package/dist/requireHook.js +0 -31
  76. package/dist/schema.d.ts +0 -3
  77. package/dist/schema.js +0 -84
  78. package/dist/server/https.d.ts +0 -4
  79. package/dist/server/https.js +0 -74
  80. package/dist/server/server.d.ts +0 -17
  81. package/dist/server/server.js +0 -202
  82. package/dist/server/ws.d.ts +0 -11
  83. package/dist/server/ws.js +0 -42
  84. package/dist/swcPlugins/autoCSSModules.d.ts +0 -13
  85. package/dist/swcPlugins/autoCSSModules.js +0 -34
  86. package/dist/swcPlugins/changeImportFromString.d.ts +0 -2
  87. package/dist/swcPlugins/changeImportFromString.js +0 -10
  88. package/dist/swcPlugins/lockCoreJS.d.ts +0 -6
  89. package/dist/swcPlugins/lockCoreJS.js +0 -24
  90. package/dist/types.d.ts +0 -123
  91. package/dist/types.js +0 -30
  92. package/dist/utils/browsersList.d.ts +0 -5
  93. package/dist/utils/browsersList.js +0 -10
  94. package/dist/utils/depMatch.d.ts +0 -6
  95. package/dist/utils/depMatch.js +0 -46
  96. package/dist/utils/formatWebpackMessages.d.ts +0 -12
  97. package/dist/utils/formatWebpackMessages.js +0 -100
  98. package/dist/utils/getEsBuildTarget.d.ts +0 -5
  99. package/dist/utils/getEsBuildTarget.js +0 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/bundler-webpack",
3
- "version": "4.0.0-canary.20220428.1",
3
+ "version": "4.0.0-canary.20220429.2",
4
4
  "description": "@umijs/bundler-webpack",
5
5
  "homepage": "https://github.com/umijs/umi-next/tree/master/packages/bundler-webpack#readme",
6
6
  "bugs": "https://github.com/umijs/umi-next/issues",
@@ -35,22 +35,20 @@
35
35
  "@svgr/plugin-jsx": "^6.2.1",
36
36
  "@svgr/plugin-svgo": "^6.2.0",
37
37
  "@types/hapi__joi": "17.1.8",
38
- "@umijs/babel-preset-umi": "4.0.0-canary.20220428.1",
39
- "@umijs/bundler-utils": "4.0.0-canary.20220428.1",
40
- "@umijs/mfsu": "4.0.0-canary.20220428.1",
41
- "@umijs/utils": "4.0.0-canary.20220428.1",
38
+ "@umijs/babel-preset-umi": "4.0.0-canary.20220429.2",
39
+ "@umijs/bundler-utils": "4.0.0-canary.20220429.2",
40
+ "@umijs/mfsu": "4.0.0-canary.20220429.2",
41
+ "@umijs/utils": "4.0.0-canary.20220429.2",
42
42
  "css-loader": "6.7.1",
43
43
  "es5-imcompatible-versions": "^0.1.73",
44
44
  "jest-worker": "27.5.1",
45
45
  "node-libs-browser": "2.2.1",
46
46
  "postcss": "^8.4.12",
47
47
  "postcss-preset-env": "7.4.3",
48
- "react-error-overlay": "6.0.9",
49
- "spdy": "^4.0.2"
48
+ "react-error-overlay": "6.0.9"
50
49
  },
51
50
  "devDependencies": {
52
51
  "@swc/core": "1.2.165",
53
- "@types/spdy": "^3.4.5",
54
52
  "@types/webpack-sources": "3.2.0",
55
53
  "@types/ws": "8.5.3",
56
54
  "autoprefixer": "10.4.4",
package/dist/build.d.ts DELETED
@@ -1,20 +0,0 @@
1
- import webpack from '../compiled/webpack';
2
- import { IOpts as IConfigOpts } from './config/config';
3
- import { IConfig } from './types';
4
- declare type IOpts = {
5
- cwd: string;
6
- rootDir?: string;
7
- entry: Record<string, string>;
8
- config: IConfig;
9
- onBuildComplete?: Function;
10
- babelPreset?: any;
11
- chainWebpack?: Function;
12
- modifyWebpackConfig?: Function;
13
- beforeBabelPlugins?: any[];
14
- beforeBabelPresets?: any[];
15
- extraBabelPlugins?: any[];
16
- extraBabelPresets?: any[];
17
- clean?: boolean;
18
- } & Pick<IConfigOpts, 'cache'>;
19
- export declare function build(opts: IOpts): Promise<webpack.Stats>;
20
- export {};
package/dist/build.js DELETED
@@ -1,75 +0,0 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.build = void 0;
16
- const utils_1 = require("@umijs/utils");
17
- const webpack_1 = __importDefault(require("../compiled/webpack"));
18
- const config_1 = require("./config/config");
19
- 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
- extraBabelIncludes: opts.config.extraBabelIncludes,
39
- chainWebpack: opts.chainWebpack,
40
- modifyWebpackConfig: opts.modifyWebpackConfig,
41
- cache: opts.cache,
42
- });
43
- let isFirstCompile = true;
44
- return new Promise((resolve, reject) => {
45
- utils_1.rimraf.sync(webpackConfig.output.path);
46
- const compiler = (0, webpack_1.default)(webpackConfig);
47
- compiler.run((err, stats) => {
48
- var _a;
49
- (_a = opts.onBuildComplete) === null || _a === void 0 ? void 0 : _a.call(opts, {
50
- err,
51
- stats,
52
- isFirstCompile,
53
- time: stats ? stats.endTime - stats.startTime : null,
54
- });
55
- isFirstCompile = false;
56
- if (err || (stats === null || stats === void 0 ? void 0 : stats.hasErrors())) {
57
- if (err) {
58
- // console.error(err);
59
- reject(err);
60
- }
61
- if (stats) {
62
- const errorMsg = stats.toString('errors-only');
63
- // console.error(errorMsg);
64
- reject(new Error(errorMsg));
65
- }
66
- }
67
- else {
68
- resolve(stats);
69
- }
70
- compiler.close(() => { });
71
- });
72
- });
73
- });
74
- }
75
- exports.build = build;
package/dist/cli.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/dist/cli.js DELETED
@@ -1,90 +0,0 @@
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const esbuild_1 = __importDefault(require("@umijs/bundler-utils/compiled/esbuild"));
16
- const utils_1 = require("@umijs/utils");
17
- const assert_1 = __importDefault(require("assert"));
18
- const fs_1 = require("fs");
19
- const path_1 = require("path");
20
- const build_1 = require("./build");
21
- const dev_1 = require("./dev");
22
- const args = (0, utils_1.yParser)(process.argv.slice(2), {});
23
- const command = args._[0];
24
- const cwd = process.cwd();
25
- const entry = (0, utils_1.tryPaths)([
26
- (0, path_1.join)(cwd, 'src/index.tsx'),
27
- (0, path_1.join)(cwd, 'src/index.ts'),
28
- (0, path_1.join)(cwd, 'index.tsx'),
29
- (0, path_1.join)(cwd, 'index.ts'),
30
- ]);
31
- let config = {};
32
- const configFile = (0, path_1.join)(cwd, args.config || 'config.ts');
33
- utils_1.register.register({
34
- implementor: esbuild_1.default,
35
- });
36
- utils_1.register.clearFiles();
37
- if ((0, fs_1.existsSync)(configFile)) {
38
- require('./requireHook');
39
- config = require(configFile).default;
40
- }
41
- Object.assign(config, args);
42
- if (command === 'build') {
43
- (() => __awaiter(void 0, void 0, void 0, function* () {
44
- process.env.NODE_ENV = 'production';
45
- (0, assert_1.default)(entry, `Build failed: entry not found.`);
46
- try {
47
- yield (0, build_1.build)({
48
- config,
49
- cwd,
50
- entry: {
51
- [getEntryKey(entry)]: entry,
52
- },
53
- });
54
- }
55
- catch (e) {
56
- console.error(e);
57
- }
58
- }))();
59
- }
60
- else if (command === 'dev') {
61
- (() => __awaiter(void 0, void 0, void 0, function* () {
62
- process.env.NODE_ENV = 'development';
63
- try {
64
- (0, assert_1.default)(entry, `Build failed: entry not found.`);
65
- yield (0, dev_1.dev)({
66
- config,
67
- cwd,
68
- port: process.env.PORT,
69
- entry: {
70
- [getEntryKey(entry)]: entry,
71
- },
72
- cache: {
73
- buildDependencies: [].filter(Boolean),
74
- },
75
- });
76
- }
77
- catch (e) {
78
- console.error(e);
79
- }
80
- }))();
81
- }
82
- else {
83
- error(`Unsupported command ${command}.`);
84
- }
85
- function error(msg) {
86
- console.error(utils_1.chalk.red(msg));
87
- }
88
- function getEntryKey(path) {
89
- return (0, path_1.basename)(path, (0, path_1.extname)(path));
90
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,258 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
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
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- const strip_ansi_1 = __importDefault(require("@umijs/utils/compiled/strip-ansi"));
39
- // @ts-ignore
40
- const ErrorOverlay = __importStar(require("react-error-overlay"));
41
- const constants_1 = require("../constants");
42
- const formatWebpackMessages_1 = require("../utils/formatWebpackMessages");
43
- console.log('[webpack] connecting...');
44
- function getHost() {
45
- if (process.env.SOCKET_SERVER) {
46
- return new URL(process.env.SOCKET_SERVER);
47
- }
48
- return location;
49
- }
50
- function getSocketUrl() {
51
- let h = getHost();
52
- const host = h.host;
53
- const isHttps = h.protocol === 'https:';
54
- return `${isHttps ? 'wss' : 'ws'}://${host}`;
55
- }
56
- function getPingUrl() {
57
- const h = getHost();
58
- return `${h.protocol}//${h.host}/__umi_ping`;
59
- }
60
- let pingTimer = null;
61
- let isFirstCompilation = true;
62
- let mostRecentCompilationHash = null;
63
- let hasCompileErrors = false;
64
- let hadRuntimeError = false;
65
- const pingUrl = getPingUrl();
66
- const socket = new WebSocket(getSocketUrl(), 'webpack-hmr');
67
- socket.addEventListener('message', ({ data }) => __awaiter(void 0, void 0, void 0, function* () {
68
- data = JSON.parse(data);
69
- if (data.type === 'connected') {
70
- console.log(`[webpack] connected.`);
71
- // proxy(nginx, docker) hmr ws maybe caused timeout,
72
- // so send ping package let ws keep alive.
73
- pingTimer = setInterval(() => socket.send('ping'), 30000);
74
- }
75
- else {
76
- handleMessage(data).catch(console.error);
77
- }
78
- }));
79
- function waitForSuccessfulPing(ms = 1000) {
80
- return __awaiter(this, void 0, void 0, function* () {
81
- // eslint-disable-next-line no-constant-condition
82
- while (true) {
83
- try {
84
- yield fetch(pingUrl);
85
- break;
86
- }
87
- catch (e) {
88
- yield new Promise((resolve) => setTimeout(resolve, ms));
89
- }
90
- }
91
- });
92
- }
93
- socket.addEventListener('close', () => __awaiter(void 0, void 0, void 0, function* () {
94
- if (pingTimer)
95
- clearInterval(pingTimer);
96
- console.info('[webpack] Dev server disconnected. Polling for restart...');
97
- yield waitForSuccessfulPing();
98
- location.reload();
99
- }));
100
- ErrorOverlay.startReportingRuntimeErrors({
101
- onError: function () {
102
- hadRuntimeError = true;
103
- },
104
- filename: '/static/js/bundle.js',
105
- });
106
- // @ts-ignore
107
- if (module.hot && typeof module.hot.dispose === 'function') {
108
- // @ts-ignore
109
- module.hot.dispose(function () {
110
- // TODO: why do we need this?
111
- ErrorOverlay.stopReportingRuntimeErrors();
112
- });
113
- }
114
- // There is a newer version of the code available.
115
- function handleAvailableHash(hash) {
116
- // Update last known compilation hash.
117
- mostRecentCompilationHash = hash;
118
- }
119
- function handleSuccess() {
120
- const isHotUpdate = !isFirstCompilation;
121
- isFirstCompilation = false;
122
- hasCompileErrors = false;
123
- // Attempt to apply hot updates or reload.
124
- if (isHotUpdate) {
125
- tryApplyUpdates(function onHotUpdateSuccess() {
126
- // Only dismiss it when we're sure it's a hot update.
127
- // Otherwise it would flicker right before the reload.
128
- tryDismissErrorOverlay();
129
- });
130
- }
131
- }
132
- function handleWarnings(warnings) {
133
- const isHotUpdate = !isFirstCompilation;
134
- isFirstCompilation = false;
135
- hasCompileErrors = false;
136
- const formatted = (0, formatWebpackMessages_1.formatWebpackMessages)({
137
- warnings,
138
- errors: [],
139
- });
140
- // print warnings
141
- if (typeof console !== 'undefined' && typeof console.warn === 'function') {
142
- for (let i = 0; i < formatted.warnings.length; i++) {
143
- if (i === 5) {
144
- console.warn('There were more warnings in other files.\n' +
145
- 'You can find a complete log in the terminal.');
146
- break;
147
- }
148
- console.warn((0, strip_ansi_1.default)(formatted.warnings[i]));
149
- }
150
- }
151
- // Attempt to apply hot updates or reload.
152
- if (isHotUpdate) {
153
- tryApplyUpdates(function onSuccessfulHotUpdate() {
154
- // Only dismiss it when we're sure it's a hot update.
155
- // Otherwise it would flicker right before the reload.
156
- tryDismissErrorOverlay();
157
- });
158
- }
159
- }
160
- function handleErrors(errors) {
161
- isFirstCompilation = false;
162
- hasCompileErrors = true;
163
- const formatted = (0, formatWebpackMessages_1.formatWebpackMessages)({
164
- warnings: [],
165
- errors,
166
- });
167
- // Only show the first error.
168
- ErrorOverlay.reportBuildError(formatted.errors[0]);
169
- // Also log them to the console.
170
- if (typeof console !== 'undefined' && typeof console.error === 'function') {
171
- for (let i = 0; i < formatted.errors.length; i++) {
172
- console.error((0, strip_ansi_1.default)(formatted.errors[i]));
173
- }
174
- }
175
- }
176
- function tryDismissErrorOverlay() {
177
- if (!hasCompileErrors) {
178
- ErrorOverlay.dismissBuildError();
179
- }
180
- }
181
- // Is there a newer version of this code available?
182
- function isUpdateAvailable() {
183
- // @ts-ignore
184
- return mostRecentCompilationHash !== __webpack_hash__;
185
- }
186
- function canApplyUpdates() {
187
- // @ts-ignore
188
- return module.hot.status() === 'idle';
189
- }
190
- function canAcceptErrors() {
191
- // NOTE: This var is injected by Webpack's DefinePlugin, and is a boolean instead of string.
192
- const hasReactRefresh = process.env.FAST_REFRESH;
193
- // @ts-ignore
194
- const status = module.hot.status();
195
- // React refresh can handle hot-reloading over errors.
196
- // However, when hot-reload status is abort or fail,
197
- // it indicates the current update cannot be applied safely,
198
- // and thus we should bail out to a forced reload for consistency.
199
- return hasReactRefresh && ['abort', 'fail'].indexOf(status) === -1;
200
- }
201
- function tryApplyUpdates(onHotUpdateSuccess) {
202
- // @ts-ignore
203
- if (!module.hot) {
204
- window.location.reload();
205
- return;
206
- }
207
- if (!isUpdateAvailable() || !canApplyUpdates()) {
208
- return;
209
- }
210
- function handleApplyUpdates(err, updatedModules) {
211
- const haveErrors = err || hadRuntimeError;
212
- // When there is no error but updatedModules is unavailable,
213
- // it indicates a critical failure in hot-reloading,
214
- // e.g. server is not ready to serve new bundle,
215
- // and hence we need to do a forced reload.
216
- const needsForcedReload = !err && !updatedModules;
217
- if ((haveErrors && !canAcceptErrors()) || needsForcedReload) {
218
- window.location.reload();
219
- }
220
- if (onHotUpdateSuccess)
221
- onHotUpdateSuccess();
222
- // While we were updating, there was a new update! Do it again.
223
- if (isUpdateAvailable()) {
224
- tryApplyUpdates();
225
- }
226
- }
227
- // @ts-ignore
228
- module.hot
229
- .check(/* autoApply */ true)
230
- .then((updatedModules) => {
231
- handleApplyUpdates(null, updatedModules);
232
- })
233
- .catch((err) => {
234
- handleApplyUpdates(err, null);
235
- });
236
- }
237
- function handleMessage(payload) {
238
- return __awaiter(this, void 0, void 0, function* () {
239
- // console.log('[payload]', payload);
240
- switch (payload.type) {
241
- case constants_1.MESSAGE_TYPE.hash:
242
- handleAvailableHash(payload.data);
243
- break;
244
- case constants_1.MESSAGE_TYPE.stillOk:
245
- case constants_1.MESSAGE_TYPE.ok:
246
- handleSuccess();
247
- break;
248
- case constants_1.MESSAGE_TYPE.errors:
249
- handleErrors(payload.data);
250
- break;
251
- case constants_1.MESSAGE_TYPE.warnings:
252
- handleWarnings(payload.data);
253
- break;
254
- default:
255
- // Do nothing
256
- }
257
- });
258
- }
@@ -1,10 +0,0 @@
1
- import Config from '@umijs/bundler-webpack/compiled/webpack-5-chain';
2
- import { Env, IConfig } from '../types';
3
- interface IOpts {
4
- config: Config;
5
- userConfig: IConfig;
6
- cwd: string;
7
- env: Env;
8
- }
9
- export declare function addSampleFeature(opts: IOpts): Promise<void>;
10
- export {};
@@ -1,22 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- 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
- });
21
- }
22
- exports.addSampleFeature = addSampleFeature;
@@ -1,11 +0,0 @@
1
- import Config from '@umijs/bundler-webpack/compiled/webpack-5-chain';
2
- import { Env, IConfig } from '../types';
3
- interface IOpts {
4
- config: Config;
5
- userConfig: IConfig;
6
- cwd: string;
7
- env: Env;
8
- staticPathPrefix: string;
9
- }
10
- export declare function addAssetRules(opts: IOpts): Promise<void>;
11
- export {};
@@ -1,61 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- 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
- });
59
- });
60
- }
61
- exports.addAssetRules = addAssetRules;
@@ -1,10 +0,0 @@
1
- import Config from '@umijs/bundler-webpack/compiled/webpack-5-chain';
2
- import { Env, IConfig } from '../types';
3
- interface IOpts {
4
- config: Config;
5
- userConfig: IConfig;
6
- cwd: string;
7
- env: Env;
8
- }
9
- export declare function addBundleAnalyzerPlugin(opts: IOpts): Promise<void>;
10
- export {};
@@ -1,30 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.addBundleAnalyzerPlugin = void 0;
13
- // @ts-ignore
14
- 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
- });
29
- }
30
- exports.addBundleAnalyzerPlugin = addBundleAnalyzerPlugin;
@@ -1,10 +0,0 @@
1
- import Config from '../../compiled/webpack-5-chain';
2
- import { Env, IConfig } from '../types';
3
- interface IOpts {
4
- config: Config;
5
- userConfig: IConfig;
6
- cwd: string;
7
- env: Env;
8
- }
9
- export declare function addCompressPlugin(opts: IOpts): Promise<void>;
10
- export {};