glass-easel-miniprogram-webpack-plugin 0.8.0 → 0.8.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/README.md +3 -1
- package/index.js +5 -1
- package/index.ts +8 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -40,6 +40,7 @@ plugins: [
|
|
|
40
40
|
|
|
41
41
|
| Options | Explanation |
|
|
42
42
|
| ------- | ----------- |
|
|
43
|
+
| dev | compile with more debug information (default to `false` if the webpack is in `production` mode) |
|
|
43
44
|
| path | the mini-program-like directory to be compiled (default to `src` ) |
|
|
44
45
|
| resourceFilePattern | the filename pattern (in the mini-program-like directory) to be copied into the webpack output path |
|
|
45
46
|
| defaultEntry | the mini-program page to be loaded on startup |
|
|
@@ -83,10 +84,11 @@ A page can be loaded like this:
|
|
|
83
84
|
|
|
84
85
|
```js
|
|
85
86
|
import * as glassEasel from 'glass-easel'
|
|
86
|
-
import { codeSpace, initWithBackend } from './src' // import the plugin-generated code
|
|
87
|
+
import { codeSpace, initWithBackend, registerGlobalEventListener } from './src' // import the plugin-generated code
|
|
87
88
|
|
|
88
89
|
// create the backend context
|
|
89
90
|
const backendContext = new glassEasel.CurrentWindowBackendContext() // or another backend context
|
|
91
|
+
registerGlobalEventListener(backendContext)
|
|
90
92
|
const ab = initWithBackend(backendContext)
|
|
91
93
|
|
|
92
94
|
// create a mini-program page
|
package/index.js
CHANGED
|
@@ -150,6 +150,7 @@ class GlassEaselMiniprogramWebpackPlugin {
|
|
|
150
150
|
constructor(options) {
|
|
151
151
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
152
152
|
this.virtualModules = new VirtualModulesPlugin();
|
|
153
|
+
this.dev = options.dev;
|
|
153
154
|
this.path = options.path || './src';
|
|
154
155
|
this.resourceFilePattern = options.resourceFilePattern || /\.(jpg|jpeg|png|gif)$/;
|
|
155
156
|
this.defaultEntry = options.defaultEntry || 'pages/index/index';
|
|
@@ -157,6 +158,9 @@ class GlassEaselMiniprogramWebpackPlugin {
|
|
|
157
158
|
this.disableClassPrefix = options.disableClassPrefix || false;
|
|
158
159
|
}
|
|
159
160
|
apply(compiler) {
|
|
161
|
+
const devMode = this.dev === undefined
|
|
162
|
+
? compiler.options.mode === 'development' || compiler.options.mode === 'none'
|
|
163
|
+
: !!this.dev;
|
|
160
164
|
const codeRoot = path.resolve(this.path);
|
|
161
165
|
const compInfoMap = Object.create(null);
|
|
162
166
|
const resPathMap = Object.create(null);
|
|
@@ -423,7 +427,7 @@ class GlassEaselMiniprogramWebpackPlugin {
|
|
|
423
427
|
compilation.hooks.finishModules.tapPromise(PLUGIN_NAME, (modules) => __awaiter(this, void 0, void 0, function* () {
|
|
424
428
|
const tasks = [];
|
|
425
429
|
let indexModule;
|
|
426
|
-
const tmplGroup = new glass_easel_template_compiler_1.TmplGroup();
|
|
430
|
+
const tmplGroup = devMode ? glass_easel_template_compiler_1.TmplGroup.newDev() : new glass_easel_template_compiler_1.TmplGroup();
|
|
427
431
|
// collect compilation results
|
|
428
432
|
// eslint-disable-next-line no-restricted-syntax
|
|
429
433
|
for (const m of modules) {
|
package/index.ts
CHANGED
|
@@ -39,6 +39,7 @@ const CACHE_ETAG = 1
|
|
|
39
39
|
const HOST_STYLES_MODULE = '__glass_easel_host_styles__.wxss'
|
|
40
40
|
|
|
41
41
|
type PluginConfig = {
|
|
42
|
+
dev?: boolean
|
|
42
43
|
path: string
|
|
43
44
|
resourceFilePattern: RegExp
|
|
44
45
|
defaultEntry: string
|
|
@@ -176,6 +177,7 @@ class StyleSheetManager {
|
|
|
176
177
|
}
|
|
177
178
|
|
|
178
179
|
export class GlassEaselMiniprogramWebpackPlugin implements WebpackPluginInstance {
|
|
180
|
+
dev?: boolean
|
|
179
181
|
path: string
|
|
180
182
|
resourceFilePattern: RegExp
|
|
181
183
|
defaultEntry: string
|
|
@@ -185,6 +187,7 @@ export class GlassEaselMiniprogramWebpackPlugin implements WebpackPluginInstance
|
|
|
185
187
|
virtualModules = new VirtualModulesPlugin() as VirtualModulePluginType
|
|
186
188
|
|
|
187
189
|
constructor(options: Partial<PluginConfig>) {
|
|
190
|
+
this.dev = options.dev
|
|
188
191
|
this.path = options.path || './src'
|
|
189
192
|
this.resourceFilePattern = options.resourceFilePattern || /\.(jpg|jpeg|png|gif)$/
|
|
190
193
|
this.defaultEntry = options.defaultEntry || 'pages/index/index'
|
|
@@ -193,6 +196,10 @@ export class GlassEaselMiniprogramWebpackPlugin implements WebpackPluginInstance
|
|
|
193
196
|
}
|
|
194
197
|
|
|
195
198
|
apply(compiler: Compiler) {
|
|
199
|
+
const devMode =
|
|
200
|
+
this.dev === undefined
|
|
201
|
+
? compiler.options.mode === 'development' || compiler.options.mode === 'none'
|
|
202
|
+
: !!this.dev
|
|
196
203
|
const codeRoot = path.resolve(this.path)
|
|
197
204
|
const compInfoMap = Object.create(null) as {
|
|
198
205
|
[compPath: string]: { main: string; taskConfig: unknown; hasWxss: boolean }
|
|
@@ -470,7 +477,7 @@ export class GlassEaselMiniprogramWebpackPlugin implements WebpackPluginInstance
|
|
|
470
477
|
compilation.hooks.finishModules.tapPromise(PLUGIN_NAME, async (modules) => {
|
|
471
478
|
const tasks: Promise<any>[] = []
|
|
472
479
|
let indexModule: NormalModule | undefined
|
|
473
|
-
const tmplGroup = new TmplGroup()
|
|
480
|
+
const tmplGroup = devMode ? TmplGroup.newDev() : new TmplGroup()
|
|
474
481
|
|
|
475
482
|
// collect compilation results
|
|
476
483
|
// eslint-disable-next-line no-restricted-syntax
|
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.8.
|
|
4
|
+
"version": "0.8.2",
|
|
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.85.0",
|
|
21
|
-
"glass-easel": "0.8.
|
|
22
|
-
"glass-easel-miniprogram-adapter": "0.8.
|
|
21
|
+
"glass-easel": "0.8.2",
|
|
22
|
+
"glass-easel-miniprogram-adapter": "0.8.2"
|
|
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-
|
|
31
|
-
"glass-easel-
|
|
30
|
+
"glass-easel-template-compiler": "0.8.2",
|
|
31
|
+
"glass-easel-stylesheet-compiler": "0.8.2"
|
|
32
32
|
},
|
|
33
33
|
"scripts": {
|
|
34
34
|
"build": "tsc -p .",
|