@mpxjs/webpack-plugin 2.7.4 → 2.7.8
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/DynamicEntryDependency.js +5 -2
- package/lib/extractor.js +3 -2
- package/lib/index.js +1 -1
- package/lib/json-compiler/index.js +2 -1
- package/lib/loader.js +1 -1
- package/lib/resolver/PackageEntryPlugin.js +22 -35
- package/lib/runtime/components/web/mpx-movable-view.vue +6 -2
- package/lib/template-compiler/compiler.js +5 -0
- package/lib/template-compiler/trans-dynamic-class-expr.js +2 -0
- package/lib/utils/normalize.js +4 -2
- package/lib/wxml/loader.js +1 -1
- package/lib/wxss/loader.js +1 -1
- package/package.json +2 -2
|
@@ -117,8 +117,11 @@ class DynamicEntryDependency extends NullDependency {
|
|
|
117
117
|
|
|
118
118
|
DynamicEntryDependency.Template = class DynamicEntryDependencyTemplate {
|
|
119
119
|
apply (dep, source) {
|
|
120
|
-
const { resultPath, range, key } = dep
|
|
121
|
-
if (
|
|
120
|
+
const { resultPath, range, key, outputPath } = dep
|
|
121
|
+
if (outputPath === 'custom-tab-bar/index') {
|
|
122
|
+
// replace with true for custom-tab-bar
|
|
123
|
+
source.replace(range[0], range[1] - 1, 'true')
|
|
124
|
+
} else if (resultPath) {
|
|
122
125
|
source.replace(range[0], range[1] - 1, JSON.stringify(resultPath))
|
|
123
126
|
} else {
|
|
124
127
|
const replaceRange = `mpx_replace_path_${key}`
|
package/lib/extractor.js
CHANGED
|
@@ -16,7 +16,7 @@ module.exports.pitch = async function (remainingRequest) {
|
|
|
16
16
|
const type = queryObj.type
|
|
17
17
|
const index = queryObj.index || 0
|
|
18
18
|
const isStatic = queryObj.isStatic
|
|
19
|
-
const
|
|
19
|
+
const issuerResource = queryObj.issuerResource
|
|
20
20
|
const fromImport = queryObj.fromImport
|
|
21
21
|
const needBabel = queryObj.needBabel
|
|
22
22
|
|
|
@@ -82,7 +82,8 @@ module.exports.pitch = async function (remainingRequest) {
|
|
|
82
82
|
// styles为static就两种情况,一种是.mpx中使用src引用样式,第二种为css-loader中处理@import
|
|
83
83
|
// 为了支持持久化缓存,.mpx中使用src引用样式对issueFile asset产生的副作用迁移到ExtractDependency中处理
|
|
84
84
|
case 'styles':
|
|
85
|
-
if (
|
|
85
|
+
if (issuerResource) {
|
|
86
|
+
const issuerFile = mpx.getExtractedFile(issuerResource)
|
|
86
87
|
let relativePath = toPosix(path.relative(path.dirname(issuerFile), file))
|
|
87
88
|
relativePath = fixRelative(relativePath, mode)
|
|
88
89
|
if (fromImport) {
|
package/lib/index.js
CHANGED
|
@@ -279,7 +279,7 @@ class MpxWebpackPlugin {
|
|
|
279
279
|
|
|
280
280
|
const addModePlugin = new AddModePlugin('before-file', this.options.mode, this.options.fileConditionRules, 'file')
|
|
281
281
|
const addEnvPlugin = new AddEnvPlugin('before-file', this.options.env, this.options.fileConditionRules, 'file')
|
|
282
|
-
const packageEntryPlugin = new PackageEntryPlugin('before-
|
|
282
|
+
const packageEntryPlugin = new PackageEntryPlugin('before-file', this.options.miniNpmPackages, 'file')
|
|
283
283
|
if (Array.isArray(compiler.options.resolve.plugins)) {
|
|
284
284
|
compiler.options.resolve.plugins.push(addModePlugin)
|
|
285
285
|
} else {
|
|
@@ -474,11 +474,12 @@ module.exports = function (content) {
|
|
|
474
474
|
|
|
475
475
|
const processCustomTabBar = (tabBar, context, callback) => {
|
|
476
476
|
if (tabBar && tabBar.custom) {
|
|
477
|
-
processComponent('./custom-tab-bar/index', context, { outputPath: 'custom-tab-bar/index' }, (err) => {
|
|
477
|
+
processComponent('./custom-tab-bar/index', context, { outputPath: 'custom-tab-bar/index' }, (err, entry) => {
|
|
478
478
|
if (err === RESOLVE_IGNORED_ERR) {
|
|
479
479
|
delete tabBar.custom
|
|
480
480
|
return callback()
|
|
481
481
|
}
|
|
482
|
+
tabBar.custom = entry // hack for javascript parser call hook.
|
|
482
483
|
callback(err)
|
|
483
484
|
})
|
|
484
485
|
} else {
|
package/lib/loader.js
CHANGED
|
@@ -290,7 +290,7 @@ module.exports = function (content) {
|
|
|
290
290
|
...style.src ? {
|
|
291
291
|
...queryObj,
|
|
292
292
|
isStatic: true,
|
|
293
|
-
|
|
293
|
+
issuerResource: addQuery(this.resource, { type: 'styles' }, true)
|
|
294
294
|
} : null,
|
|
295
295
|
moduleId,
|
|
296
296
|
scoped
|
|
@@ -1,55 +1,42 @@
|
|
|
1
1
|
const path = require('path')
|
|
2
|
-
|
|
3
|
-
* @desc 获取小程序npm包资源入口目录
|
|
4
|
-
*/
|
|
5
|
-
const getEntry = (name, miniprogram) => {
|
|
6
|
-
return path.join(name, miniprogram)
|
|
7
|
-
}
|
|
2
|
+
const toPosix = require('../utils/to-posix')
|
|
8
3
|
|
|
9
4
|
module.exports = class PackageEntryPlugin {
|
|
10
|
-
constructor (source,
|
|
5
|
+
constructor (source, miniNpmPackages, target) {
|
|
11
6
|
this.source = source
|
|
12
7
|
this.target = target
|
|
13
|
-
this.
|
|
8
|
+
this.miniNpmPackages = miniNpmPackages
|
|
14
9
|
}
|
|
15
10
|
|
|
16
11
|
/**
|
|
17
12
|
* 判断是否需要更改innerRequest
|
|
18
13
|
* 小程序发布npm包约束: package.json配置miniprogram 或默认 miniprogram_dist目录
|
|
19
|
-
* 0. 前提: request中含有package.json中name字段
|
|
20
14
|
* 1. package.json中配置了miniprogram, 且request中不含miniprogram,尝试拼接
|
|
21
|
-
* 2. 用户配置
|
|
15
|
+
* 2. 用户配置miniNpmPackages说明是小程序npm包,如果package.json中没配置miniprogram字段,则尝试拼接默认miniprogram_dist目录
|
|
22
16
|
*/
|
|
23
17
|
apply (resolver) {
|
|
24
18
|
const target = resolver.ensureHook(this.target)
|
|
25
19
|
resolver.getHook(this.source).tapAsync('PackagePlugin', (request, resolveContext, callback) => {
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
if (request.miniprogram) return callback()
|
|
21
|
+
let { path: resourcePath, descriptionFileData, descriptionFileRoot } = request
|
|
22
|
+
if (request.miniprogram || !descriptionFileData) return callback()
|
|
23
|
+
|
|
24
|
+
let { name, miniprogram } = descriptionFileData
|
|
25
|
+
if (!miniprogram && this.miniNpmPackages.includes(name)) miniprogram = 'miniprogram_dist'
|
|
26
|
+
if (!miniprogram) return callback()
|
|
27
|
+
|
|
28
|
+
let relativePath = path.relative(descriptionFileRoot, resourcePath)
|
|
29
|
+
if (relativePath.startsWith(miniprogram)) return callback()
|
|
30
|
+
|
|
31
|
+
relativePath = path.join(miniprogram, relativePath)
|
|
28
32
|
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (innerRequest.indexOf(normalizedName) === -1) {
|
|
35
|
-
return callback()
|
|
36
|
-
}
|
|
37
|
-
if (miniprogram) {
|
|
38
|
-
newEntry = getEntry(normalizedName, miniprogram)
|
|
39
|
-
} else if (this.miniNpmPackage.includes(name)) {
|
|
40
|
-
newEntry = getEntry(normalizedName, 'miniprogram_dist')
|
|
41
|
-
}
|
|
33
|
+
const obj = Object.assign({}, request, {
|
|
34
|
+
path: path.join(descriptionFileRoot, relativePath),
|
|
35
|
+
relativePath: './' + toPosix(relativePath),
|
|
36
|
+
miniprogram: true
|
|
37
|
+
})
|
|
42
38
|
|
|
43
|
-
|
|
44
|
-
const newRequest = innerRequest.replace(normalizedName, newEntry)
|
|
45
|
-
const obj = Object.assign({}, request, {
|
|
46
|
-
request: newRequest,
|
|
47
|
-
miniprogram: true
|
|
48
|
-
})
|
|
49
|
-
resolver.doResolve(target, obj, `change request ${innerRequest} to :` + newRequest, resolveContext, callback)
|
|
50
|
-
} else {
|
|
51
|
-
callback()
|
|
52
|
-
}
|
|
39
|
+
resolver.doResolve(target, obj, 'add miniprogram dist: ' + miniprogram, resolveContext, callback)
|
|
53
40
|
})
|
|
54
41
|
}
|
|
55
42
|
}
|
|
@@ -85,6 +85,10 @@
|
|
|
85
85
|
animation: {
|
|
86
86
|
type: Boolean,
|
|
87
87
|
default: true
|
|
88
|
+
},
|
|
89
|
+
speed: {
|
|
90
|
+
type: Number,
|
|
91
|
+
default: 1000
|
|
88
92
|
}
|
|
89
93
|
},
|
|
90
94
|
watch: {
|
|
@@ -96,7 +100,7 @@
|
|
|
96
100
|
if (newVal < this.bs.maxScrollX) {
|
|
97
101
|
newVal = this.bs.maxScrollX
|
|
98
102
|
}
|
|
99
|
-
this.bs.scrollTo(newVal, this.bs.y)
|
|
103
|
+
this.bs.scrollTo(newVal, this.bs.y, this.speed)
|
|
100
104
|
},
|
|
101
105
|
y (newVal) {
|
|
102
106
|
this.source = ''
|
|
@@ -106,7 +110,7 @@
|
|
|
106
110
|
if (newVal < this.bs.maxScrollY) {
|
|
107
111
|
newVal = this.bs.maxScrollY
|
|
108
112
|
}
|
|
109
|
-
this.bs.scrollTo(this.bs.x, newVal)
|
|
113
|
+
this.bs.scrollTo(this.bs.x, newVal, this.speed)
|
|
110
114
|
},
|
|
111
115
|
scaleValue (newVal) {
|
|
112
116
|
this.isZooming = true
|
|
@@ -2130,7 +2130,12 @@ function postProcessComponentIs (el) {
|
|
|
2130
2130
|
} else {
|
|
2131
2131
|
tempNode = getTempNode()
|
|
2132
2132
|
}
|
|
2133
|
+
let range = []
|
|
2134
|
+
if (el.attrsMap.range) {
|
|
2135
|
+
range = getAndRemoveAttr(el, 'range').val.split(',')
|
|
2136
|
+
}
|
|
2133
2137
|
el.components.forEach(function (component) {
|
|
2138
|
+
if (range.length > 0 && !range.includes(component)) return
|
|
2134
2139
|
let newChild = createASTElement(component, cloneAttrsList(el.attrsList), tempNode)
|
|
2135
2140
|
newChild.if = {
|
|
2136
2141
|
raw: `{{${el.is} === ${stringify(component)}}}`,
|
package/lib/utils/normalize.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
const path = require('path')
|
|
1
|
+
// const path = require('path')
|
|
2
2
|
|
|
3
|
-
exports.lib = file => path.resolve(__dirname, '../', file)
|
|
3
|
+
// exports.lib = file => path.resolve(__dirname, '../', file)
|
|
4
|
+
// support npm link debug
|
|
5
|
+
exports.lib = file => '@mpxjs/webpack-plugin/lib/' + file
|
package/lib/wxml/loader.js
CHANGED
|
@@ -99,7 +99,7 @@ module.exports = function (content) {
|
|
|
99
99
|
case config[mode].wxs.tag:
|
|
100
100
|
// 显式传递issuerResource避免模块缓存以及提供给wxs-loader计算相对路径
|
|
101
101
|
extraOptions = {
|
|
102
|
-
|
|
102
|
+
issuerResource: this.resource,
|
|
103
103
|
isStatic: true
|
|
104
104
|
}
|
|
105
105
|
requestString = getRequestString('wxs', { src, mode: localSrcMode }, extraOptions)
|
package/lib/wxss/loader.js
CHANGED
|
@@ -73,7 +73,7 @@ module.exports = function (content, map) {
|
|
|
73
73
|
} else {
|
|
74
74
|
const requestString = getRequestString('styles', { src: imp.url }, {
|
|
75
75
|
isStatic: true,
|
|
76
|
-
|
|
76
|
+
issuerResource: this.resource,
|
|
77
77
|
fromImport: true
|
|
78
78
|
}, i)
|
|
79
79
|
return 'exports.push([module.id, ' +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.8",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"engines": {
|
|
81
81
|
"node": ">=14.14.0"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "7c4e607bae13678cadc080d3303e9b432074d03e"
|
|
84
84
|
}
|