@umijs/bundler-webpack 4.0.0-canary.20220323.1 → 4.0.0-canary.20220325.1
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/compiled/copy-webpack-plugin/{576.index.js → 939.index.js} +11 -11
- package/compiled/copy-webpack-plugin/index.js +12 -12
- package/dist/server/server.js +3 -4
- 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.js +3 -2
- package/package.json +5 -5
package/dist/server/server.js
CHANGED
|
@@ -42,7 +42,7 @@ function createServer(opts) {
|
|
|
42
42
|
// cros
|
|
43
43
|
app.use((_req, res, next) => {
|
|
44
44
|
res.header('Access-Control-Allow-Origin', '*');
|
|
45
|
-
res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With
|
|
45
|
+
res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With');
|
|
46
46
|
res.header('Access-Control-Allow-Methods', 'GET, HEAD, PUT, POST, PATCH, DELETE, OPTIONS');
|
|
47
47
|
next();
|
|
48
48
|
});
|
|
@@ -55,7 +55,7 @@ function createServer(opts) {
|
|
|
55
55
|
app.use((req, res, next) => {
|
|
56
56
|
if (req.path === '/umi.js' && (0, fs_1.existsSync)((0, path_1.join)(opts.cwd, 'umi.js'))) {
|
|
57
57
|
res.setHeader('Content-Type', 'application/javascript');
|
|
58
|
-
|
|
58
|
+
(0, fs_1.createReadStream)((0, path_1.join)(opts.cwd, 'umi.js')).on('error', next).pipe(res);
|
|
59
59
|
}
|
|
60
60
|
else {
|
|
61
61
|
next();
|
|
@@ -165,8 +165,7 @@ function createServer(opts) {
|
|
|
165
165
|
res.set('Content-Type', 'text/html');
|
|
166
166
|
const htmlPath = (0, path_1.join)(opts.cwd, 'index.html');
|
|
167
167
|
if ((0, fs_1.existsSync)(htmlPath)) {
|
|
168
|
-
|
|
169
|
-
res.send(html);
|
|
168
|
+
(0, fs_1.createReadStream)(htmlPath).on('error', next).pipe(res);
|
|
170
169
|
}
|
|
171
170
|
else {
|
|
172
171
|
next();
|
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-webpack",
|
|
3
|
-
"version": "4.0.0-canary.
|
|
3
|
+
"version": "4.0.0-canary.20220325.1",
|
|
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,9 +35,9 @@
|
|
|
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.
|
|
39
|
-
"@umijs/mfsu": "4.0.0-canary.
|
|
40
|
-
"@umijs/utils": "4.0.0-canary.
|
|
38
|
+
"@umijs/babel-preset-umi": "4.0.0-canary.20220325.1",
|
|
39
|
+
"@umijs/mfsu": "4.0.0-canary.20220325.1",
|
|
40
|
+
"@umijs/utils": "4.0.0-canary.20220325.1",
|
|
41
41
|
"css-loader": "6.7.1",
|
|
42
42
|
"es5-imcompatible-versions": "^0.1.73",
|
|
43
43
|
"jest-worker": "27.5.1",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"react-error-overlay": "6.0.9"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@swc/core": "1.2.
|
|
50
|
+
"@swc/core": "1.2.160",
|
|
51
51
|
"@types/webpack-sources": "3.2.0",
|
|
52
52
|
"@types/ws": "8.5.3",
|
|
53
53
|
"autoprefixer": "10.4.4",
|