@umijs/bundler-webpack 4.0.0-rc.2 → 4.0.0-rc.20
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/autoprefixer/browserslist/index.d.ts +2 -0
- package/compiled/autoprefixer/index.js +3 -3
- package/compiled/autoprefixer/postcss/lib/declaration.d.ts +1 -1
- package/compiled/autoprefixer/postcss/lib/node.d.ts +2 -2
- package/compiled/babel-loader/index.js +2 -2
- package/compiled/copy-webpack-plugin/{576.index.js → 939.index.js} +11 -11
- package/compiled/copy-webpack-plugin/index.js +12 -12
- package/compiled/css-minimizer-webpack-plugin/index.js +7 -7
- package/compiled/cssnano/index.js +6 -6
- package/compiled/cssnano/package.json +1 -1
- package/compiled/express.d.ts +2 -0
- package/compiled/fork-ts-checker-webpack-plugin/index.js +7 -13
- package/compiled/http-proxy-middleware/index.js +10 -10
- package/compiled/mini-css-extract-plugin/index.js +440 -401
- package/compiled/mini-css-extract-plugin/loader.js +3 -1
- package/compiled/mini-css-extract-plugin/utils.js +2 -0
- 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/terser/index.js +1 -1
- 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 +5760 -3275
- package/compiled/webpack/types.d.ts +606 -171
- package/compiled/webpack-manifest-plugin/index.js +1 -1
- package/dist/build.d.ts +1 -0
- package/dist/build.js +48 -57
- package/dist/cli.js +6 -15
- package/dist/client/client.js +57 -51
- package/dist/config/_sampleFeature.js +6 -17
- package/dist/config/assetRules.js +44 -55
- package/dist/config/bundleAnalyzerPlugin.js +12 -23
- package/dist/config/compressPlugin.js +89 -64
- package/dist/config/config.d.ts +2 -0
- package/dist/config/config.js +177 -179
- package/dist/config/copyPlugin.js +29 -40
- package/dist/config/cssRules.js +93 -83
- package/dist/config/definePlugin.js +11 -19
- package/dist/config/detectDeadCode.js +1 -1
- package/dist/config/detectDeadCodePlugin.js +21 -22
- 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 -138
- package/dist/config/manifestPlugin.js +10 -18
- package/dist/config/miniCSSExtractPlugin.js +12 -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/svgRules.js +44 -47
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +7 -1
- package/dist/dev.d.ts +4 -0
- package/dist/dev.js +115 -94
- package/dist/index.d.ts +4 -1
- package/dist/index.js +5 -1
- package/dist/loader/svgr.js +4 -13
- package/dist/loader/swc.js +9 -14
- package/dist/plugins/ProgressPlugin.js +2 -2
- package/dist/plugins/RuntimePublicPathPlugin.js +1 -1
- package/dist/schema.js +29 -13
- package/dist/server/server.d.ts +2 -1
- package/dist/server/server.js +164 -148
- package/dist/server/ws.d.ts +5 -2
- package/dist/swcPlugins/autoCSSModules.js +3 -1
- package/dist/swcPlugins/changeImportFromString.d.ts +2 -0
- package/dist/swcPlugins/changeImportFromString.js +10 -0
- package/dist/swcPlugins/lockCoreJS.d.ts +1 -1
- package/dist/swcPlugins/lockCoreJS.js +3 -2
- package/dist/types.d.ts +4 -0
- package/dist/types.js +1 -0
- package/dist/utils/getEsBuildTarget.d.ts +5 -0
- package/dist/utils/getEsBuildTarget.js +12 -0
- package/package.json +32 -34
- package/compiled/css-loader/LICENSE +0 -20
- package/compiled/css-loader/api.js +0 -102
- package/compiled/css-loader/getUrl.js +0 -29
- package/compiled/css-loader/index.js +0 -2
- package/compiled/css-loader/noSourceMaps.js +0 -5
- package/compiled/css-loader/package.json +0 -1
- package/compiled/css-loader/sourceMaps.js +0 -22
- package/compiled/express/LICENSE +0 -24
- package/compiled/express/body-parser/index.d.ts +0 -104
- package/compiled/express/connect/index.d.ts +0 -93
- package/compiled/express/express-serve-static-core/index.d.ts +0 -1252
- package/compiled/express/index.d.ts +0 -133
- package/compiled/express/index.js +0 -321
- package/compiled/express/mime/index.d.ts +0 -35
- package/compiled/express/package.json +0 -1
- package/compiled/express/qs/index.d.ts +0 -62
- package/compiled/express/range-parser/index.d.ts +0 -35
- package/compiled/express/serve-static/index.d.ts +0 -108
- package/compiled/less/index.js +0 -31
- package/compiled/less/package.json +0 -1
- 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 -65
package/dist/server/server.js
CHANGED
|
@@ -1,177 +1,193 @@
|
|
|
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;
|
|
16
|
-
const
|
|
7
|
+
const bundler_utils_1 = require("@umijs/bundler-utils");
|
|
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
|
-
|
|
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
|
+
if (req.path === '/umi.js' && (0, fs_1.existsSync)((0, path_1.join)(opts.cwd, 'umi.js'))) {
|
|
36
|
+
res.setHeader('Content-Type', 'application/javascript');
|
|
37
|
+
(0, fs_1.createReadStream)((0, path_1.join)(opts.cwd, 'umi.js')).on('error', next).pipe(res);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
47
40
|
next();
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
// webpack dev middleware
|
|
44
|
+
const configs = Array.isArray(webpackConfig)
|
|
45
|
+
? webpackConfig
|
|
46
|
+
: [webpackConfig];
|
|
47
|
+
const progresses = [];
|
|
48
|
+
if (opts.onProgress) {
|
|
49
|
+
configs.forEach((config) => {
|
|
50
|
+
const progress = {
|
|
51
|
+
percent: 0,
|
|
52
|
+
status: 'waiting',
|
|
53
|
+
};
|
|
54
|
+
progresses.push(progress);
|
|
55
|
+
config.plugins.push(new webpack_1.default.ProgressPlugin((percent, msg) => {
|
|
56
|
+
progress.percent = percent;
|
|
57
|
+
progress.status = msg;
|
|
58
|
+
opts.onProgress({ progresses });
|
|
59
|
+
}));
|
|
48
60
|
});
|
|
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 }
|
|
61
|
+
}
|
|
62
|
+
const compiler = (0, webpack_1.default)(configs);
|
|
63
|
+
const webpackDevMiddleware = require('@umijs/bundler-webpack/compiled/webpack-dev-middleware');
|
|
64
|
+
const compilerMiddleware = webpackDevMiddleware(compiler, {
|
|
65
|
+
publicPath: userConfig.publicPath || '/',
|
|
66
|
+
writeToDisk: userConfig.writeToDisk,
|
|
67
|
+
stats: 'none',
|
|
68
|
+
// watchOptions: { ignored }
|
|
69
|
+
});
|
|
70
|
+
app.use(compilerMiddleware);
|
|
71
|
+
// hmr hooks
|
|
72
|
+
let stats;
|
|
73
|
+
let isFirstCompile = true;
|
|
74
|
+
compiler.compilers.forEach(addHooks);
|
|
75
|
+
function addHooks(compiler) {
|
|
76
|
+
compiler.hooks.invalid.tap('server', () => {
|
|
77
|
+
sendMessage(constants_1.MESSAGE_TYPE.invalid);
|
|
72
78
|
});
|
|
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;
|
|
79
|
+
compiler.hooks.done.tap('server', (_stats) => {
|
|
80
|
+
var _a;
|
|
81
|
+
stats = _stats;
|
|
82
|
+
sendStats(getStats(stats));
|
|
83
|
+
(_a = opts.onDevCompileDone) === null || _a === void 0 ? void 0 : _a.call(opts, {
|
|
84
|
+
stats,
|
|
85
|
+
isFirstCompile,
|
|
86
|
+
time: stats.endTime - stats.startTime,
|
|
92
87
|
});
|
|
88
|
+
isFirstCompile = false;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function sendStats(stats, force, sender) {
|
|
92
|
+
const shouldEmit = !force &&
|
|
93
|
+
stats &&
|
|
94
|
+
(!stats.errors || stats.errors.length === 0) &&
|
|
95
|
+
(!stats.warnings || stats.warnings.length === 0) &&
|
|
96
|
+
stats.assets &&
|
|
97
|
+
stats.assets.every((asset) => !asset.emitted);
|
|
98
|
+
if (shouldEmit) {
|
|
99
|
+
sendMessage(constants_1.MESSAGE_TYPE.stillOk, null, sender);
|
|
100
|
+
return;
|
|
93
101
|
}
|
|
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;
|
|
102
|
+
sendMessage(constants_1.MESSAGE_TYPE.hash, stats.hash, sender);
|
|
103
|
+
if ((stats.errors && stats.errors.length > 0) ||
|
|
104
|
+
(stats.warnings && stats.warnings.length > 0)) {
|
|
105
|
+
if (stats.warnings && stats.warnings.length > 0) {
|
|
106
|
+
sendMessage(constants_1.MESSAGE_TYPE.warnings, stats.warnings, sender);
|
|
104
107
|
}
|
|
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
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
sendMessage(constants_1.MESSAGE_TYPE.ok, null, sender);
|
|
108
|
+
if (stats.errors && stats.errors.length > 0) {
|
|
109
|
+
sendMessage(constants_1.MESSAGE_TYPE.errors, stats.errors, sender);
|
|
117
110
|
}
|
|
118
111
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
all: false,
|
|
122
|
-
hash: true,
|
|
123
|
-
assets: true,
|
|
124
|
-
warnings: true,
|
|
125
|
-
errors: true,
|
|
126
|
-
errorDetails: false,
|
|
127
|
-
});
|
|
112
|
+
else {
|
|
113
|
+
sendMessage(constants_1.MESSAGE_TYPE.ok, null, sender);
|
|
128
114
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
// after middlewares
|
|
140
|
-
(opts.afterMiddlewares || []).forEach((m) => app.use(m));
|
|
141
|
-
// history fallback
|
|
142
|
-
app.use(require('@umijs/bundler-webpack/compiled/connect-history-api-fallback')({
|
|
143
|
-
index: '/',
|
|
144
|
-
}));
|
|
145
|
-
// hmr reconnect ping
|
|
146
|
-
app.use('/__umi_ping', (_, res) => {
|
|
147
|
-
res.end('pong');
|
|
148
|
-
});
|
|
149
|
-
// index.html
|
|
150
|
-
// TODO: remove me
|
|
151
|
-
app.get('/', (_req, res, next) => {
|
|
152
|
-
res.set('Content-Type', 'text/html');
|
|
153
|
-
const htmlPath = (0, path_1.join)(opts.cwd, 'index.html');
|
|
154
|
-
if ((0, fs_1.existsSync)(htmlPath)) {
|
|
155
|
-
const html = (0, fs_1.readFileSync)(htmlPath, 'utf-8');
|
|
156
|
-
res.send(html);
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
next();
|
|
160
|
-
}
|
|
115
|
+
}
|
|
116
|
+
function getStats(stats) {
|
|
117
|
+
return stats.toJson({
|
|
118
|
+
all: false,
|
|
119
|
+
hash: true,
|
|
120
|
+
assets: true,
|
|
121
|
+
warnings: true,
|
|
122
|
+
errors: true,
|
|
123
|
+
errorDetails: false,
|
|
161
124
|
});
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
ws.
|
|
165
|
-
|
|
166
|
-
|
|
125
|
+
}
|
|
126
|
+
function sendMessage(type, data, sender) {
|
|
127
|
+
(sender || ws).send(JSON.stringify({ type, data }));
|
|
128
|
+
}
|
|
129
|
+
// mock
|
|
130
|
+
// proxy
|
|
131
|
+
if (proxy) {
|
|
132
|
+
Object.keys(proxy).forEach((key) => {
|
|
133
|
+
const proxyConfig = proxy[key];
|
|
134
|
+
const target = proxyConfig.target;
|
|
135
|
+
if (target) {
|
|
136
|
+
app.use(key, (0, http_proxy_middleware_1.createProxyMiddleware)(key, {
|
|
137
|
+
...proxy[key],
|
|
138
|
+
// Add x-real-url in response header
|
|
139
|
+
onProxyRes(proxyRes, req) {
|
|
140
|
+
var _a;
|
|
141
|
+
proxyRes.headers['x-real-url'] =
|
|
142
|
+
((_a = new URL(req.url || '', target)) === null || _a === void 0 ? void 0 : _a.href) || '';
|
|
143
|
+
},
|
|
144
|
+
}));
|
|
167
145
|
}
|
|
168
146
|
});
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
});
|
|
174
|
-
|
|
147
|
+
}
|
|
148
|
+
// after middlewares
|
|
149
|
+
(opts.afterMiddlewares || []).forEach((m) => {
|
|
150
|
+
// TODO: FIXME
|
|
151
|
+
app.use(m.toString().includes(`{ compiler }`) ? m({ compiler }) : m);
|
|
152
|
+
});
|
|
153
|
+
// history fallback
|
|
154
|
+
app.use(require('@umijs/bundler-webpack/compiled/connect-history-api-fallback')({
|
|
155
|
+
index: '/',
|
|
156
|
+
}));
|
|
157
|
+
// hmr reconnect ping
|
|
158
|
+
app.use('/__umi_ping', (_, res) => {
|
|
159
|
+
res.end('pong');
|
|
160
|
+
});
|
|
161
|
+
// index.html
|
|
162
|
+
// TODO: remove me
|
|
163
|
+
app.get('/', (_req, res, next) => {
|
|
164
|
+
res.set('Content-Type', 'text/html');
|
|
165
|
+
const htmlPath = (0, path_1.join)(opts.cwd, 'index.html');
|
|
166
|
+
if ((0, fs_1.existsSync)(htmlPath)) {
|
|
167
|
+
(0, fs_1.createReadStream)(htmlPath).on('error', next).pipe(res);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
next();
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
const server = userConfig.https
|
|
174
|
+
? await (0, bundler_utils_1.createHttpsServer)(app, userConfig.https)
|
|
175
|
+
: http_1.default.createServer(app);
|
|
176
|
+
if (!server) {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
const ws = (0, ws_1.createWebSocketServer)(server);
|
|
180
|
+
ws.wss.on('connection', (socket) => {
|
|
181
|
+
if (stats) {
|
|
182
|
+
sendStats(getStats(stats), false, socket);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
const protocol = userConfig.https ? 'https:' : 'http:';
|
|
186
|
+
const port = opts.port || 8000;
|
|
187
|
+
server.listen(port, () => {
|
|
188
|
+
const host = opts.host && opts.host !== '0.0.0.0' ? opts.host : '127.0.0.1';
|
|
189
|
+
utils_1.logger.ready(`App listening at ${utils_1.chalk.green(`${protocol}//${host}:${port}`)}`);
|
|
175
190
|
});
|
|
191
|
+
return server;
|
|
176
192
|
}
|
|
177
193
|
exports.createServer = createServer;
|
package/dist/server/ws.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Server } from '
|
|
2
|
+
import type { SpdyServer as Server } from '@umijs/bundler-utils';
|
|
3
|
+
import { Server as HttpServer } from 'http';
|
|
4
|
+
import { Http2Server } from 'http2';
|
|
5
|
+
import { Server as HttpsServer } from 'https';
|
|
3
6
|
import WebSocket from '../../compiled/ws';
|
|
4
|
-
export declare function createWebSocketServer(server: Server): {
|
|
7
|
+
export declare function createWebSocketServer(server: HttpServer | HttpsServer | Http2Server | Server): {
|
|
5
8
|
send(message: string): void;
|
|
6
9
|
wss: WebSocket.Server;
|
|
7
10
|
close(): void;
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const Visitor_1 = __importDefault(require("@swc/core/Visitor"));
|
|
7
7
|
const utils_1 = require("@umijs/utils");
|
|
8
|
+
const changeImportFromString_1 = require("./changeImportFromString");
|
|
8
9
|
class AutoCSSModule extends Visitor_1.default {
|
|
9
10
|
visitTsType(expression) {
|
|
10
11
|
return expression;
|
|
@@ -24,7 +25,8 @@ class AutoCSSModule extends Visitor_1.default {
|
|
|
24
25
|
const { specifiers, source } = expression;
|
|
25
26
|
const { value } = source;
|
|
26
27
|
if (specifiers.length && (0, utils_1.isStyleFile)({ filename: value })) {
|
|
27
|
-
|
|
28
|
+
const newImportFrom = `${value}?modules`;
|
|
29
|
+
(0, changeImportFromString_1.changeImportFromString)(expression, newImportFrom);
|
|
28
30
|
}
|
|
29
31
|
return expression;
|
|
30
32
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.changeImportFromString = void 0;
|
|
4
|
+
const changeImportFromString = (e, v) => {
|
|
5
|
+
e.source.value = v;
|
|
6
|
+
// sync change to `raw`
|
|
7
|
+
// https://github.com/swc-project/swc/issues/4128
|
|
8
|
+
e.source.raw = `'${v}'`;
|
|
9
|
+
};
|
|
10
|
+
exports.changeImportFromString = changeImportFromString;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const Visitor_1 = __importDefault(require("@swc/core/Visitor"));
|
|
7
7
|
const utils_1 = require("@umijs/utils");
|
|
8
8
|
const path_1 = require("path");
|
|
9
|
+
const changeImportFromString_1 = require("./changeImportFromString");
|
|
9
10
|
function addLastSlash(path) {
|
|
10
11
|
return path.endsWith('/') ? path : `${path}/`;
|
|
11
12
|
}
|
|
@@ -14,8 +15,8 @@ class LockCoreJS extends Visitor_1.default {
|
|
|
14
15
|
const { source } = expression;
|
|
15
16
|
let { value, type } = source;
|
|
16
17
|
if (type === 'StringLiteral' && value.startsWith('core-js/')) {
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
const newValue = value.replace(/^core-js\//, addLastSlash((0, utils_1.winPath)((0, path_1.dirname)(require.resolve('core-js/package.json')))));
|
|
19
|
+
(0, changeImportFromString_1.changeImportFromString)(expression, newValue);
|
|
19
20
|
}
|
|
20
21
|
return expression;
|
|
21
22
|
}
|
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';
|
|
@@ -22,6 +23,7 @@ export declare enum JSMinifier {
|
|
|
22
23
|
export declare enum CSSMinifier {
|
|
23
24
|
esbuild = "esbuild",
|
|
24
25
|
cssnano = "cssnano",
|
|
26
|
+
parcelCSS = "parcelCSS",
|
|
25
27
|
none = "none"
|
|
26
28
|
}
|
|
27
29
|
export interface ICopy {
|
|
@@ -62,12 +64,14 @@ export interface IConfig {
|
|
|
62
64
|
depTranspiler?: Transpiler;
|
|
63
65
|
devtool?: Config.DevTool;
|
|
64
66
|
deadCode?: DeadCodeParams;
|
|
67
|
+
https?: HttpsServerOptions;
|
|
65
68
|
externals?: WebpackConfig['externals'];
|
|
66
69
|
esm?: {
|
|
67
70
|
[key: string]: any;
|
|
68
71
|
};
|
|
69
72
|
extraBabelPlugins?: IBabelPlugin[];
|
|
70
73
|
extraBabelPresets?: IBabelPlugin[];
|
|
74
|
+
extraBabelIncludes?: string[];
|
|
71
75
|
extraPostCSSPlugins?: any[];
|
|
72
76
|
hash?: boolean;
|
|
73
77
|
ignoreMomentLocale?: boolean;
|
package/dist/types.js
CHANGED
|
@@ -25,5 +25,6 @@ var CSSMinifier;
|
|
|
25
25
|
(function (CSSMinifier) {
|
|
26
26
|
CSSMinifier["esbuild"] = "esbuild";
|
|
27
27
|
CSSMinifier["cssnano"] = "cssnano";
|
|
28
|
+
CSSMinifier["parcelCSS"] = "parcelCSS";
|
|
28
29
|
CSSMinifier["none"] = "none";
|
|
29
30
|
})(CSSMinifier = exports.CSSMinifier || (exports.CSSMinifier = {}));
|
|
@@ -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.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.20",
|
|
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,63 +23,64 @@
|
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "pnpm tsc",
|
|
25
25
|
"build:client": "pnpm tsc --project ./tsconfig.client.json",
|
|
26
|
-
"build:deps": "
|
|
26
|
+
"build:deps": "umi-scripts bundleDeps",
|
|
27
27
|
"dev": "pnpm build -- --watch",
|
|
28
|
-
"generate:webpackPackages": "zx ./scripts/generateWebpackPackages.mjs"
|
|
28
|
+
"generate:webpackPackages": "zx ./scripts/generateWebpackPackages.mjs",
|
|
29
|
+
"test": "umi-scripts jest-turbo"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@
|
|
32
|
+
"@parcel/css": "1.8.2",
|
|
33
|
+
"@pmmmwh/react-refresh-webpack-plugin": "0.5.5",
|
|
32
34
|
"@svgr/core": "6.2.1",
|
|
33
35
|
"@svgr/plugin-jsx": "^6.2.1",
|
|
34
36
|
"@svgr/plugin-svgo": "^6.2.0",
|
|
35
|
-
"@swc/core": "1.2.141",
|
|
36
37
|
"@types/hapi__joi": "17.1.8",
|
|
37
|
-
"@umijs/babel-preset-umi": "4.0.0-rc.
|
|
38
|
-
"@umijs/
|
|
39
|
-
"@umijs/
|
|
40
|
-
"
|
|
38
|
+
"@umijs/babel-preset-umi": "4.0.0-rc.20",
|
|
39
|
+
"@umijs/bundler-utils": "4.0.0-rc.20",
|
|
40
|
+
"@umijs/mfsu": "4.0.0-rc.20",
|
|
41
|
+
"@umijs/utils": "4.0.0-rc.20",
|
|
42
|
+
"cors": "^2.8.5",
|
|
43
|
+
"css-loader": "6.7.1",
|
|
41
44
|
"es5-imcompatible-versions": "^0.1.73",
|
|
42
45
|
"jest-worker": "27.5.1",
|
|
43
46
|
"node-libs-browser": "2.2.1",
|
|
44
|
-
"postcss": "^8.4.
|
|
45
|
-
"postcss-preset-env": "7.
|
|
47
|
+
"postcss": "^8.4.13",
|
|
48
|
+
"postcss-preset-env": "7.5.0",
|
|
46
49
|
"react-error-overlay": "6.0.9"
|
|
47
50
|
},
|
|
48
51
|
"devDependencies": {
|
|
49
|
-
"@
|
|
52
|
+
"@swc/core": "1.2.165",
|
|
53
|
+
"@types/cors": "^2.8.12",
|
|
50
54
|
"@types/webpack-sources": "3.2.0",
|
|
51
|
-
"@types/ws": "8.
|
|
52
|
-
"autoprefixer": "10.4.
|
|
53
|
-
"babel-loader": "8.2.
|
|
55
|
+
"@types/ws": "8.5.3",
|
|
56
|
+
"autoprefixer": "10.4.4",
|
|
57
|
+
"babel-loader": "8.2.4",
|
|
54
58
|
"compression": "1.7.4",
|
|
55
59
|
"connect-history-api-fallback": "1.6.0",
|
|
56
60
|
"copy-webpack-plugin": "10.2.4",
|
|
57
|
-
"css-minimizer-webpack-plugin": "
|
|
58
|
-
"cssnano": "5.
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"http-proxy-middleware": "2.0.3",
|
|
62
|
-
"less": "4.1.2",
|
|
61
|
+
"css-minimizer-webpack-plugin": "4.0.0",
|
|
62
|
+
"cssnano": "5.1.7",
|
|
63
|
+
"fork-ts-checker-webpack-plugin": "7.2.4",
|
|
64
|
+
"http-proxy-middleware": "2.0.4",
|
|
63
65
|
"less-loader": "10.2.0",
|
|
64
|
-
"mini-css-extract-plugin": "2.
|
|
66
|
+
"mini-css-extract-plugin": "2.6.0",
|
|
65
67
|
"postcss-flexbugs-fixes": "5.0.2",
|
|
66
68
|
"postcss-loader": "6.2.1",
|
|
67
69
|
"purgecss-webpack-plugin": "4.1.3",
|
|
68
|
-
"react-refresh": "0.
|
|
70
|
+
"react-refresh": "0.12.0",
|
|
69
71
|
"sass-loader": "12.6.0",
|
|
70
72
|
"schema-utils": "4.0.0",
|
|
71
73
|
"speed-measure-webpack-plugin": "1.5.0",
|
|
72
74
|
"style-loader": "3.3.1",
|
|
73
75
|
"svgo-loader": "3.0.0",
|
|
74
|
-
"
|
|
75
|
-
"terser": "5.10.0",
|
|
76
|
+
"terser": "5.12.1",
|
|
76
77
|
"terser-webpack-plugin": "5.3.1",
|
|
77
78
|
"url-loader": "4.1.1",
|
|
78
|
-
"webpack": "5.
|
|
79
|
+
"webpack": "5.72.0",
|
|
79
80
|
"webpack-5-chain": "8.0.0",
|
|
80
81
|
"webpack-bundle-analyzer": "4.5.0",
|
|
81
82
|
"webpack-dev-middleware": "5.3.1",
|
|
82
|
-
"webpack-manifest-plugin": "
|
|
83
|
+
"webpack-manifest-plugin": "5.0.0",
|
|
83
84
|
"webpack-sources": "3.2.3",
|
|
84
85
|
"ws": "8.5.0"
|
|
85
86
|
},
|
|
@@ -99,10 +100,8 @@
|
|
|
99
100
|
"cssnano",
|
|
100
101
|
"compression",
|
|
101
102
|
"connect-history-api-fallback",
|
|
102
|
-
"express",
|
|
103
103
|
"fork-ts-checker-webpack-plugin",
|
|
104
104
|
"http-proxy-middleware",
|
|
105
|
-
"less",
|
|
106
105
|
"less-loader",
|
|
107
106
|
"mini-css-extract-plugin",
|
|
108
107
|
"postcss-flexbugs-fixes",
|
|
@@ -113,7 +112,6 @@
|
|
|
113
112
|
"style-loader",
|
|
114
113
|
"speed-measure-webpack-plugin",
|
|
115
114
|
"svgo-loader",
|
|
116
|
-
"tapable",
|
|
117
115
|
"terser",
|
|
118
116
|
"terser-webpack-plugin",
|
|
119
117
|
"url-loader",
|
|
@@ -131,12 +129,12 @@
|
|
|
131
129
|
"@babel/core": "@umijs/bundler-utils/compiled/babel/core",
|
|
132
130
|
"es-module-lexer": "@umijs/bundler-utils/compiled/es-module-lexer",
|
|
133
131
|
"esbuild": "@umijs/bundler-utils/compiled/esbuild",
|
|
134
|
-
"express": "
|
|
132
|
+
"express": "@umijs/bundler-utils/compiled/express",
|
|
135
133
|
"jest-worker": "jest-worker",
|
|
136
|
-
"less": "
|
|
134
|
+
"less": "@umijs/bundler-utils/compiled/less",
|
|
137
135
|
"cssnano": "$$LOCAL",
|
|
138
136
|
"postcss": "postcss",
|
|
139
|
-
"tapable": "
|
|
137
|
+
"tapable": "@umijs/bundler-utils/compiled/tapable",
|
|
140
138
|
"terser": "$$LOCAL",
|
|
141
139
|
"terser-webpack-plugin": "$$LOCAL",
|
|
142
140
|
"typescript": "typescript",
|
|
@@ -172,12 +170,12 @@
|
|
|
172
170
|
"compression",
|
|
173
171
|
"connect-history-api-fallback",
|
|
174
172
|
"fork-ts-checker-webpack-plugin",
|
|
175
|
-
"less",
|
|
176
173
|
"less-loader",
|
|
177
174
|
"mini-css-extract-plugin",
|
|
178
175
|
"postcss-flexbugs-fixes",
|
|
179
176
|
"postcss-loader",
|
|
180
177
|
"purgecss-webpack-plugin",
|
|
178
|
+
"react-refresh",
|
|
181
179
|
"sass-loader",
|
|
182
180
|
"speed-measure-webpack-plugin",
|
|
183
181
|
"style-loader",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
Copyright JS Foundation and other contributors
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
-
a copy of this software and associated documentation files (the
|
|
5
|
-
'Software'), to deal in the Software without restriction, including
|
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
-
the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be
|
|
12
|
-
included in all copies or substantial portions of the Software.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
18
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
19
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
20
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|