@umijs/bundler-webpack 4.0.0-rc.9 → 4.0.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.
- package/client/client/client.js +65 -37
- package/client/constants.js +9 -0
- package/compiled/css-minimizer-webpack-plugin/index.js +7 -7
- package/compiled/cssnano/index.js +6 -6
- package/compiled/fork-ts-checker-webpack-plugin/index.js +7 -13
- package/compiled/{tapable → react-refresh}/LICENSE +6 -6
- package/compiled/react-refresh/index.js +9 -7
- package/compiled/react-refresh/package.json +1 -0
- package/compiled/webpack/BasicEffectRulePlugin.js +1 -0
- package/compiled/webpack/BasicMatcherRulePlugin.js +1 -0
- package/compiled/webpack/HotModuleReplacement.runtime.js +29 -14
- package/compiled/webpack/JavascriptHotModuleReplacement.runtime.js +4 -3
- package/compiled/webpack/ObjectMatcherRulePlugin.js +1 -0
- package/compiled/webpack/RuleSetCompiler.js +1 -0
- package/compiled/webpack/UseEffectRulePlugin.js +1 -0
- package/compiled/webpack/deepImports.json +6 -1
- package/compiled/webpack/index.js +3978 -3167
- package/compiled/webpack/types.d.ts +606 -171
- package/compiled/webpack-dev-middleware/index.js +8 -7
- package/compiled/webpack-manifest-plugin/index.js +1 -1
- package/dist/build.d.ts +1 -0
- package/dist/build.js +49 -56
- package/dist/cli.js +6 -15
- package/dist/client/client.js +52 -50
- package/dist/config/_sampleFeature.js +6 -17
- package/dist/config/assetRules.js +33 -55
- package/dist/config/bundleAnalyzerPlugin.js +12 -23
- package/dist/config/compressPlugin.js +89 -70
- package/dist/config/config.d.ts +2 -0
- package/dist/config/config.js +182 -179
- package/dist/config/copyPlugin.js +29 -40
- package/dist/config/cssRules.js +114 -83
- package/dist/config/definePlugin.js +11 -19
- package/dist/config/detectDeadCodePlugin.js +16 -21
- package/dist/config/fastRefreshPlugin.js +11 -22
- package/dist/config/forkTSCheckerPlugin.js +11 -22
- package/dist/config/harmonyLinkingErrorPlugin.js +3 -14
- package/dist/config/ignorePlugin.js +10 -21
- package/dist/config/javaScriptRules.d.ts +1 -0
- package/dist/config/javaScriptRules.js +152 -136
- package/dist/config/manifestPlugin.d.ts +1 -1
- package/dist/config/manifestPlugin.js +10 -18
- package/dist/config/miniCSSExtractPlugin.js +15 -23
- package/dist/config/nodePolyfill.js +14 -20
- package/dist/config/nodePrefixPlugin.d.ts +11 -0
- package/dist/config/nodePrefixPlugin.js +14 -0
- package/dist/config/progressPlugin.js +7 -18
- package/dist/config/purgecssWebpackPlugin.js +15 -26
- package/dist/config/speedMeasureWebpackPlugin.js +12 -23
- package/dist/config/ssrPlugin.d.ts +11 -0
- package/dist/config/ssrPlugin.js +66 -0
- package/dist/config/svgRules.js +35 -44
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +7 -1
- package/dist/dev.d.ts +4 -0
- package/dist/dev.js +113 -93
- package/dist/index.d.ts +3 -0
- package/dist/index.js +16 -0
- package/dist/loader/svgr.js +4 -13
- package/dist/loader/swc.js +9 -14
- package/dist/plugins/ProgressPlugin.js +3 -3
- package/dist/plugins/RuntimePublicPathPlugin.js +4 -1
- package/dist/schema.d.ts +1 -2
- package/dist/schema.js +21 -6
- package/dist/server/server.d.ts +3 -1
- package/dist/server/server.js +165 -159
- package/dist/server/ws.d.ts +7 -2
- package/dist/types.d.ts +3 -0
- package/dist/utils/getEsBuildTarget.d.ts +5 -0
- package/dist/utils/getEsBuildTarget.js +12 -0
- package/package.json +23 -21
- package/compiled/tapable/index.js +0 -1
- package/compiled/tapable/package.json +0 -1
- package/compiled/tapable/tapable.d.ts +0 -116
- package/dist/plugins/ESBuildCSSMinifyPlugin.d.ts +0 -11
- package/dist/plugins/ESBuildCSSMinifyPlugin.js +0 -63
- package/dist/plugins/ParcelCSSMinifyPlugin.d.ts +0 -10
- package/dist/plugins/ParcelCSSMinifyPlugin.js +0 -75
package/dist/server/server.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
import { Configuration } from '@umijs/bundler-webpack/compiled/webpack';
|
|
3
4
|
import http from 'http';
|
|
4
5
|
import { IConfig } from '../types';
|
|
@@ -11,6 +12,7 @@ interface IOpts {
|
|
|
11
12
|
beforeMiddlewares?: any[];
|
|
12
13
|
afterMiddlewares?: any[];
|
|
13
14
|
onDevCompileDone?: Function;
|
|
15
|
+
onProgress?: Function;
|
|
14
16
|
}
|
|
15
|
-
export declare function createServer(opts: IOpts): Promise<http.Server>;
|
|
17
|
+
export declare function createServer(opts: IOpts): Promise<http.Server | import("https").Server | null>;
|
|
16
18
|
export {};
|
package/dist/server/server.js
CHANGED
|
@@ -1,189 +1,195 @@
|
|
|
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
|
};
|
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
6
|
exports.createServer = void 0;
|
|
7
|
+
const bundler_utils_1 = require("@umijs/bundler-utils");
|
|
16
8
|
const express_1 = __importDefault(require("@umijs/bundler-utils/compiled/express"));
|
|
17
9
|
const http_proxy_middleware_1 = require("@umijs/bundler-webpack/compiled/http-proxy-middleware");
|
|
18
10
|
const webpack_1 = __importDefault(require("@umijs/bundler-webpack/compiled/webpack"));
|
|
19
11
|
const utils_1 = require("@umijs/utils");
|
|
12
|
+
const cors_1 = __importDefault(require("cors"));
|
|
20
13
|
const fs_1 = require("fs");
|
|
21
14
|
const http_1 = __importDefault(require("http"));
|
|
22
15
|
const path_1 = require("path");
|
|
23
16
|
const constants_1 = require("../constants");
|
|
24
17
|
const ws_1 = require("./ws");
|
|
25
|
-
function createServer(opts) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
res.
|
|
18
|
+
async function createServer(opts) {
|
|
19
|
+
const { webpackConfig, userConfig } = opts;
|
|
20
|
+
const { proxy } = userConfig;
|
|
21
|
+
const app = (0, express_1.default)();
|
|
22
|
+
// cros
|
|
23
|
+
app.use((0, cors_1.default)({
|
|
24
|
+
origin: true,
|
|
25
|
+
methods: ['GET', 'HEAD', 'PUT', 'POST', 'PATCH', 'DELETE', 'OPTIONS'],
|
|
26
|
+
credentials: true,
|
|
27
|
+
}));
|
|
28
|
+
// compression
|
|
29
|
+
app.use(require('@umijs/bundler-webpack/compiled/compression')());
|
|
30
|
+
// TODO: headers
|
|
31
|
+
// before middlewares
|
|
32
|
+
(opts.beforeMiddlewares || []).forEach((m) => app.use(m));
|
|
33
|
+
// TODO: add to before middleware
|
|
34
|
+
app.use((req, res, next) => {
|
|
35
|
+
const file = req.path;
|
|
36
|
+
const filePath = (0, path_1.join)(opts.cwd, file);
|
|
37
|
+
const ext = (0, path_1.extname)(filePath);
|
|
38
|
+
if (ext === '.js' && (0, fs_1.existsSync)(filePath)) {
|
|
39
|
+
res.sendFile(filePath);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
47
42
|
next();
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
// webpack dev middleware
|
|
46
|
+
const configs = Array.isArray(webpackConfig)
|
|
47
|
+
? webpackConfig
|
|
48
|
+
: [webpackConfig];
|
|
49
|
+
const progresses = [];
|
|
50
|
+
if (opts.onProgress) {
|
|
51
|
+
configs.forEach((config) => {
|
|
52
|
+
const progress = {
|
|
53
|
+
percent: 0,
|
|
54
|
+
status: 'waiting',
|
|
55
|
+
};
|
|
56
|
+
progresses.push(progress);
|
|
57
|
+
config.plugins.push(new webpack_1.default.ProgressPlugin((percent, msg) => {
|
|
58
|
+
progress.percent = percent;
|
|
59
|
+
progress.status = msg;
|
|
60
|
+
opts.onProgress({ progresses });
|
|
61
|
+
}));
|
|
48
62
|
});
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const webpackDevMiddleware = require('@umijs/bundler-webpack/compiled/webpack-dev-middleware');
|
|
67
|
-
const compilerMiddleware = webpackDevMiddleware(compiler, {
|
|
68
|
-
publicPath: '/',
|
|
69
|
-
writeToDisk: userConfig.writeToDisk,
|
|
70
|
-
stats: 'none',
|
|
71
|
-
// watchOptions: { ignored }
|
|
63
|
+
}
|
|
64
|
+
const compiler = (0, webpack_1.default)(configs);
|
|
65
|
+
const webpackDevMiddleware = require('@umijs/bundler-webpack/compiled/webpack-dev-middleware');
|
|
66
|
+
const compilerMiddleware = webpackDevMiddleware(compiler, {
|
|
67
|
+
publicPath: userConfig.publicPath || '/',
|
|
68
|
+
writeToDisk: userConfig.writeToDisk,
|
|
69
|
+
stats: 'none',
|
|
70
|
+
// watchOptions: { ignored }
|
|
71
|
+
});
|
|
72
|
+
app.use(compilerMiddleware);
|
|
73
|
+
// hmr hooks
|
|
74
|
+
let stats;
|
|
75
|
+
let isFirstCompile = true;
|
|
76
|
+
compiler.compilers.forEach(addHooks);
|
|
77
|
+
function addHooks(compiler) {
|
|
78
|
+
compiler.hooks.invalid.tap('server', () => {
|
|
79
|
+
sendMessage(constants_1.MESSAGE_TYPE.invalid);
|
|
72
80
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
compiler.hooks.done.tap('server', (_stats) => {
|
|
83
|
-
var _a;
|
|
84
|
-
stats = _stats;
|
|
85
|
-
sendStats(getStats(stats));
|
|
86
|
-
(_a = opts.onDevCompileDone) === null || _a === void 0 ? void 0 : _a.call(opts, {
|
|
87
|
-
stats,
|
|
88
|
-
isFirstCompile,
|
|
89
|
-
time: stats.endTime - stats.startTime,
|
|
90
|
-
});
|
|
91
|
-
isFirstCompile = false;
|
|
81
|
+
compiler.hooks.done.tap('server', (_stats) => {
|
|
82
|
+
var _a;
|
|
83
|
+
stats = _stats;
|
|
84
|
+
sendStats(getStats(stats));
|
|
85
|
+
(_a = opts.onDevCompileDone) === null || _a === void 0 ? void 0 : _a.call(opts, {
|
|
86
|
+
stats,
|
|
87
|
+
isFirstCompile,
|
|
88
|
+
time: stats.endTime - stats.startTime,
|
|
92
89
|
});
|
|
90
|
+
isFirstCompile = false;
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function sendStats(stats, force, sender) {
|
|
94
|
+
const shouldEmit = !force &&
|
|
95
|
+
stats &&
|
|
96
|
+
(!stats.errors || stats.errors.length === 0) &&
|
|
97
|
+
(!stats.warnings || stats.warnings.length === 0) &&
|
|
98
|
+
stats.assets &&
|
|
99
|
+
stats.assets.every((asset) => !asset.emitted);
|
|
100
|
+
if (shouldEmit) {
|
|
101
|
+
sendMessage(constants_1.MESSAGE_TYPE.stillOk, null, sender);
|
|
102
|
+
return;
|
|
93
103
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
(
|
|
99
|
-
stats.assets &&
|
|
100
|
-
stats.assets.every((asset) => !asset.emitted);
|
|
101
|
-
if (shouldEmit) {
|
|
102
|
-
sendMessage(constants_1.MESSAGE_TYPE.stillOk, null, sender);
|
|
103
|
-
return;
|
|
104
|
+
sendMessage(constants_1.MESSAGE_TYPE.hash, stats.hash, sender);
|
|
105
|
+
if ((stats.errors && stats.errors.length > 0) ||
|
|
106
|
+
(stats.warnings && stats.warnings.length > 0)) {
|
|
107
|
+
if (stats.warnings && stats.warnings.length > 0) {
|
|
108
|
+
sendMessage(constants_1.MESSAGE_TYPE.warnings, stats.warnings, sender);
|
|
104
109
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
(stats.warnings && stats.warnings.length > 0)) {
|
|
108
|
-
if (stats.warnings && stats.warnings.length > 0) {
|
|
109
|
-
sendMessage(constants_1.MESSAGE_TYPE.warnings, stats.warnings, sender);
|
|
110
|
-
}
|
|
111
|
-
if (stats.errors && stats.errors.length > 0) {
|
|
112
|
-
sendMessage(constants_1.MESSAGE_TYPE.errors, stats.errors, sender);
|
|
113
|
-
}
|
|
110
|
+
if (stats.errors && stats.errors.length > 0) {
|
|
111
|
+
sendMessage(constants_1.MESSAGE_TYPE.errors, stats.errors, sender);
|
|
114
112
|
}
|
|
115
|
-
else {
|
|
116
|
-
sendMessage(constants_1.MESSAGE_TYPE.ok, null, sender);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
function getStats(stats) {
|
|
120
|
-
return stats.toJson({
|
|
121
|
-
all: false,
|
|
122
|
-
hash: true,
|
|
123
|
-
assets: true,
|
|
124
|
-
warnings: true,
|
|
125
|
-
errors: true,
|
|
126
|
-
errorDetails: false,
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
function sendMessage(type, data, sender) {
|
|
130
|
-
(sender || ws).send(JSON.stringify({ type, data }));
|
|
131
113
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (proxy) {
|
|
135
|
-
Object.keys(proxy).forEach((key) => {
|
|
136
|
-
const proxyConfig = proxy[key];
|
|
137
|
-
const target = proxyConfig.target;
|
|
138
|
-
if (target) {
|
|
139
|
-
app.use(key, (0, http_proxy_middleware_1.createProxyMiddleware)(key, Object.assign(Object.assign({}, proxy[key]), {
|
|
140
|
-
// Add x-real-url in response header
|
|
141
|
-
onProxyRes(proxyRes, req) {
|
|
142
|
-
var _a;
|
|
143
|
-
proxyRes.headers['x-real-url'] =
|
|
144
|
-
((_a = new URL(req.url || '', target)) === null || _a === void 0 ? void 0 : _a.href) || '';
|
|
145
|
-
} })));
|
|
146
|
-
}
|
|
147
|
-
});
|
|
114
|
+
else {
|
|
115
|
+
sendMessage(constants_1.MESSAGE_TYPE.ok, null, sender);
|
|
148
116
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
// hmr reconnect ping
|
|
159
|
-
app.use('/__umi_ping', (_, res) => {
|
|
160
|
-
res.end('pong');
|
|
117
|
+
}
|
|
118
|
+
function getStats(stats) {
|
|
119
|
+
return stats.toJson({
|
|
120
|
+
all: false,
|
|
121
|
+
hash: true,
|
|
122
|
+
assets: true,
|
|
123
|
+
warnings: true,
|
|
124
|
+
errors: true,
|
|
125
|
+
errorDetails: false,
|
|
161
126
|
});
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
127
|
+
}
|
|
128
|
+
function sendMessage(type, data, sender) {
|
|
129
|
+
(sender || ws).send(JSON.stringify({ type, data }));
|
|
130
|
+
}
|
|
131
|
+
// mock
|
|
132
|
+
// proxy
|
|
133
|
+
if (proxy) {
|
|
134
|
+
Object.keys(proxy).forEach((key) => {
|
|
135
|
+
const proxyConfig = proxy[key];
|
|
136
|
+
const target = proxyConfig.target;
|
|
137
|
+
if (target) {
|
|
138
|
+
app.use(key, (0, http_proxy_middleware_1.createProxyMiddleware)(key, {
|
|
139
|
+
...proxy[key],
|
|
140
|
+
// Add x-real-url in response header
|
|
141
|
+
onProxyRes(proxyRes, req) {
|
|
142
|
+
var _a;
|
|
143
|
+
proxyRes.headers['x-real-url'] =
|
|
144
|
+
((_a = new URL(req.url || '', target)) === null || _a === void 0 ? void 0 : _a.href) || '';
|
|
145
|
+
},
|
|
146
|
+
}));
|
|
169
147
|
}
|
|
170
|
-
else {
|
|
171
|
-
next();
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
const server = http_1.default.createServer(app);
|
|
175
|
-
const ws = (0, ws_1.createWebSocketServer)(server);
|
|
176
|
-
ws.wss.on('connection', (socket) => {
|
|
177
|
-
if (stats) {
|
|
178
|
-
sendStats(getStats(stats), false, socket);
|
|
179
|
-
}
|
|
180
|
-
});
|
|
181
|
-
const port = opts.port || 8000;
|
|
182
|
-
server.listen(port, () => {
|
|
183
|
-
const host = opts.host && opts.host !== '0.0.0.0' ? opts.host : '127.0.0.1';
|
|
184
|
-
utils_1.logger.ready(`App listening at ${utils_1.chalk.green(`http://${host}:${port}`)}`);
|
|
185
148
|
});
|
|
186
|
-
|
|
149
|
+
}
|
|
150
|
+
// after middlewares
|
|
151
|
+
(opts.afterMiddlewares || []).forEach((m) => {
|
|
152
|
+
// TODO: FIXME
|
|
153
|
+
app.use(m.toString().includes(`{ compiler }`) ? m({ compiler }) : m);
|
|
154
|
+
});
|
|
155
|
+
// history fallback
|
|
156
|
+
app.use(require('@umijs/bundler-webpack/compiled/connect-history-api-fallback')({
|
|
157
|
+
index: '/',
|
|
158
|
+
}));
|
|
159
|
+
// hmr reconnect ping
|
|
160
|
+
app.use('/__umi_ping', (_, res) => {
|
|
161
|
+
res.end('pong');
|
|
162
|
+
});
|
|
163
|
+
// index.html
|
|
164
|
+
// TODO: remove me
|
|
165
|
+
app.get('/', (_req, res, next) => {
|
|
166
|
+
res.set('Content-Type', 'text/html');
|
|
167
|
+
const htmlPath = (0, path_1.join)(opts.cwd, 'index.html');
|
|
168
|
+
if ((0, fs_1.existsSync)(htmlPath)) {
|
|
169
|
+
(0, fs_1.createReadStream)(htmlPath).on('error', next).pipe(res);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
next();
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
const server = userConfig.https
|
|
176
|
+
? await (0, bundler_utils_1.createHttpsServer)(app, userConfig.https)
|
|
177
|
+
: http_1.default.createServer(app);
|
|
178
|
+
if (!server) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
181
|
+
const ws = (0, ws_1.createWebSocketServer)(server);
|
|
182
|
+
ws.wss.on('connection', (socket) => {
|
|
183
|
+
if (stats) {
|
|
184
|
+
sendStats(getStats(stats), false, socket);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
const protocol = userConfig.https ? 'https:' : 'http:';
|
|
188
|
+
const port = opts.port || 8000;
|
|
189
|
+
server.listen(port, () => {
|
|
190
|
+
const host = opts.host && opts.host !== '0.0.0.0' ? opts.host : '127.0.0.1';
|
|
191
|
+
utils_1.logger.ready(`App listening at ${utils_1.chalk.green(`${protocol}//${host}:${port}`)}`);
|
|
187
192
|
});
|
|
193
|
+
return server;
|
|
188
194
|
}
|
|
189
195
|
exports.createServer = createServer;
|
package/dist/server/ws.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import type { SpdyServer as Server } from '@umijs/bundler-utils';
|
|
5
|
+
import { Server as HttpServer } from 'http';
|
|
6
|
+
import { Http2Server } from 'http2';
|
|
7
|
+
import { Server as HttpsServer } from 'https';
|
|
3
8
|
import WebSocket from '../../compiled/ws';
|
|
4
|
-
export declare function createWebSocketServer(server: Server): {
|
|
9
|
+
export declare function createWebSocketServer(server: HttpServer | HttpsServer | Http2Server | Server): {
|
|
5
10
|
send(message: string): void;
|
|
6
11
|
wss: WebSocket.Server;
|
|
7
12
|
close(): void;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Config as SwcConfig } from '@swc/core';
|
|
2
|
+
import type { HttpsServerOptions } from '@umijs/bundler-utils';
|
|
2
3
|
import type { Options as ProxyOptions } from '../compiled/http-proxy-middleware';
|
|
3
4
|
import { Configuration } from '../compiled/webpack';
|
|
4
5
|
import Config from '../compiled/webpack-5-chain';
|
|
@@ -63,12 +64,14 @@ export interface IConfig {
|
|
|
63
64
|
depTranspiler?: Transpiler;
|
|
64
65
|
devtool?: Config.DevTool;
|
|
65
66
|
deadCode?: DeadCodeParams;
|
|
67
|
+
https?: HttpsServerOptions;
|
|
66
68
|
externals?: WebpackConfig['externals'];
|
|
67
69
|
esm?: {
|
|
68
70
|
[key: string]: any;
|
|
69
71
|
};
|
|
70
72
|
extraBabelPlugins?: IBabelPlugin[];
|
|
71
73
|
extraBabelPresets?: IBabelPlugin[];
|
|
74
|
+
extraBabelIncludes?: string[];
|
|
72
75
|
extraPostCSSPlugins?: any[];
|
|
73
76
|
hash?: boolean;
|
|
74
77
|
ignoreMomentLocale?: boolean;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEsBuildTarget = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
function getEsBuildTarget({ targets }) {
|
|
6
|
+
return Object.keys(targets)
|
|
7
|
+
.filter((key) => constants_1.DEFAULT_ESBUILD_TARGET_KEYS.includes(key))
|
|
8
|
+
.map((key) => {
|
|
9
|
+
return `${key}${targets[key] === true ? '0' : targets[key]}`;
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
exports.getEsBuildTarget = getEsBuildTarget;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-webpack",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.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",
|
|
@@ -23,31 +23,34 @@
|
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "pnpm tsc",
|
|
25
25
|
"build:client": "pnpm tsc --project ./tsconfig.client.json",
|
|
26
|
-
"build:deps": "
|
|
27
|
-
"dev": "pnpm build --
|
|
26
|
+
"build:deps": "umi-scripts bundleDeps",
|
|
27
|
+
"dev": "pnpm build --watch",
|
|
28
28
|
"generate:webpackPackages": "zx ./scripts/generateWebpackPackages.mjs",
|
|
29
|
-
"test": "
|
|
29
|
+
"test": "umi-scripts jest-turbo"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@parcel/css": "1.
|
|
33
|
-
"@pmmmwh/react-refresh-webpack-plugin": "0.5.
|
|
32
|
+
"@parcel/css": "1.9.0",
|
|
33
|
+
"@pmmmwh/react-refresh-webpack-plugin": "0.5.7",
|
|
34
34
|
"@svgr/core": "6.2.1",
|
|
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.
|
|
39
|
-
"@umijs/
|
|
40
|
-
"@umijs/
|
|
38
|
+
"@umijs/babel-preset-umi": "4.0.2",
|
|
39
|
+
"@umijs/bundler-utils": "4.0.2",
|
|
40
|
+
"@umijs/mfsu": "4.0.2",
|
|
41
|
+
"@umijs/utils": "4.0.2",
|
|
42
|
+
"cors": "^2.8.5",
|
|
41
43
|
"css-loader": "6.7.1",
|
|
42
44
|
"es5-imcompatible-versions": "^0.1.73",
|
|
43
45
|
"jest-worker": "27.5.1",
|
|
44
46
|
"node-libs-browser": "2.2.1",
|
|
45
|
-
"postcss": "^8.4.
|
|
46
|
-
"postcss-preset-env": "7.
|
|
47
|
+
"postcss": "^8.4.13",
|
|
48
|
+
"postcss-preset-env": "7.5.0",
|
|
47
49
|
"react-error-overlay": "6.0.9"
|
|
48
50
|
},
|
|
49
51
|
"devDependencies": {
|
|
50
|
-
"@swc/core": "1.2.
|
|
52
|
+
"@swc/core": "1.2.165",
|
|
53
|
+
"@types/cors": "^2.8.12",
|
|
51
54
|
"@types/webpack-sources": "3.2.0",
|
|
52
55
|
"@types/ws": "8.5.3",
|
|
53
56
|
"autoprefixer": "10.4.4",
|
|
@@ -55,29 +58,28 @@
|
|
|
55
58
|
"compression": "1.7.4",
|
|
56
59
|
"connect-history-api-fallback": "1.6.0",
|
|
57
60
|
"copy-webpack-plugin": "10.2.4",
|
|
58
|
-
"css-minimizer-webpack-plugin": "
|
|
59
|
-
"cssnano": "5.1.
|
|
60
|
-
"fork-ts-checker-webpack-plugin": "7.2.
|
|
61
|
+
"css-minimizer-webpack-plugin": "4.0.0",
|
|
62
|
+
"cssnano": "5.1.7",
|
|
63
|
+
"fork-ts-checker-webpack-plugin": "7.2.4",
|
|
61
64
|
"http-proxy-middleware": "2.0.4",
|
|
62
65
|
"less-loader": "10.2.0",
|
|
63
66
|
"mini-css-extract-plugin": "2.6.0",
|
|
64
67
|
"postcss-flexbugs-fixes": "5.0.2",
|
|
65
68
|
"postcss-loader": "6.2.1",
|
|
66
69
|
"purgecss-webpack-plugin": "4.1.3",
|
|
67
|
-
"react-refresh": "0.
|
|
70
|
+
"react-refresh": "0.12.0",
|
|
68
71
|
"sass-loader": "12.6.0",
|
|
69
72
|
"schema-utils": "4.0.0",
|
|
70
73
|
"speed-measure-webpack-plugin": "1.5.0",
|
|
71
74
|
"style-loader": "3.3.1",
|
|
72
75
|
"svgo-loader": "3.0.0",
|
|
73
|
-
"tapable": "2.2.1",
|
|
74
76
|
"terser": "5.12.1",
|
|
75
77
|
"terser-webpack-plugin": "5.3.1",
|
|
76
78
|
"url-loader": "4.1.1",
|
|
77
|
-
"webpack": "5.
|
|
79
|
+
"webpack": "5.72.1",
|
|
78
80
|
"webpack-5-chain": "8.0.0",
|
|
79
81
|
"webpack-bundle-analyzer": "4.5.0",
|
|
80
|
-
"webpack-dev-middleware": "5.3.
|
|
82
|
+
"webpack-dev-middleware": "5.3.3",
|
|
81
83
|
"webpack-manifest-plugin": "5.0.0",
|
|
82
84
|
"webpack-sources": "3.2.3",
|
|
83
85
|
"ws": "8.5.0"
|
|
@@ -110,7 +112,6 @@
|
|
|
110
112
|
"style-loader",
|
|
111
113
|
"speed-measure-webpack-plugin",
|
|
112
114
|
"svgo-loader",
|
|
113
|
-
"tapable",
|
|
114
115
|
"terser",
|
|
115
116
|
"terser-webpack-plugin",
|
|
116
117
|
"url-loader",
|
|
@@ -133,7 +134,7 @@
|
|
|
133
134
|
"less": "@umijs/bundler-utils/compiled/less",
|
|
134
135
|
"cssnano": "$$LOCAL",
|
|
135
136
|
"postcss": "postcss",
|
|
136
|
-
"tapable": "
|
|
137
|
+
"tapable": "@umijs/bundler-utils/compiled/tapable",
|
|
137
138
|
"terser": "$$LOCAL",
|
|
138
139
|
"terser-webpack-plugin": "$$LOCAL",
|
|
139
140
|
"typescript": "typescript",
|
|
@@ -174,6 +175,7 @@
|
|
|
174
175
|
"postcss-flexbugs-fixes",
|
|
175
176
|
"postcss-loader",
|
|
176
177
|
"purgecss-webpack-plugin",
|
|
178
|
+
"react-refresh",
|
|
177
179
|
"sass-loader",
|
|
178
180
|
"speed-measure-webpack-plugin",
|
|
179
181
|
"style-loader",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(){"use strict";var e={131:function(e,t,n){const o=n(246);const r=n(431);class AsyncParallelBailHookCodeFactory extends r{content({onError:e,onResult:t,onDone:n}){let o="";o+=`var _results = new Array(${this.options.taps.length});\n`;o+="var _checkDone = function() {\n";o+="for(var i = 0; i < _results.length; i++) {\n";o+="var item = _results[i];\n";o+="if(item === undefined) return false;\n";o+="if(item.result !== undefined) {\n";o+=t("item.result");o+="return true;\n";o+="}\n";o+="if(item.error) {\n";o+=e("item.error");o+="return true;\n";o+="}\n";o+="}\n";o+="return false;\n";o+="}\n";o+=this.callTapsParallel({onError:(e,t,n,o)=>{let r="";r+=`if(${e} < _results.length && ((_results.length = ${e+1}), (_results[${e}] = { error: ${t} }), _checkDone())) {\n`;r+=o(true);r+="} else {\n";r+=n();r+="}\n";return r},onResult:(e,t,n,o)=>{let r="";r+=`if(${e} < _results.length && (${t} !== undefined && (_results.length = ${e+1}), (_results[${e}] = { result: ${t} }), _checkDone())) {\n`;r+=o(true);r+="} else {\n";r+=n();r+="}\n";return r},onTap:(e,t,n,o)=>{let r="";if(e>0){r+=`if(${e} >= _results.length) {\n`;r+=n();r+="} else {\n"}r+=t();if(e>0)r+="}\n";return r},onDone:n});return o}}const s=new AsyncParallelBailHookCodeFactory;const COMPILE=function(e){s.setup(this,e);return s.create(e)};function AsyncParallelBailHook(e=[],t=undefined){const n=new o(e,t);n.constructor=AsyncParallelBailHook;n.compile=COMPILE;n._call=undefined;n.call=undefined;return n}AsyncParallelBailHook.prototype=null;e.exports=AsyncParallelBailHook},834:function(e,t,n){const o=n(246);const r=n(431);class AsyncParallelHookCodeFactory extends r{content({onError:e,onDone:t}){return this.callTapsParallel({onError:(t,n,o,r)=>e(n)+r(true),onDone:t})}}const s=new AsyncParallelHookCodeFactory;const COMPILE=function(e){s.setup(this,e);return s.create(e)};function AsyncParallelHook(e=[],t=undefined){const n=new o(e,t);n.constructor=AsyncParallelHook;n.compile=COMPILE;n._call=undefined;n.call=undefined;return n}AsyncParallelHook.prototype=null;e.exports=AsyncParallelHook},179:function(e,t,n){const o=n(246);const r=n(431);class AsyncSeriesBailHookCodeFactory extends r{content({onError:e,onResult:t,resultReturns:n,onDone:o}){return this.callTapsSeries({onError:(t,n,o,r)=>e(n)+r(true),onResult:(e,n,o)=>`if(${n} !== undefined) {\n${t(n)}\n} else {\n${o()}}\n`,resultReturns:n,onDone:o})}}const s=new AsyncSeriesBailHookCodeFactory;const COMPILE=function(e){s.setup(this,e);return s.create(e)};function AsyncSeriesBailHook(e=[],t=undefined){const n=new o(e,t);n.constructor=AsyncSeriesBailHook;n.compile=COMPILE;n._call=undefined;n.call=undefined;return n}AsyncSeriesBailHook.prototype=null;e.exports=AsyncSeriesBailHook},1:function(e,t,n){const o=n(246);const r=n(431);class AsyncSeriesHookCodeFactory extends r{content({onError:e,onDone:t}){return this.callTapsSeries({onError:(t,n,o,r)=>e(n)+r(true),onDone:t})}}const s=new AsyncSeriesHookCodeFactory;const COMPILE=function(e){s.setup(this,e);return s.create(e)};function AsyncSeriesHook(e=[],t=undefined){const n=new o(e,t);n.constructor=AsyncSeriesHook;n.compile=COMPILE;n._call=undefined;n.call=undefined;return n}AsyncSeriesHook.prototype=null;e.exports=AsyncSeriesHook},843:function(e,t,n){const o=n(246);const r=n(431);class AsyncSeriesLoopHookCodeFactory extends r{content({onError:e,onDone:t}){return this.callTapsLooping({onError:(t,n,o,r)=>e(n)+r(true),onDone:t})}}const s=new AsyncSeriesLoopHookCodeFactory;const COMPILE=function(e){s.setup(this,e);return s.create(e)};function AsyncSeriesLoopHook(e=[],t=undefined){const n=new o(e,t);n.constructor=AsyncSeriesLoopHook;n.compile=COMPILE;n._call=undefined;n.call=undefined;return n}AsyncSeriesLoopHook.prototype=null;e.exports=AsyncSeriesLoopHook},371:function(e,t,n){const o=n(246);const r=n(431);class AsyncSeriesWaterfallHookCodeFactory extends r{content({onError:e,onResult:t,onDone:n}){return this.callTapsSeries({onError:(t,n,o,r)=>e(n)+r(true),onResult:(e,t,n)=>{let o="";o+=`if(${t} !== undefined) {\n`;o+=`${this._args[0]} = ${t};\n`;o+=`}\n`;o+=n();return o},onDone:()=>t(this._args[0])})}}const s=new AsyncSeriesWaterfallHookCodeFactory;const COMPILE=function(e){s.setup(this,e);return s.create(e)};function AsyncSeriesWaterfallHook(e=[],t=undefined){if(e.length<1)throw new Error("Waterfall hooks must have at least one argument");const n=new o(e,t);n.constructor=AsyncSeriesWaterfallHook;n.compile=COMPILE;n._call=undefined;n.call=undefined;return n}AsyncSeriesWaterfallHook.prototype=null;e.exports=AsyncSeriesWaterfallHook},246:function(e,t,n){const o=n(669);const r=o.deprecate((()=>{}),"Hook.context is deprecated and will be removed");const CALL_DELEGATE=function(...e){this.call=this._createCall("sync");return this.call(...e)};const CALL_ASYNC_DELEGATE=function(...e){this.callAsync=this._createCall("async");return this.callAsync(...e)};const PROMISE_DELEGATE=function(...e){this.promise=this._createCall("promise");return this.promise(...e)};class Hook{constructor(e=[],t=undefined){this._args=e;this.name=t;this.taps=[];this.interceptors=[];this._call=CALL_DELEGATE;this.call=CALL_DELEGATE;this._callAsync=CALL_ASYNC_DELEGATE;this.callAsync=CALL_ASYNC_DELEGATE;this._promise=PROMISE_DELEGATE;this.promise=PROMISE_DELEGATE;this._x=undefined;this.compile=this.compile;this.tap=this.tap;this.tapAsync=this.tapAsync;this.tapPromise=this.tapPromise}compile(e){throw new Error("Abstract: should be overridden")}_createCall(e){return this.compile({taps:this.taps,interceptors:this.interceptors,args:this._args,type:e})}_tap(e,t,n){if(typeof t==="string"){t={name:t.trim()}}else if(typeof t!=="object"||t===null){throw new Error("Invalid tap options")}if(typeof t.name!=="string"||t.name===""){throw new Error("Missing name for tap")}if(typeof t.context!=="undefined"){r()}t=Object.assign({type:e,fn:n},t);t=this._runRegisterInterceptors(t);this._insert(t)}tap(e,t){this._tap("sync",e,t)}tapAsync(e,t){this._tap("async",e,t)}tapPromise(e,t){this._tap("promise",e,t)}_runRegisterInterceptors(e){for(const t of this.interceptors){if(t.register){const n=t.register(e);if(n!==undefined){e=n}}}return e}withOptions(e){const mergeOptions=t=>Object.assign({},e,typeof t==="string"?{name:t}:t);return{name:this.name,tap:(e,t)=>this.tap(mergeOptions(e),t),tapAsync:(e,t)=>this.tapAsync(mergeOptions(e),t),tapPromise:(e,t)=>this.tapPromise(mergeOptions(e),t),intercept:e=>this.intercept(e),isUsed:()=>this.isUsed(),withOptions:e=>this.withOptions(mergeOptions(e))}}isUsed(){return this.taps.length>0||this.interceptors.length>0}intercept(e){this._resetCompilation();this.interceptors.push(Object.assign({},e));if(e.register){for(let t=0;t<this.taps.length;t++){this.taps[t]=e.register(this.taps[t])}}}_resetCompilation(){this.call=this._call;this.callAsync=this._callAsync;this.promise=this._promise}_insert(e){this._resetCompilation();let t;if(typeof e.before==="string"){t=new Set([e.before])}else if(Array.isArray(e.before)){t=new Set(e.before)}let n=0;if(typeof e.stage==="number"){n=e.stage}let o=this.taps.length;while(o>0){o--;const e=this.taps[o];this.taps[o+1]=e;const r=e.stage||0;if(t){if(t.has(e.name)){t.delete(e.name);continue}if(t.size>0){continue}}if(r>n){continue}o++;break}this.taps[o]=e}}Object.setPrototypeOf(Hook.prototype,null);e.exports=Hook},431:function(e){class HookCodeFactory{constructor(e){this.config=e;this.options=undefined;this._args=undefined}create(e){this.init(e);let t;switch(this.options.type){case"sync":t=new Function(this.args(),'"use strict";\n'+this.header()+this.contentWithInterceptors({onError:e=>`throw ${e};\n`,onResult:e=>`return ${e};\n`,resultReturns:true,onDone:()=>"",rethrowIfPossible:true}));break;case"async":t=new Function(this.args({after:"_callback"}),'"use strict";\n'+this.header()+this.contentWithInterceptors({onError:e=>`_callback(${e});\n`,onResult:e=>`_callback(null, ${e});\n`,onDone:()=>"_callback();\n"}));break;case"promise":let e=false;const n=this.contentWithInterceptors({onError:t=>{e=true;return`_error(${t});\n`},onResult:e=>`_resolve(${e});\n`,onDone:()=>"_resolve();\n"});let o="";o+='"use strict";\n';o+=this.header();o+="return new Promise((function(_resolve, _reject) {\n";if(e){o+="var _sync = true;\n";o+="function _error(_err) {\n";o+="if(_sync)\n";o+="_resolve(Promise.resolve().then((function() { throw _err; })));\n";o+="else\n";o+="_reject(_err);\n";o+="};\n"}o+=n;if(e){o+="_sync = false;\n"}o+="}));\n";t=new Function(this.args(),o);break}this.deinit();return t}setup(e,t){e._x=t.taps.map((e=>e.fn))}init(e){this.options=e;this._args=e.args.slice()}deinit(){this.options=undefined;this._args=undefined}contentWithInterceptors(e){if(this.options.interceptors.length>0){const t=e.onError;const n=e.onResult;const o=e.onDone;let r="";for(let e=0;e<this.options.interceptors.length;e++){const t=this.options.interceptors[e];if(t.call){r+=`${this.getInterceptor(e)}.call(${this.args({before:t.context?"_context":undefined})});\n`}}r+=this.content(Object.assign(e,{onError:t&&(e=>{let n="";for(let t=0;t<this.options.interceptors.length;t++){const o=this.options.interceptors[t];if(o.error){n+=`${this.getInterceptor(t)}.error(${e});\n`}}n+=t(e);return n}),onResult:n&&(e=>{let t="";for(let n=0;n<this.options.interceptors.length;n++){const o=this.options.interceptors[n];if(o.result){t+=`${this.getInterceptor(n)}.result(${e});\n`}}t+=n(e);return t}),onDone:o&&(()=>{let e="";for(let t=0;t<this.options.interceptors.length;t++){const n=this.options.interceptors[t];if(n.done){e+=`${this.getInterceptor(t)}.done();\n`}}e+=o();return e})}));return r}else{return this.content(e)}}header(){let e="";if(this.needContext()){e+="var _context = {};\n"}else{e+="var _context;\n"}e+="var _x = this._x;\n";if(this.options.interceptors.length>0){e+="var _taps = this.taps;\n";e+="var _interceptors = this.interceptors;\n"}return e}needContext(){for(const e of this.options.taps)if(e.context)return true;return false}callTap(e,{onError:t,onResult:n,onDone:o,rethrowIfPossible:r}){let s="";let i=false;for(let t=0;t<this.options.interceptors.length;t++){const n=this.options.interceptors[t];if(n.tap){if(!i){s+=`var _tap${e} = ${this.getTap(e)};\n`;i=true}s+=`${this.getInterceptor(t)}.tap(${n.context?"_context, ":""}_tap${e});\n`}}s+=`var _fn${e} = ${this.getTapFn(e)};\n`;const c=this.options.taps[e];switch(c.type){case"sync":if(!r){s+=`var _hasError${e} = false;\n`;s+="try {\n"}if(n){s+=`var _result${e} = _fn${e}(${this.args({before:c.context?"_context":undefined})});\n`}else{s+=`_fn${e}(${this.args({before:c.context?"_context":undefined})});\n`}if(!r){s+="} catch(_err) {\n";s+=`_hasError${e} = true;\n`;s+=t("_err");s+="}\n";s+=`if(!_hasError${e}) {\n`}if(n){s+=n(`_result${e}`)}if(o){s+=o()}if(!r){s+="}\n"}break;case"async":let i="";if(n)i+=`(function(_err${e}, _result${e}) {\n`;else i+=`(function(_err${e}) {\n`;i+=`if(_err${e}) {\n`;i+=t(`_err${e}`);i+="} else {\n";if(n){i+=n(`_result${e}`)}if(o){i+=o()}i+="}\n";i+="})";s+=`_fn${e}(${this.args({before:c.context?"_context":undefined,after:i})});\n`;break;case"promise":s+=`var _hasResult${e} = false;\n`;s+=`var _promise${e} = _fn${e}(${this.args({before:c.context?"_context":undefined})});\n`;s+=`if (!_promise${e} || !_promise${e}.then)\n`;s+=` throw new Error('Tap function (tapPromise) did not return promise (returned ' + _promise${e} + ')');\n`;s+=`_promise${e}.then((function(_result${e}) {\n`;s+=`_hasResult${e} = true;\n`;if(n){s+=n(`_result${e}`)}if(o){s+=o()}s+=`}), function(_err${e}) {\n`;s+=`if(_hasResult${e}) throw _err${e};\n`;s+=t(`_err${e}`);s+="});\n";break}return s}callTapsSeries({onError:e,onResult:t,resultReturns:n,onDone:o,doneReturns:r,rethrowIfPossible:s}){if(this.options.taps.length===0)return o();const i=this.options.taps.findIndex((e=>e.type!=="sync"));const c=n||r;let a="";let l=o;let p=0;for(let n=this.options.taps.length-1;n>=0;n--){const r=n;const u=l!==o&&(this.options.taps[r].type!=="sync"||p++>20);if(u){p=0;a+=`function _next${r}() {\n`;a+=l();a+=`}\n`;l=()=>`${c?"return ":""}_next${r}();\n`}const f=l;const doneBreak=e=>{if(e)return"";return o()};const h=this.callTap(r,{onError:t=>e(r,t,f,doneBreak),onResult:t&&(e=>t(r,e,f,doneBreak)),onDone:!t&&f,rethrowIfPossible:s&&(i<0||r<i)});l=()=>h}a+=l();return a}callTapsLooping({onError:e,onDone:t,rethrowIfPossible:n}){if(this.options.taps.length===0)return t();const o=this.options.taps.every((e=>e.type==="sync"));let r="";if(!o){r+="var _looper = (function() {\n";r+="var _loopAsync = false;\n"}r+="var _loop;\n";r+="do {\n";r+="_loop = false;\n";for(let e=0;e<this.options.interceptors.length;e++){const t=this.options.interceptors[e];if(t.loop){r+=`${this.getInterceptor(e)}.loop(${this.args({before:t.context?"_context":undefined})});\n`}}r+=this.callTapsSeries({onError:e,onResult:(e,t,n,r)=>{let s="";s+=`if(${t} !== undefined) {\n`;s+="_loop = true;\n";if(!o)s+="if(_loopAsync) _looper();\n";s+=r(true);s+=`} else {\n`;s+=n();s+=`}\n`;return s},onDone:t&&(()=>{let e="";e+="if(!_loop) {\n";e+=t();e+="}\n";return e}),rethrowIfPossible:n&&o});r+="} while(_loop);\n";if(!o){r+="_loopAsync = true;\n";r+="});\n";r+="_looper();\n"}return r}callTapsParallel({onError:e,onResult:t,onDone:n,rethrowIfPossible:o,onTap:r=((e,t)=>t())}){if(this.options.taps.length<=1){return this.callTapsSeries({onError:e,onResult:t,onDone:n,rethrowIfPossible:o})}let s="";s+="do {\n";s+=`var _counter = ${this.options.taps.length};\n`;if(n){s+="var _done = (function() {\n";s+=n();s+="});\n"}for(let i=0;i<this.options.taps.length;i++){const done=()=>{if(n)return"if(--_counter === 0) _done();\n";else return"--_counter;"};const doneBreak=e=>{if(e||!n)return"_counter = 0;\n";else return"_counter = 0;\n_done();\n"};s+="if(_counter <= 0) break;\n";s+=r(i,(()=>this.callTap(i,{onError:t=>{let n="";n+="if(_counter > 0) {\n";n+=e(i,t,done,doneBreak);n+="}\n";return n},onResult:t&&(e=>{let n="";n+="if(_counter > 0) {\n";n+=t(i,e,done,doneBreak);n+="}\n";return n}),onDone:!t&&(()=>done()),rethrowIfPossible:o})),done,doneBreak)}s+="} while(false);\n";return s}args({before:e,after:t}={}){let n=this._args;if(e)n=[e].concat(n);if(t)n=n.concat(t);if(n.length===0){return""}else{return n.join(", ")}}getTapFn(e){return`_x[${e}]`}getTap(e){return`_taps[${e}]`}getInterceptor(e){return`_interceptors[${e}]`}}e.exports=HookCodeFactory},278:function(e,t,n){const o=n(669);const defaultFactory=(e,t)=>t;class HookMap{constructor(e,t=undefined){this._map=new Map;this.name=t;this._factory=e;this._interceptors=[]}get(e){return this._map.get(e)}for(e){const t=this.get(e);if(t!==undefined){return t}let n=this._factory(e);const o=this._interceptors;for(let t=0;t<o.length;t++){n=o[t].factory(e,n)}this._map.set(e,n);return n}intercept(e){this._interceptors.push(Object.assign({factory:defaultFactory},e))}}HookMap.prototype.tap=o.deprecate((function(e,t,n){return this.for(e).tap(t,n)}),"HookMap#tap(key,…) is deprecated. Use HookMap#for(key).tap(…) instead.");HookMap.prototype.tapAsync=o.deprecate((function(e,t,n){return this.for(e).tapAsync(t,n)}),"HookMap#tapAsync(key,…) is deprecated. Use HookMap#for(key).tapAsync(…) instead.");HookMap.prototype.tapPromise=o.deprecate((function(e,t,n){return this.for(e).tapPromise(t,n)}),"HookMap#tapPromise(key,…) is deprecated. Use HookMap#for(key).tapPromise(…) instead.");e.exports=HookMap},310:function(e,t,n){const o=n(246);class MultiHook{constructor(e,t=undefined){this.hooks=e;this.name=t}tap(e,t){for(const n of this.hooks){n.tap(e,t)}}tapAsync(e,t){for(const n of this.hooks){n.tapAsync(e,t)}}tapPromise(e,t){for(const n of this.hooks){n.tapPromise(e,t)}}isUsed(){for(const e of this.hooks){if(e.isUsed())return true}return false}intercept(e){for(const t of this.hooks){t.intercept(e)}}withOptions(e){return new MultiHook(this.hooks.map((t=>t.withOptions(e))),this.name)}}e.exports=MultiHook},487:function(e,t,n){const o=n(246);const r=n(431);class SyncBailHookCodeFactory extends r{content({onError:e,onResult:t,resultReturns:n,onDone:o,rethrowIfPossible:r}){return this.callTapsSeries({onError:(t,n)=>e(n),onResult:(e,n,o)=>`if(${n} !== undefined) {\n${t(n)};\n} else {\n${o()}}\n`,resultReturns:n,onDone:o,rethrowIfPossible:r})}}const s=new SyncBailHookCodeFactory;const TAP_ASYNC=()=>{throw new Error("tapAsync is not supported on a SyncBailHook")};const TAP_PROMISE=()=>{throw new Error("tapPromise is not supported on a SyncBailHook")};const COMPILE=function(e){s.setup(this,e);return s.create(e)};function SyncBailHook(e=[],t=undefined){const n=new o(e,t);n.constructor=SyncBailHook;n.tapAsync=TAP_ASYNC;n.tapPromise=TAP_PROMISE;n.compile=COMPILE;return n}SyncBailHook.prototype=null;e.exports=SyncBailHook},75:function(e,t,n){const o=n(246);const r=n(431);class SyncHookCodeFactory extends r{content({onError:e,onDone:t,rethrowIfPossible:n}){return this.callTapsSeries({onError:(t,n)=>e(n),onDone:t,rethrowIfPossible:n})}}const s=new SyncHookCodeFactory;const TAP_ASYNC=()=>{throw new Error("tapAsync is not supported on a SyncHook")};const TAP_PROMISE=()=>{throw new Error("tapPromise is not supported on a SyncHook")};const COMPILE=function(e){s.setup(this,e);return s.create(e)};function SyncHook(e=[],t=undefined){const n=new o(e,t);n.constructor=SyncHook;n.tapAsync=TAP_ASYNC;n.tapPromise=TAP_PROMISE;n.compile=COMPILE;return n}SyncHook.prototype=null;e.exports=SyncHook},667:function(e,t,n){const o=n(246);const r=n(431);class SyncLoopHookCodeFactory extends r{content({onError:e,onDone:t,rethrowIfPossible:n}){return this.callTapsLooping({onError:(t,n)=>e(n),onDone:t,rethrowIfPossible:n})}}const s=new SyncLoopHookCodeFactory;const TAP_ASYNC=()=>{throw new Error("tapAsync is not supported on a SyncLoopHook")};const TAP_PROMISE=()=>{throw new Error("tapPromise is not supported on a SyncLoopHook")};const COMPILE=function(e){s.setup(this,e);return s.create(e)};function SyncLoopHook(e=[],t=undefined){const n=new o(e,t);n.constructor=SyncLoopHook;n.tapAsync=TAP_ASYNC;n.tapPromise=TAP_PROMISE;n.compile=COMPILE;return n}SyncLoopHook.prototype=null;e.exports=SyncLoopHook},303:function(e,t,n){const o=n(246);const r=n(431);class SyncWaterfallHookCodeFactory extends r{content({onError:e,onResult:t,resultReturns:n,rethrowIfPossible:o}){return this.callTapsSeries({onError:(t,n)=>e(n),onResult:(e,t,n)=>{let o="";o+=`if(${t} !== undefined) {\n`;o+=`${this._args[0]} = ${t};\n`;o+=`}\n`;o+=n();return o},onDone:()=>t(this._args[0]),doneReturns:n,rethrowIfPossible:o})}}const s=new SyncWaterfallHookCodeFactory;const TAP_ASYNC=()=>{throw new Error("tapAsync is not supported on a SyncWaterfallHook")};const TAP_PROMISE=()=>{throw new Error("tapPromise is not supported on a SyncWaterfallHook")};const COMPILE=function(e){s.setup(this,e);return s.create(e)};function SyncWaterfallHook(e=[],t=undefined){if(e.length<1)throw new Error("Waterfall hooks must have at least one argument");const n=new o(e,t);n.constructor=SyncWaterfallHook;n.tapAsync=TAP_ASYNC;n.tapPromise=TAP_PROMISE;n.compile=COMPILE;return n}SyncWaterfallHook.prototype=null;e.exports=SyncWaterfallHook},669:function(e){e.exports=require("util")}};var t={};function __nccwpck_require__(n){var o=t[n];if(o!==undefined){return o.exports}var r=t[n]={exports:{}};var s=true;try{e[n](r,r.exports,__nccwpck_require__);s=false}finally{if(s)delete t[n]}return r.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var n={};!function(){var e=n;e.__esModule=true;e.SyncHook=__nccwpck_require__(75);e.SyncBailHook=__nccwpck_require__(487);e.SyncWaterfallHook=__nccwpck_require__(303);e.SyncLoopHook=__nccwpck_require__(667);e.AsyncParallelHook=__nccwpck_require__(834);e.AsyncParallelBailHook=__nccwpck_require__(131);e.AsyncSeriesHook=__nccwpck_require__(1);e.AsyncSeriesBailHook=__nccwpck_require__(179);e.AsyncSeriesLoopHook=__nccwpck_require__(843);e.AsyncSeriesWaterfallHook=__nccwpck_require__(371);e.HookMap=__nccwpck_require__(278);e.MultiHook=__nccwpck_require__(310)}();module.exports=n})();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"name":"tapable","author":"Tobias Koppers @sokra","license":"MIT","types":"./tapable.d.ts"}
|