@mpxjs/webpack-plugin 2.8.28-beta.5 → 2.8.28-beta.9

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 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!')
@@ -521,8 +520,8 @@ class MpxWebpackPlugin {
521
520
  })
522
521
 
523
522
  compiler.hooks.thisCompilation.tap('MpxWebpackPlugin', (compilation, { normalModuleFactory }) => {
524
- compilation.warnings = compilation.warnings.concat(warnings)
525
- compilation.errors = compilation.errors.concat(errors)
523
+ compilation.warnings.push(...warnings)
524
+ compilation.errors.push(...errors)
526
525
  const moduleGraph = compilation.moduleGraph
527
526
 
528
527
  if (!compilation.__mpx__) {
@@ -772,10 +771,14 @@ class MpxWebpackPlugin {
772
771
  const rawProcessModuleDependencies = compilation.processModuleDependencies
773
772
  compilation.processModuleDependencies = (module, callback) => {
774
773
  const presentationalDependencies = module.presentationalDependencies || []
774
+ const errors = []
775
775
  async.forEach(presentationalDependencies.filter((dep) => dep.mpxAction), (dep, callback) => {
776
- dep.mpxAction(module, compilation, callback)
777
- }, (err) => {
778
- if (err) compilation.errors.push(err)
776
+ dep.mpxAction(module, compilation, (err) => {
777
+ if (err) errors.push(err)
778
+ callback()
779
+ })
780
+ }, () => {
781
+ compilation.errors.push(...errors)
779
782
  rawProcessModuleDependencies.call(compilation, module, callback)
780
783
  })
781
784
  }
@@ -861,16 +864,17 @@ class MpxWebpackPlugin {
861
864
  }
862
865
 
863
866
  // hack process https://github.com/webpack/webpack/issues/16045
864
- const _handleModuleBuildAndDependenciesRaw = compilation._handleModuleBuildAndDependencies
865
-
866
- compilation._handleModuleBuildAndDependencies = (originModule, module, recursive, callback) => {
867
- const rawCallback = callback
868
- callback = (err) => {
869
- if (err) return rawCallback(err)
870
- return rawCallback(null, module)
871
- }
872
- return _handleModuleBuildAndDependenciesRaw.call(compilation, originModule, module, recursive, callback)
873
- }
867
+ // no need anymore
868
+ // const _handleModuleBuildAndDependenciesRaw = compilation._handleModuleBuildAndDependencies
869
+ //
870
+ // compilation._handleModuleBuildAndDependencies = (originModule, module, recursive, callback) => {
871
+ // const rawCallback = callback
872
+ // callback = (err) => {
873
+ // if (err) return rawCallback(err)
874
+ // return rawCallback(null, module)
875
+ // }
876
+ // return _handleModuleBuildAndDependenciesRaw.call(compilation, originModule, module, recursive, callback)
877
+ // }
874
878
 
875
879
  const rawEmitAsset = compilation.emitAsset
876
880
 
@@ -1085,6 +1089,49 @@ class MpxWebpackPlugin {
1085
1089
  }
1086
1090
  })
1087
1091
 
1092
+ parser.hooks.evaluate.for('NewExpression').tap('MpxWebpackPlugin', (expression) => {
1093
+ if (/@intlify\/core-base/.test(parser.state.module.resource)) {
1094
+ if (expression.callee.name === 'Function') {
1095
+ const current = parser.state.current
1096
+ current.addPresentationalDependency(new InjectDependency({
1097
+ content: '_mpxCodeTransForm(',
1098
+ index: expression.arguments[0].start
1099
+ }))
1100
+ current.addPresentationalDependency(new InjectDependency({
1101
+ content: ')',
1102
+ index: expression.arguments[0].end
1103
+ }))
1104
+ }
1105
+ }
1106
+ })
1107
+
1108
+ parser.hooks.program.tap('MpxWebpackPlugin', ast => {
1109
+ if (/@intlify\/core-base/.test(parser.state.module.resource)) {
1110
+ const current = parser.state.current
1111
+ current.addPresentationalDependency(new InjectDependency({
1112
+ content: 'function _mpxCodeTransForm (code) {\n' +
1113
+ ' code = code.replace(/const { (.*?) } = ctx/g, function (match, $1) {\n' +
1114
+ ' var arr = $1.split(", ")\n' +
1115
+ ' var str = ""\n' +
1116
+ ' var pattern = /(.*):(.*)/\n' +
1117
+ ' for (var i = 0; i < arr.length; i++) {\n' +
1118
+ ' var result = arr[i].match(pattern)\n' +
1119
+ ' var left = result[1]\n' +
1120
+ ' var right = result[2]\n' +
1121
+ ' str += "var" + right + " = ctx." + left\n' +
1122
+ ' }\n' +
1123
+ ' return str\n' +
1124
+ ' })\n' +
1125
+ ' code = code.replace(/\\(ctx\\) =>/g, function (match, $1) {\n' +
1126
+ ' return "function (ctx)"\n' +
1127
+ ' })\n' +
1128
+ ' return code\n' +
1129
+ '}',
1130
+ index: ast.end
1131
+ }))
1132
+ }
1133
+ })
1134
+
1088
1135
  // 处理跨平台转换
1089
1136
  if (mpx.srcMode !== mpx.mode) {
1090
1137
  // 处理跨平台全局对象转换
package/lib/parser.js CHANGED
@@ -2,7 +2,6 @@ const cache = require('lru-cache')(100)
2
2
  const hash = require('hash-sum')
3
3
  const compiler = require('./template-compiler/compiler')
4
4
  const SourceMapGenerator = require('source-map').SourceMapGenerator
5
-
6
5
  const splitRE = /\r?\n/g
7
6
  const emptyRE = /^(?:\/\/)?\s*$/
8
7
 
@@ -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 () {
@@ -122,7 +122,9 @@ function compile (tokens, values) {
122
122
  }
123
123
 
124
124
  function interpolate (message, values) {
125
- values = values || {}
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 len = loaders.length; len > 0; --len) {
16
- const currentLoader = loaders[len - 1]
15
+ for (let i = loaderIndex; i >= 0; i--) {
16
+ const currentLoader = loaders[i]
17
17
  if (!has(tsLoaderWatchRunFilterLoaders, filterLoaderPath => currentLoader.path.endsWith(filterLoaderPath))) {
18
- break
18
+ return i
19
19
  }
20
- loaderIndex--
21
20
  }
22
21
  return loaderIndex
23
22
  }
@@ -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
- function randomIdent () {
10
- return 'xxxHTMLLINKxxx' + Math.random() + Math.random() + 'xxx'
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 = randomIdent()
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(/xxxHTMLLINKxxx[0-9.]+xxx/g, (match) => {
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.8.28-beta.5",
3
+ "version": "2.8.28-beta.9",
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": "f415e2d6a1c14b51b2cee6eb654205608f217401"
85
+ "gitHead": "ec2c3c67a3ef40485941c30bbb260138602d01a1"
86
86
  }