@umijs/bundler-webpack 4.0.56 → 4.0.57
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/dist/config/cssRules.js +31 -22
- package/dist/schema.js +1 -0
- package/dist/server/ws.d.ts +1 -1
- package/dist/types.d.ts +3 -0
- package/package.json +5 -5
package/dist/config/cssRules.js
CHANGED
|
@@ -62,14 +62,14 @@ async function addCSSRules(opts) {
|
|
|
62
62
|
const nestRulesConfig = [
|
|
63
63
|
userConfig.autoCSSModules && {
|
|
64
64
|
rule: rule.test(test).oneOf("css-modules").resourceQuery(/modules/),
|
|
65
|
-
|
|
65
|
+
isAutoCSSModuleRule: true
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
68
|
rule: rule.test(test).oneOf("css").sideEffects(true),
|
|
69
|
-
|
|
69
|
+
isAutoCSSModuleRule: false
|
|
70
70
|
}
|
|
71
71
|
].filter(Boolean);
|
|
72
|
-
for (const { rule: rule2,
|
|
72
|
+
for (const { rule: rule2, isAutoCSSModuleRule } of nestRulesConfig) {
|
|
73
73
|
if (userConfig.styleLoader) {
|
|
74
74
|
rule2.use("style-loader").loader(
|
|
75
75
|
require.resolve("@umijs/bundler-webpack/compiled/style-loader")
|
|
@@ -83,6 +83,23 @@ async function addCSSRules(opts) {
|
|
|
83
83
|
esModule: true
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
|
+
const getLocalIdent = userConfig.ssr && getLocalIdentForSSR;
|
|
87
|
+
const localIdentName = "[local]___[hash:base64:5]";
|
|
88
|
+
let cssLoaderModulesConfig;
|
|
89
|
+
if (isAutoCSSModuleRule) {
|
|
90
|
+
cssLoaderModulesConfig = {
|
|
91
|
+
localIdentName,
|
|
92
|
+
...userConfig.cssLoaderModules,
|
|
93
|
+
getLocalIdent
|
|
94
|
+
};
|
|
95
|
+
} else if (userConfig.normalCSSLoaderModules) {
|
|
96
|
+
cssLoaderModulesConfig = {
|
|
97
|
+
localIdentName,
|
|
98
|
+
auto: true,
|
|
99
|
+
...userConfig.normalCSSLoaderModules,
|
|
100
|
+
getLocalIdent
|
|
101
|
+
};
|
|
102
|
+
}
|
|
86
103
|
rule2.use("css-loader").loader(require.resolve("css-loader")).options({
|
|
87
104
|
importLoaders: 1,
|
|
88
105
|
esModule: true,
|
|
@@ -94,25 +111,7 @@ async function addCSSRules(opts) {
|
|
|
94
111
|
}
|
|
95
112
|
},
|
|
96
113
|
import: true,
|
|
97
|
-
|
|
98
|
-
modules: {
|
|
99
|
-
localIdentName: "[local]___[hash:base64:5]",
|
|
100
|
-
...userConfig.cssLoaderModules,
|
|
101
|
-
// If SSR is enabled, we need to handling the css modules name hashing
|
|
102
|
-
// and save the class names mapping into opts.cssModulesMapping
|
|
103
|
-
// so the esbuild can use it to generate the correct name for the server side
|
|
104
|
-
getLocalIdent: userConfig.ssr && ((context, localIdentName, localName, opt) => {
|
|
105
|
-
const classIdent = ((0, import_utils.winPath)(context.resourcePath).replace(
|
|
106
|
-
(0, import_utils.winPath)(ensureLastSlash(opt.context)),
|
|
107
|
-
""
|
|
108
|
-
) + "@" + localName).trim();
|
|
109
|
-
let hash = Buffer.from(classIdent).toString("base64").replace(/=/g, "");
|
|
110
|
-
hash = hash.substring(hash.length - 5);
|
|
111
|
-
const result = localIdentName.replace(/\[local]/g, localName).replace(/\[hash[^\[]*?]/g, hash);
|
|
112
|
-
return result;
|
|
113
|
-
})
|
|
114
|
-
}
|
|
115
|
-
} : {},
|
|
114
|
+
modules: cssLoaderModulesConfig,
|
|
116
115
|
...userConfig.cssLoader
|
|
117
116
|
});
|
|
118
117
|
rule2.use("postcss-loader").loader(
|
|
@@ -143,6 +142,16 @@ async function addCSSRules(opts) {
|
|
|
143
142
|
function ensureLastSlash(path) {
|
|
144
143
|
return path.endsWith("/") ? path : path + "/";
|
|
145
144
|
}
|
|
145
|
+
function getLocalIdentForSSR(context, localIdentName, localName, opt) {
|
|
146
|
+
const classIdent = ((0, import_utils.winPath)(context.resourcePath).replace(
|
|
147
|
+
(0, import_utils.winPath)(ensureLastSlash(opt.context)),
|
|
148
|
+
""
|
|
149
|
+
) + "@" + localName).trim();
|
|
150
|
+
let hash = Buffer.from(classIdent).toString("base64").replace(/=/g, "");
|
|
151
|
+
hash = hash.substring(hash.length - 5);
|
|
152
|
+
const result = localIdentName.replace(/\[local]/g, localName).replace(/\[hash[^\[]*?]/g, hash);
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
146
155
|
// Annotate the CommonJS export names for ESM import in node:
|
|
147
156
|
0 && (module.exports = {
|
|
148
157
|
addCSSRules
|
package/dist/schema.js
CHANGED
|
@@ -135,6 +135,7 @@ function getSchemas() {
|
|
|
135
135
|
}),
|
|
136
136
|
Joi.boolean()
|
|
137
137
|
),
|
|
138
|
+
normalCSSLoaderModules: (Joi) => Joi.object(),
|
|
138
139
|
outputPath: (Joi) => Joi.string(),
|
|
139
140
|
postcssLoader: (Joi) => Joi.object(),
|
|
140
141
|
proxy: (Joi) => Joi.alternatives().try(Joi.object(), Joi.array()),
|
package/dist/server/ws.d.ts
CHANGED
|
@@ -8,6 +8,6 @@ import { Server as HttpsServer } from 'https';
|
|
|
8
8
|
import WebSocket from '../../compiled/ws';
|
|
9
9
|
export declare function createWebSocketServer(server: HttpServer | HttpsServer | Http2Server | Server): {
|
|
10
10
|
send(message: string): void;
|
|
11
|
-
wss: WebSocket.Server
|
|
11
|
+
wss: WebSocket.Server;
|
|
12
12
|
close(): void;
|
|
13
13
|
};
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/bundler-webpack",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.57",
|
|
4
4
|
"description": "@umijs/bundler-webpack",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/bundler-webpack#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"@svgr/plugin-jsx": "^6.5.1",
|
|
34
34
|
"@svgr/plugin-svgo": "^6.5.1",
|
|
35
35
|
"@types/hapi__joi": "17.1.9",
|
|
36
|
-
"@umijs/babel-preset-umi": "4.0.
|
|
37
|
-
"@umijs/bundler-utils": "4.0.
|
|
36
|
+
"@umijs/babel-preset-umi": "4.0.57",
|
|
37
|
+
"@umijs/bundler-utils": "4.0.57",
|
|
38
38
|
"@umijs/case-sensitive-paths-webpack-plugin": "^1.0.1",
|
|
39
|
-
"@umijs/mfsu": "4.0.
|
|
40
|
-
"@umijs/utils": "4.0.
|
|
39
|
+
"@umijs/mfsu": "4.0.57",
|
|
40
|
+
"@umijs/utils": "4.0.57",
|
|
41
41
|
"cors": "^2.8.5",
|
|
42
42
|
"css-loader": "6.7.1",
|
|
43
43
|
"es5-imcompatible-versions": "^0.1.78",
|