@mpxjs/webpack-plugin 2.8.28-beta.4 → 2.8.28-beta.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/index.js +46 -4
- package/lib/json-compiler/index.js +1 -8
- package/lib/loader.js +1 -1
- package/lib/parser.js +0 -1
- package/lib/platform/json/wx/index.js +2 -1
- package/lib/runtime/components/web/mpx-video.vue +15 -1
- package/lib/runtime/i18n.wxs +3 -1
- package/lib/utils/ts-loader-watch-run-loader-filter.js +3 -4
- package/lib/wxml/loader.js +6 -4
- package/lib/wxss/loader.js +3 -3
- package/package.json +9 -9
package/lib/index.js
CHANGED
|
@@ -112,7 +112,6 @@ class MpxWebpackPlugin {
|
|
|
112
112
|
constructor (options = {}) {
|
|
113
113
|
options.mode = options.mode || 'wx'
|
|
114
114
|
options.env = options.env || ''
|
|
115
|
-
|
|
116
115
|
options.srcMode = options.srcMode || options.mode
|
|
117
116
|
if (options.mode !== options.srcMode && options.srcMode !== 'wx') {
|
|
118
117
|
errors.push('MpxWebpackPlugin supports srcMode to be "wx" only temporarily!')
|
|
@@ -524,6 +523,7 @@ class MpxWebpackPlugin {
|
|
|
524
523
|
compilation.warnings = compilation.warnings.concat(warnings)
|
|
525
524
|
compilation.errors = compilation.errors.concat(errors)
|
|
526
525
|
const moduleGraph = compilation.moduleGraph
|
|
526
|
+
|
|
527
527
|
if (!compilation.__mpx__) {
|
|
528
528
|
// init mpx
|
|
529
529
|
mpx = compilation.__mpx__ = {
|
|
@@ -774,9 +774,8 @@ class MpxWebpackPlugin {
|
|
|
774
774
|
async.forEach(presentationalDependencies.filter((dep) => dep.mpxAction), (dep, callback) => {
|
|
775
775
|
dep.mpxAction(module, compilation, callback)
|
|
776
776
|
}, (err) => {
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
})
|
|
777
|
+
if (err) compilation.errors.push(err)
|
|
778
|
+
rawProcessModuleDependencies.call(compilation, module, callback)
|
|
780
779
|
})
|
|
781
780
|
}
|
|
782
781
|
|
|
@@ -1085,6 +1084,49 @@ class MpxWebpackPlugin {
|
|
|
1085
1084
|
}
|
|
1086
1085
|
})
|
|
1087
1086
|
|
|
1087
|
+
parser.hooks.evaluate.for('NewExpression').tap('MpxWebpackPlugin', (expression) => {
|
|
1088
|
+
if (/@intlify\/core-base/.test(parser.state.module.resource)) {
|
|
1089
|
+
if (expression.callee.name === 'Function') {
|
|
1090
|
+
const current = parser.state.current
|
|
1091
|
+
current.addPresentationalDependency(new InjectDependency({
|
|
1092
|
+
content: '_mpxCodeTransForm(',
|
|
1093
|
+
index: expression.arguments[0].start
|
|
1094
|
+
}))
|
|
1095
|
+
current.addPresentationalDependency(new InjectDependency({
|
|
1096
|
+
content: ')',
|
|
1097
|
+
index: expression.arguments[0].end
|
|
1098
|
+
}))
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
})
|
|
1102
|
+
|
|
1103
|
+
parser.hooks.program.tap('MpxWebpackPlugin', ast => {
|
|
1104
|
+
if (/@intlify\/core-base/.test(parser.state.module.resource)) {
|
|
1105
|
+
const current = parser.state.current
|
|
1106
|
+
current.addPresentationalDependency(new InjectDependency({
|
|
1107
|
+
content: 'function _mpxCodeTransForm (code) {\n' +
|
|
1108
|
+
' code = code.replace(/const { (.*?) } = ctx/g, function (match, $1) {\n' +
|
|
1109
|
+
' var arr = $1.split(", ")\n' +
|
|
1110
|
+
' var str = ""\n' +
|
|
1111
|
+
' var pattern = /(.*):(.*)/\n' +
|
|
1112
|
+
' for (var i = 0; i < arr.length; i++) {\n' +
|
|
1113
|
+
' var result = arr[i].match(pattern)\n' +
|
|
1114
|
+
' var left = result[1]\n' +
|
|
1115
|
+
' var right = result[2]\n' +
|
|
1116
|
+
' str += "var" + right + " = ctx." + left\n' +
|
|
1117
|
+
' }\n' +
|
|
1118
|
+
' return str\n' +
|
|
1119
|
+
' })\n' +
|
|
1120
|
+
' code = code.replace(/\\(ctx\\) =>/g, function (match, $1) {\n' +
|
|
1121
|
+
' return "function (ctx)"\n' +
|
|
1122
|
+
' })\n' +
|
|
1123
|
+
' return code\n' +
|
|
1124
|
+
'}',
|
|
1125
|
+
index: ast.end
|
|
1126
|
+
}))
|
|
1127
|
+
}
|
|
1128
|
+
})
|
|
1129
|
+
|
|
1088
1130
|
// 处理跨平台转换
|
|
1089
1131
|
if (mpx.srcMode !== mpx.mode) {
|
|
1090
1132
|
// 处理跨平台全局对象转换
|
|
@@ -98,14 +98,7 @@ module.exports = function (content) {
|
|
|
98
98
|
if (err) return callback(err)
|
|
99
99
|
if (!this._compilation) return callback()
|
|
100
100
|
const targetPath = path.relative(context, file)
|
|
101
|
-
this.
|
|
102
|
-
size: function size () {
|
|
103
|
-
return stats.size
|
|
104
|
-
},
|
|
105
|
-
source: function source () {
|
|
106
|
-
return content
|
|
107
|
-
}
|
|
108
|
-
}
|
|
101
|
+
this.emitFile(targetPath, content)
|
|
109
102
|
callback()
|
|
110
103
|
})
|
|
111
104
|
}
|
package/lib/loader.js
CHANGED
|
@@ -69,7 +69,7 @@ module.exports = function (content) {
|
|
|
69
69
|
|
|
70
70
|
if (ctorType === 'app') {
|
|
71
71
|
const appName = getEntryName(this)
|
|
72
|
-
this._module.addPresentationalDependency(new AppEntryDependency(resourcePath, appName))
|
|
72
|
+
if (appName) this._module.addPresentationalDependency(new AppEntryDependency(resourcePath, appName))
|
|
73
73
|
}
|
|
74
74
|
const loaderContext = this
|
|
75
75
|
const stringifyRequest = r => loaderUtils.stringifyRequest(loaderContext, r)
|
package/lib/parser.js
CHANGED
|
@@ -152,7 +152,8 @@ module.exports = function getSpec ({ warn, error }) {
|
|
|
152
152
|
ali: addGlobalComponents,
|
|
153
153
|
swan: addGlobalComponents,
|
|
154
154
|
qq: addGlobalComponents,
|
|
155
|
-
tt: addGlobalComponents
|
|
155
|
+
tt: addGlobalComponents,
|
|
156
|
+
jd: addGlobalComponents
|
|
156
157
|
}
|
|
157
158
|
],
|
|
158
159
|
tabBar: {
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
<video
|
|
3
3
|
ref="_mpx_video_ref"
|
|
4
4
|
:class="classList"
|
|
5
|
-
webkit-playsinline="true" playsinline="true" x5-playsinline="true"
|
|
6
5
|
:src="src"
|
|
7
6
|
:controls="showControlsTool"
|
|
8
7
|
:autoplay="autoplay"
|
|
9
8
|
:loop="loop"
|
|
10
9
|
:muted="mutedCopy"
|
|
11
10
|
:poster="poster"
|
|
11
|
+
v-bind="playsinlineAttr"
|
|
12
12
|
>
|
|
13
13
|
</video>
|
|
14
14
|
</template>
|
|
@@ -123,6 +123,20 @@
|
|
|
123
123
|
showScreenLockButton: {
|
|
124
124
|
type: Boolean,
|
|
125
125
|
default: false
|
|
126
|
+
},
|
|
127
|
+
playsinline: {
|
|
128
|
+
type: Boolean,
|
|
129
|
+
default: true
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
computed: {
|
|
133
|
+
playsinlineAttr () {
|
|
134
|
+
if (!this.playsinline) return {}
|
|
135
|
+
return {
|
|
136
|
+
'webkit-playsinline': true,
|
|
137
|
+
'playsinline': true,
|
|
138
|
+
'x5-playsinline': true
|
|
139
|
+
}
|
|
126
140
|
}
|
|
127
141
|
},
|
|
128
142
|
data () {
|
package/lib/runtime/i18n.wxs
CHANGED
|
@@ -122,7 +122,9 @@ function compile (tokens, values) {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
function interpolate (message, values) {
|
|
125
|
-
|
|
125
|
+
if (!values) {
|
|
126
|
+
return [message]
|
|
127
|
+
}
|
|
126
128
|
var tokens = _tokenCaches[message]
|
|
127
129
|
if (!tokens) {
|
|
128
130
|
tokens = parseMessage(message)
|
|
@@ -12,12 +12,11 @@ const tsLoaderWatchRunFilterLoaders = new Set([
|
|
|
12
12
|
])
|
|
13
13
|
|
|
14
14
|
module.exports = (loaders, loaderIndex) => {
|
|
15
|
-
for (let
|
|
16
|
-
const currentLoader = loaders[
|
|
15
|
+
for (let i = loaderIndex; i >= 0; i--) {
|
|
16
|
+
const currentLoader = loaders[i]
|
|
17
17
|
if (!has(tsLoaderWatchRunFilterLoaders, filterLoaderPath => currentLoader.path.endsWith(filterLoaderPath))) {
|
|
18
|
-
|
|
18
|
+
return i
|
|
19
19
|
}
|
|
20
|
-
loaderIndex--
|
|
21
20
|
}
|
|
22
21
|
return loaderIndex
|
|
23
22
|
}
|
package/lib/wxml/loader.js
CHANGED
|
@@ -6,8 +6,10 @@ const createHelpers = require('../helpers')
|
|
|
6
6
|
const isUrlRequest = require('../utils/is-url-request')
|
|
7
7
|
const parseRequest = require('../utils/parse-request')
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
let count = 0
|
|
10
|
+
|
|
11
|
+
function countIdent () {
|
|
12
|
+
return `__HTMLLINK__${count++}__`
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
module.exports = function (content) {
|
|
@@ -57,7 +59,7 @@ module.exports = function (content) {
|
|
|
57
59
|
|
|
58
60
|
let ident
|
|
59
61
|
do {
|
|
60
|
-
ident =
|
|
62
|
+
ident = countIdent()
|
|
61
63
|
} while (data[ident])
|
|
62
64
|
data[ident] = link
|
|
63
65
|
const x = content.pop()
|
|
@@ -71,7 +73,7 @@ module.exports = function (content) {
|
|
|
71
73
|
|
|
72
74
|
const exportsString = 'module.exports = '
|
|
73
75
|
|
|
74
|
-
return exportsString + content.replace(/
|
|
76
|
+
return exportsString + content.replace(/__HTMLLINK__\d+__/g, (match) => {
|
|
75
77
|
if (!data[match]) return match
|
|
76
78
|
|
|
77
79
|
const link = data[match]
|
package/lib/wxss/loader.js
CHANGED
|
@@ -223,18 +223,18 @@ module.exports = async function loader (content, map, meta) {
|
|
|
223
223
|
imports.unshift({
|
|
224
224
|
type: 'api_import',
|
|
225
225
|
importName: '___CSS_LOADER_API_IMPORT___',
|
|
226
|
-
url: stringifyRequest(this, require.resolve('./runtime/api'))
|
|
226
|
+
url: stringifyRequest(this, '!!' + require.resolve('./runtime/api'))
|
|
227
227
|
})
|
|
228
228
|
|
|
229
229
|
if (options.sourceMap) {
|
|
230
230
|
imports.unshift({
|
|
231
231
|
importName: '___CSS_LOADER_API_SOURCEMAP_IMPORT___',
|
|
232
|
-
url: stringifyRequest(this, require.resolve('./runtime/sourceMaps'))
|
|
232
|
+
url: stringifyRequest(this, '!!' + require.resolve('./runtime/sourceMaps'))
|
|
233
233
|
})
|
|
234
234
|
} else {
|
|
235
235
|
imports.unshift({
|
|
236
236
|
importName: '___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___',
|
|
237
|
-
url: stringifyRequest(this, require.resolve('./runtime/noSourceMaps'))
|
|
237
|
+
url: stringifyRequest(this, '!!' + require.resolve('./runtime/noSourceMaps'))
|
|
238
238
|
})
|
|
239
239
|
}
|
|
240
240
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.8.28-beta.
|
|
3
|
+
"version": "2.8.28-beta.8",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"@babel/parser": "^7.16.2",
|
|
21
21
|
"@babel/traverse": "^7.16.0",
|
|
22
22
|
"@babel/types": "^7.16.0",
|
|
23
|
-
"@better-scroll/core": "^2.
|
|
24
|
-
"@better-scroll/movable": "^2.
|
|
25
|
-
"@better-scroll/observe-dom": "^2.
|
|
26
|
-
"@better-scroll/pull-down": "^2.
|
|
27
|
-
"@better-scroll/slide": "^2.
|
|
28
|
-
"@better-scroll/wheel": "^2.
|
|
29
|
-
"@better-scroll/zoom": "^2.
|
|
23
|
+
"@better-scroll/core": "^2.5.1",
|
|
24
|
+
"@better-scroll/movable": "^2.5.1",
|
|
25
|
+
"@better-scroll/observe-dom": "^2.5.1",
|
|
26
|
+
"@better-scroll/pull-down": "^2.5.1",
|
|
27
|
+
"@better-scroll/slide": "^2.5.1",
|
|
28
|
+
"@better-scroll/wheel": "^2.5.1",
|
|
29
|
+
"@better-scroll/zoom": "^2.5.1",
|
|
30
30
|
"acorn-walk": "^7.2.0",
|
|
31
31
|
"async": "^2.6.0",
|
|
32
32
|
"consolidate": "^0.15.1",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=14.14.0"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "d220fb8a2e9c090de490a125891262f61802f73d"
|
|
86
86
|
}
|