glass-easel-miniprogram-webpack-plugin 0.18.0 → 0.19.0
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/index.js +5 -2
- package/index.ts +8 -0
- package/package.json +5 -5
- package/wxss_loader.js +2 -2
package/index.js
CHANGED
|
@@ -71,12 +71,13 @@ const writeCache = (compiler, key, value) => new Promise((resolve) => {
|
|
|
71
71
|
});
|
|
72
72
|
});
|
|
73
73
|
class StyleSheetManager {
|
|
74
|
-
constructor(disableClassPrefix, codeRoot, virtualModules) {
|
|
74
|
+
constructor(disableClassPrefix, disableHostConversion, codeRoot, virtualModules) {
|
|
75
75
|
this.map = Object.create(null);
|
|
76
76
|
this.enableStyleScope = Object.create(null);
|
|
77
77
|
this.scopeNameInc = 0;
|
|
78
78
|
this.hostStylesReady = false;
|
|
79
79
|
this.disableClassPrefix = disableClassPrefix;
|
|
80
|
+
this.disableHostConversion = disableHostConversion;
|
|
80
81
|
this.codeRoot = codeRoot;
|
|
81
82
|
this.virtualModules = virtualModules;
|
|
82
83
|
}
|
|
@@ -155,6 +156,7 @@ class GlassEaselMiniprogramWebpackPlugin {
|
|
|
155
156
|
this.defaultEntry = options.defaultEntry || 'pages/index/index';
|
|
156
157
|
this.customBootstrap = options.customBootstrap || false;
|
|
157
158
|
this.disableClassPrefix = options.disableClassPrefix || false;
|
|
159
|
+
this.disableHostConversion = options.disableHostConversion || false;
|
|
158
160
|
}
|
|
159
161
|
apply(compiler) {
|
|
160
162
|
const devMode = this.dev === undefined
|
|
@@ -170,7 +172,7 @@ class GlassEaselMiniprogramWebpackPlugin {
|
|
|
170
172
|
// init style sheet manager
|
|
171
173
|
const virtualModules = this.virtualModules;
|
|
172
174
|
virtualModules.apply(compiler);
|
|
173
|
-
const styleSheetManager = new StyleSheetManager(this.disableClassPrefix, codeRoot, this.virtualModules);
|
|
175
|
+
const styleSheetManager = new StyleSheetManager(this.disableClassPrefix, this.disableHostConversion, codeRoot, this.virtualModules);
|
|
174
176
|
// cleanup wasm modules
|
|
175
177
|
compiler.hooks.shutdown.tap(PLUGIN_NAME, () => {
|
|
176
178
|
depsTmplGroup.free();
|
|
@@ -374,6 +376,7 @@ class GlassEaselMiniprogramWebpackPlugin {
|
|
|
374
376
|
else {
|
|
375
377
|
x.options = {
|
|
376
378
|
classPrefix: styleSheetManager.getScopeName(compPath),
|
|
379
|
+
disableHostConversion: styleSheetManager.disableHostConversion,
|
|
377
380
|
setLowPriorityStyles: (s, map) => {
|
|
378
381
|
styleSheetManager.setLowPriorityStyles(compPath, s, map);
|
|
379
382
|
},
|
package/index.ts
CHANGED
|
@@ -44,6 +44,7 @@ type PluginConfig = {
|
|
|
44
44
|
defaultEntry: string
|
|
45
45
|
customBootstrap: boolean
|
|
46
46
|
disableClassPrefix: boolean
|
|
47
|
+
disableHostConversion: boolean
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
type GlobalStaticConfig = {
|
|
@@ -91,16 +92,19 @@ class StyleSheetManager {
|
|
|
91
92
|
enableStyleScope = Object.create(null) as { [path: string]: boolean }
|
|
92
93
|
scopeNameInc = 0
|
|
93
94
|
disableClassPrefix: boolean
|
|
95
|
+
disableHostConversion: boolean
|
|
94
96
|
codeRoot: string
|
|
95
97
|
virtualModules: VirtualModulePluginType
|
|
96
98
|
hostStylesReady = false
|
|
97
99
|
|
|
98
100
|
constructor(
|
|
99
101
|
disableClassPrefix: boolean,
|
|
102
|
+
disableHostConversion: boolean,
|
|
100
103
|
codeRoot: string,
|
|
101
104
|
virtualModules: VirtualModulePluginType,
|
|
102
105
|
) {
|
|
103
106
|
this.disableClassPrefix = disableClassPrefix
|
|
107
|
+
this.disableHostConversion = disableHostConversion
|
|
104
108
|
this.codeRoot = codeRoot
|
|
105
109
|
this.virtualModules = virtualModules
|
|
106
110
|
}
|
|
@@ -182,6 +186,7 @@ export class GlassEaselMiniprogramWebpackPlugin implements WebpackPluginInstance
|
|
|
182
186
|
defaultEntry: string
|
|
183
187
|
customBootstrap: boolean
|
|
184
188
|
disableClassPrefix: boolean
|
|
189
|
+
disableHostConversion: boolean
|
|
185
190
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
186
191
|
virtualModules = new VirtualModulesPlugin() as VirtualModulePluginType
|
|
187
192
|
|
|
@@ -192,6 +197,7 @@ export class GlassEaselMiniprogramWebpackPlugin implements WebpackPluginInstance
|
|
|
192
197
|
this.defaultEntry = options.defaultEntry || 'pages/index/index'
|
|
193
198
|
this.customBootstrap = options.customBootstrap || false
|
|
194
199
|
this.disableClassPrefix = options.disableClassPrefix || false
|
|
200
|
+
this.disableHostConversion = options.disableHostConversion || false
|
|
195
201
|
}
|
|
196
202
|
|
|
197
203
|
apply(compiler: Compiler) {
|
|
@@ -214,6 +220,7 @@ export class GlassEaselMiniprogramWebpackPlugin implements WebpackPluginInstance
|
|
|
214
220
|
virtualModules.apply(compiler)
|
|
215
221
|
const styleSheetManager = new StyleSheetManager(
|
|
216
222
|
this.disableClassPrefix,
|
|
223
|
+
this.disableHostConversion,
|
|
217
224
|
codeRoot,
|
|
218
225
|
this.virtualModules,
|
|
219
226
|
)
|
|
@@ -425,6 +432,7 @@ export class GlassEaselMiniprogramWebpackPlugin implements WebpackPluginInstance
|
|
|
425
432
|
} else {
|
|
426
433
|
x.options = {
|
|
427
434
|
classPrefix: styleSheetManager.getScopeName(compPath),
|
|
435
|
+
disableHostConversion: styleSheetManager.disableHostConversion,
|
|
428
436
|
setLowPriorityStyles: (s: string, map: string) => {
|
|
429
437
|
styleSheetManager.setLowPriorityStyles(compPath, s, map)
|
|
430
438
|
},
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glass-easel-miniprogram-webpack-plugin",
|
|
3
3
|
"description": "The webpack plugin of the glass-easel project for MiniProgram file structure",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.19.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/wechat-miniprogram/glass-easel.git"
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"main": "index.js",
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"webpack": "^5.101.3",
|
|
21
|
-
"glass-easel": "0.
|
|
22
|
-
"glass-easel
|
|
21
|
+
"glass-easel-miniprogram-adapter": "0.19.0",
|
|
22
|
+
"glass-easel": "0.19.0"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"chalk": "4",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"source-map": "^0.7.4",
|
|
28
28
|
"webpack-sources": "^3.2.1",
|
|
29
29
|
"webpack-virtual-modules": "^0.5.0",
|
|
30
|
-
"glass-easel-stylesheet-compiler": "0.
|
|
31
|
-
"glass-easel-template-compiler": "0.
|
|
30
|
+
"glass-easel-stylesheet-compiler": "0.19.0",
|
|
31
|
+
"glass-easel-template-compiler": "0.19.0"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "tsc -p .",
|
package/wxss_loader.js
CHANGED
|
@@ -6,8 +6,8 @@ const { StyleSheetTransformer } = require('glass-easel-stylesheet-compiler')
|
|
|
6
6
|
|
|
7
7
|
module.exports = function (src, prevMap, meta) {
|
|
8
8
|
const callback = this.async()
|
|
9
|
-
const { classPrefix, setLowPriorityStyles } = this.query
|
|
10
|
-
const sst = new StyleSheetTransformer(this.resourcePath, src, classPrefix, 750,
|
|
9
|
+
const { classPrefix, disableHostConversion, setLowPriorityStyles } = this.query
|
|
10
|
+
const sst = new StyleSheetTransformer(this.resourcePath, src, classPrefix, 750, !disableHostConversion)
|
|
11
11
|
setLowPriorityStyles(sst.getLowPriorityContent(), sst.getLowPrioritySourceMap())
|
|
12
12
|
const warnings = sst.extractWarnings()
|
|
13
13
|
if (warnings && warnings.length > 0) {
|