@mpxjs/webpack-plugin 2.8.38 → 2.8.40-beta.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/lib/dependencies/ResolveDependency.js +12 -1
- package/lib/index.js +25 -2
- package/lib/json-compiler/default-page.mpx +3 -0
- package/lib/json-compiler/helper.js +10 -1
- package/lib/json-compiler/index.js +3 -5
- package/lib/wxss/runtime/api.js +4 -3
- package/lib/wxss/runtime/sourceMaps.js +1 -0
- package/package.json +2 -2
- package/lib/partial-compile/index.js +0 -35
|
@@ -35,6 +35,15 @@ class ResolveDependency extends NullDependency {
|
|
|
35
35
|
return pagesMap[resourcePath] || currentComponentsMap[resourcePath] || mainComponentsMap[resourcePath] || currentStaticResourcesMap[resourcePath] || mainStaticResourcesMap[resourcePath] || ''
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
isPartialCompileFilteredPage (resource) {
|
|
39
|
+
const { compilation } = this
|
|
40
|
+
if (!compilation) return ''
|
|
41
|
+
const mpx = compilation.__mpx__
|
|
42
|
+
const { partialCompileFilteredPagesMap } = mpx
|
|
43
|
+
const { resourcePath } = parseRequest(resource)
|
|
44
|
+
return partialCompileFilteredPagesMap[resourcePath]
|
|
45
|
+
}
|
|
46
|
+
|
|
38
47
|
// resolved可能会动态变更,需用此更新hash
|
|
39
48
|
updateHash (hash, context) {
|
|
40
49
|
this.resolved = this.getResolved()
|
|
@@ -42,7 +51,9 @@ class ResolveDependency extends NullDependency {
|
|
|
42
51
|
if (this.resolved) {
|
|
43
52
|
hash.update(this.resolved)
|
|
44
53
|
} else {
|
|
45
|
-
|
|
54
|
+
if (!this.isPartialCompileFilteredPage(resource)) {
|
|
55
|
+
compilation.errors.push(new Error(`Path ${resource} is not a page/component/static resource, which is resolved from ${issuerResource}!`))
|
|
56
|
+
}
|
|
46
57
|
}
|
|
47
58
|
super.updateHash(hash, context)
|
|
48
59
|
}
|
package/lib/index.js
CHANGED
|
@@ -38,7 +38,6 @@ const FlagPluginDependency = require('./dependencies/FlagPluginDependency')
|
|
|
38
38
|
const RemoveEntryDependency = require('./dependencies/RemoveEntryDependency')
|
|
39
39
|
const RecordVueContentDependency = require('./dependencies/RecordVueContentDependency')
|
|
40
40
|
const SplitChunksPlugin = require('webpack/lib/optimize/SplitChunksPlugin')
|
|
41
|
-
const PartialCompilePlugin = require('./partial-compile/index')
|
|
42
41
|
const fixRelative = require('./utils/fix-relative')
|
|
43
42
|
const parseRequest = require('./utils/parse-request')
|
|
44
43
|
const { matchCondition } = require('./utils/match-condition')
|
|
@@ -55,6 +54,7 @@ const jsonThemeCompilerPath = normalize.lib('json-compiler/theme')
|
|
|
55
54
|
const jsonPluginCompilerPath = normalize.lib('json-compiler/plugin')
|
|
56
55
|
const extractorPath = normalize.lib('extractor')
|
|
57
56
|
const async = require('async')
|
|
57
|
+
const { parseQuery } = require('loader-utils')
|
|
58
58
|
const stringifyLoadersAndResource = require('./utils/stringify-loaders-resource')
|
|
59
59
|
const emitFile = require('./utils/emit-file')
|
|
60
60
|
const { MPX_PROCESSED_FLAG, MPX_DISABLE_EXTRACTOR_CACHE } = require('./utils/const')
|
|
@@ -381,7 +381,29 @@ class MpxWebpackPlugin {
|
|
|
381
381
|
let mpx
|
|
382
382
|
|
|
383
383
|
if (this.options.partialCompile) {
|
|
384
|
-
|
|
384
|
+
function isResolvingPage (obj) {
|
|
385
|
+
// valid query should start with '?'
|
|
386
|
+
const query = obj.query || '?'
|
|
387
|
+
return parseQuery(query).isPage
|
|
388
|
+
}
|
|
389
|
+
// new PartialCompilePlugin(this.options.partialCompile).apply(compiler)
|
|
390
|
+
compiler.resolverFactory.hooks.resolver.intercept({
|
|
391
|
+
factory: (type, hook) => {
|
|
392
|
+
hook.tap('MpxPartialCompilePlugin', (resolver) => {
|
|
393
|
+
resolver.hooks.result.tapAsync({
|
|
394
|
+
name: 'MpxPartialCompilePlugin',
|
|
395
|
+
stage: -100
|
|
396
|
+
}, (obj, resolverContext, callback) => {
|
|
397
|
+
if (isResolvingPage(obj) && !matchCondition(obj.path, this.options.partialCompile)) {
|
|
398
|
+
if (mpx) mpx.partialCompileFilteredPagesMap[obj.path] = true
|
|
399
|
+
obj.path = false
|
|
400
|
+
}
|
|
401
|
+
callback(null, obj)
|
|
402
|
+
})
|
|
403
|
+
})
|
|
404
|
+
return hook
|
|
405
|
+
}
|
|
406
|
+
})
|
|
385
407
|
}
|
|
386
408
|
|
|
387
409
|
const getPackageCacheGroup = packageName => {
|
|
@@ -595,6 +617,7 @@ class MpxWebpackPlugin {
|
|
|
595
617
|
removedChunks: [],
|
|
596
618
|
forceProxyEventRules: this.options.forceProxyEventRules,
|
|
597
619
|
enableRequireAsync: this.options.mode === 'wx' || (this.options.mode === 'ali' && this.options.enableAliRequireAsync),
|
|
620
|
+
partialCompileFilteredPagesMap: {},
|
|
598
621
|
pathHash: (resourcePath) => {
|
|
599
622
|
if (this.options.pathHashMode === 'relative' && this.options.projectRoot) {
|
|
600
623
|
return hash(path.relative(this.options.projectRoot, resourcePath))
|
|
@@ -6,6 +6,7 @@ const parseRequest = require('../utils/parse-request')
|
|
|
6
6
|
const addQuery = require('../utils/add-query')
|
|
7
7
|
const loaderUtils = require('loader-utils')
|
|
8
8
|
const resolve = require('../utils/resolve')
|
|
9
|
+
const { RESOLVE_IGNORED_ERR } = require('../utils/const')
|
|
9
10
|
|
|
10
11
|
module.exports = function createJSONHelper ({ loaderContext, emitWarning, customGetDynamicEntry }) {
|
|
11
12
|
const mpx = loaderContext.getMpx()
|
|
@@ -101,7 +102,15 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
|
|
|
101
102
|
// 增加 page 标识
|
|
102
103
|
page = addQuery(page, { isPage: true })
|
|
103
104
|
resolve(context, page, loaderContext, (err, resource) => {
|
|
104
|
-
if (err)
|
|
105
|
+
if (err) {
|
|
106
|
+
if (err === RESOLVE_IGNORED_ERR && tarRoot) {
|
|
107
|
+
const defaultPage = require.resolve('./default-page.mpx') + `?resourcePath=${context}/${tarRoot}/pages/index.mpx`
|
|
108
|
+
resource = defaultPage
|
|
109
|
+
aliasPath = ''
|
|
110
|
+
} else {
|
|
111
|
+
return callback(err)
|
|
112
|
+
}
|
|
113
|
+
}
|
|
105
114
|
const { resourcePath, queryObj: { isFirst } } = parseRequest(resource)
|
|
106
115
|
const ext = path.extname(resourcePath)
|
|
107
116
|
let outputPath
|
|
@@ -577,12 +577,10 @@ module.exports = function (content) {
|
|
|
577
577
|
for (const root in subPackagesCfg) {
|
|
578
578
|
const subPackageCfg = subPackagesCfg[root]
|
|
579
579
|
// 分包不存在 pages,输出 subPackages 字段会报错
|
|
580
|
-
if (
|
|
581
|
-
|
|
582
|
-
json.subPackages = []
|
|
583
|
-
}
|
|
584
|
-
json.subPackages.push(subPackageCfg)
|
|
580
|
+
if (!json.subPackages) {
|
|
581
|
+
json.subPackages = []
|
|
585
582
|
}
|
|
583
|
+
json.subPackages.push(subPackageCfg)
|
|
586
584
|
}
|
|
587
585
|
const processOutput = (output) => {
|
|
588
586
|
output = processDynamicEntry(output)
|
package/lib/wxss/runtime/api.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
3
|
Author Tobias Koppers @sokra
|
|
4
4
|
*/
|
|
5
|
+
/* eslint no-var: off */
|
|
5
6
|
module.exports = function (cssWithMappingToString) {
|
|
6
7
|
var list = []
|
|
7
8
|
|
|
@@ -51,7 +52,7 @@ module.exports = function (cssWithMappingToString) {
|
|
|
51
52
|
var alreadyImportedModules = {}
|
|
52
53
|
|
|
53
54
|
if (dedupe) {
|
|
54
|
-
for (
|
|
55
|
+
for (var k = 0; k < this.length; k++) {
|
|
55
56
|
var id = this[k][0]
|
|
56
57
|
|
|
57
58
|
if (id != null) {
|
|
@@ -60,8 +61,8 @@ module.exports = function (cssWithMappingToString) {
|
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
for (var
|
|
64
|
-
var item = [].concat(modules[
|
|
64
|
+
for (var k1 = 0; k1 < modules.length; k1++) {
|
|
65
|
+
var item = [].concat(modules[k1])
|
|
65
66
|
|
|
66
67
|
if (dedupe && alreadyImportedModules[item[0]]) {
|
|
67
68
|
continue
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.40-beta.0",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=14.14.0"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "03d5373a8526f23e00f05917aaf84f6fbb7ef98f"
|
|
86
86
|
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const { matchCondition } = require('../utils/match-condition')
|
|
2
|
-
const { parseQuery } = require('loader-utils')
|
|
3
|
-
|
|
4
|
-
class MpxPartialCompilePlugin {
|
|
5
|
-
constructor (condition) {
|
|
6
|
-
this.condition = condition
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
isResolvingPage (obj) {
|
|
10
|
-
// valid query should start with '?'
|
|
11
|
-
const query = obj.query || '?'
|
|
12
|
-
return parseQuery(query).isPage
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
apply (compiler) {
|
|
16
|
-
compiler.resolverFactory.hooks.resolver.intercept({
|
|
17
|
-
factory: (type, hook) => {
|
|
18
|
-
hook.tap('MpxPartialCompilePlugin', (resolver) => {
|
|
19
|
-
resolver.hooks.result.tapAsync({
|
|
20
|
-
name: 'MpxPartialCompilePlugin',
|
|
21
|
-
stage: -100
|
|
22
|
-
}, (obj, resolverContext, callback) => {
|
|
23
|
-
if (this.isResolvingPage(obj) && !matchCondition(obj.path, this.condition)) {
|
|
24
|
-
obj.path = false
|
|
25
|
-
}
|
|
26
|
-
callback(null, obj)
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
return hook
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
module.exports = MpxPartialCompilePlugin
|