@mpxjs/webpack-plugin 2.9.0-beta.0 → 2.9.0-beta.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.
Files changed (40) hide show
  1. package/lib/dependencies/DynamicEntryDependency.js +10 -16
  2. package/lib/dependencies/ResolveDependency.js +11 -9
  3. package/lib/index.js +88 -34
  4. package/lib/json-compiler/default-page.mpx +3 -0
  5. package/lib/json-compiler/helper.js +22 -7
  6. package/lib/json-compiler/index.js +74 -26
  7. package/lib/loader.js +2 -9
  8. package/lib/native-loader.js +3 -8
  9. package/lib/parser.js +0 -1
  10. package/lib/platform/json/wx/index.js +21 -0
  11. package/lib/platform/template/wx/component-config/component.js +1 -2
  12. package/lib/platform/template/wx/component-config/hypen-tag-name.js +2 -6
  13. package/lib/platform/template/wx/component-config/index.js +2 -2
  14. package/lib/platform/template/wx/index.js +12 -14
  15. package/lib/runtime/base.styl +0 -5
  16. package/lib/runtime/components/web/getInnerListeners.js +16 -2
  17. package/lib/runtime/components/web/mpx-checkbox-group.vue +1 -1
  18. package/lib/runtime/components/web/mpx-form.vue +2 -2
  19. package/lib/runtime/components/web/mpx-image.vue +11 -15
  20. package/lib/runtime/components/web/mpx-movable-view.vue +3 -3
  21. package/lib/runtime/components/web/mpx-picker-view.vue +5 -5
  22. package/lib/runtime/components/web/mpx-picker.vue +3 -3
  23. package/lib/runtime/components/web/mpx-progress.vue +3 -1
  24. package/lib/runtime/components/web/mpx-radio-group.vue +1 -1
  25. package/lib/runtime/components/web/mpx-scroll-view.vue +17 -13
  26. package/lib/runtime/components/web/mpx-slider.vue +4 -4
  27. package/lib/runtime/components/web/mpx-swiper.vue +3 -3
  28. package/lib/runtime/components/web/mpx-switch.vue +1 -1
  29. package/lib/runtime/components/web/mpx-video.vue +14 -28
  30. package/lib/runtime/components/web/mpx-web-view.vue +4 -4
  31. package/lib/runtime/optionProcessor.js +23 -18
  32. package/lib/runtime/stringify.wxs +44 -8
  33. package/lib/style-compiler/index.js +3 -1
  34. package/lib/template-compiler/compiler.js +73 -50
  35. package/lib/utils/ts-loader-watch-run-loader-filter.js +4 -18
  36. package/lib/wxss/runtime/api.js +18 -19
  37. package/lib/wxss/runtime/noSourceMaps.js +3 -1
  38. package/lib/wxss/runtime/sourceMaps.js +8 -7
  39. package/package.json +3 -3
  40. package/lib/partial-compile/index.js +0 -35
@@ -3,7 +3,19 @@ import { isBrowser } from './env'
3
3
  import transRpxStyle from './transRpxStyle'
4
4
  import animation from './animation'
5
5
 
6
- export default function processComponentOption ({ option, ctorType, outputPath, pageConfig, componentsMap, componentGenerics, genericsInfo, mixin, hasApp }) {
6
+ export default function processComponentOption (
7
+ {
8
+ option,
9
+ ctorType,
10
+ outputPath,
11
+ pageConfig,
12
+ componentsMap,
13
+ componentGenerics,
14
+ genericsInfo,
15
+ mixin,
16
+ hasApp
17
+ }
18
+ ) {
7
19
  // 局部注册页面和组件中依赖的组件
8
20
  for (const componentName in componentsMap) {
9
21
  if (hasOwn(componentsMap, componentName)) {
@@ -128,6 +140,7 @@ function createApp ({ componentsMap, Vue, pagesMap, firstPage, VueRouter, App, t
128
140
  global.__mpxRouter.stack = []
129
141
  global.__mpxRouter.needCache = null
130
142
  global.__mpxRouter.needRemove = []
143
+ global.__mpxRouter.eventChannelMap = {}
131
144
  // 处理reLaunch中传递的url并非首页时的replace逻辑
132
145
  global.__mpxRouter.beforeEach(function (to, from, next) {
133
146
  let action = global.__mpxRouter.__mpxAction
@@ -166,24 +179,15 @@ function createApp ({ componentsMap, Vue, pagesMap, firstPage, VueRouter, App, t
166
179
  })
167
180
  }
168
181
  } else {
169
- let methods = ''
170
- switch (action.type) {
171
- case 'to':
172
- methods = 'navigateTo'
173
- break
174
- case 'redirect':
175
- methods = 'redirectTo'
176
- break
177
- case 'back':
178
- methods = 'navigateBack'
179
- break
180
- case 'reLaunch':
181
- methods = 'reLaunch'
182
- break
183
- default:
184
- methods = 'navigateTo'
182
+ const typeMethodMap = {
183
+ to: 'navigateTo',
184
+ redirect: 'redirectTo',
185
+ back: 'navigateBack',
186
+ switch: 'switchTab',
187
+ reLaunch: 'reLaunch'
185
188
  }
186
- throw new Error(`${methods}:fail page "${to.path}" is not found`)
189
+ const method = typeMethodMap[action.type]
190
+ throw new Error(`${method}:fail page "${to.path}" is not found`)
187
191
  }
188
192
  }
189
193
 
@@ -195,6 +199,7 @@ function createApp ({ componentsMap, Vue, pagesMap, firstPage, VueRouter, App, t
195
199
  case 'to':
196
200
  stack.push(insertItem)
197
201
  global.__mpxRouter.needCache = insertItem
202
+ if (action.eventChannel) global.__mpxRouter.eventChannelMap[to.path.slice(1)] = action.eventChannel
198
203
  break
199
204
  case 'back':
200
205
  global.__mpxRouter.needRemove = stack.splice(stack.length - action.delta, action.delta)
@@ -24,8 +24,9 @@ function objectKeys (obj) {
24
24
  var shift = false
25
25
  for (var i = 1; i < objStr.length - 1; i++) {
26
26
  var item = objStr[i]
27
+ var lastItem = objStr[i - 1]
27
28
  if (inKey) {
28
- if (item === ':') {
29
+ if (item === ':' && lastItem === '"') {
29
30
  keys.push(key.slice(1, -1))
30
31
  key = ''
31
32
  inKey = false
@@ -93,18 +94,53 @@ function isDef (v) {
93
94
  return v !== undefined && v !== null
94
95
  }
95
96
 
97
+ var escapeMap = {
98
+ '(': '_pl_',
99
+ ')': '_pr_',
100
+ '[': '_bl_',
101
+ ']': '_br_',
102
+ '{': '_cl_',
103
+ '#': '_h_',
104
+ '!': '_i_',
105
+ '/': '_s_',
106
+ '.': '_d_',
107
+ ':': '_c_',
108
+ ',': '_2c_',
109
+ '%': '_p_',
110
+ // wxs can not use '\'' as key
111
+ // wxs环境中'\''!=="'",此文件不能格式化,否则会导致程序错误
112
+ "'": '_q_',
113
+ // wxs can not use '"' as key
114
+ '"': '_dq_',
115
+ '+': '_a_',
116
+ '$': '_si_'
117
+ }
118
+
119
+ var escapeReg = genRegExp('[()[\]{}#!/.:,%\'"+$]', 'g')
120
+
121
+ function mpEscape (str) {
122
+ return str.replace(escapeReg, function (match) {
123
+ if (escapeMap[match]) return escapeMap[match]
124
+ // fix wxs can not use '}' as key
125
+ if (match === '}') return '_cr_'
126
+ // unknown escaped
127
+ return '_u_'
128
+ })
129
+ }
130
+
131
+
96
132
  function stringifyDynamicClass (value) {
97
- if (!value) return ''
98
133
  if (isArray(value)) {
99
- return stringifyArray(value)
100
- }
101
- if (isObject(value)) {
102
- return stringifyObject(value)
134
+ value = stringifyArray(value)
135
+ } else if (isObject(value)) {
136
+ value = stringifyObject(value)
103
137
  }
138
+
104
139
  if (typeof value === 'string') {
105
- return value
140
+ return mpEscape(value)
141
+ } else {
142
+ return ''
106
143
  }
107
- return ''
108
144
  }
109
145
 
110
146
  function stringifyArray (value) {
@@ -30,7 +30,7 @@ module.exports = function (css, map) {
30
30
 
31
31
  const inlineConfig = Object.assign({}, mpx.postcssInlineConfig, { defs })
32
32
  loadPostcssConfig(this, inlineConfig).then(config => {
33
- const plugins = config.plugins.concat(trim)
33
+ const plugins = [trim] // init with trim plugin
34
34
  const options = Object.assign(
35
35
  {
36
36
  to: this.resourcePath,
@@ -79,6 +79,8 @@ module.exports = function (css, map) {
79
79
  }
80
80
  }
81
81
 
82
+ plugins.push(...config.plugins) // push user config plugins
83
+
82
84
  return postcss(plugins)
83
85
  .process(css, options)
84
86
  .then(result => {
@@ -762,7 +762,7 @@ function parse (template, options) {
762
762
  },
763
763
  comment: function comment (text) {
764
764
  if (!currentParent) genTempRoot()
765
- if (options.hasComment) {
765
+ if (options.hasComment || /mpx_config_/.test(text)) {
766
766
  currentParent.children.push({
767
767
  type: 3,
768
768
  text: text,
@@ -967,7 +967,7 @@ function processComponentIs (el, options) {
967
967
 
968
968
  const is = getAndRemoveAttr(el, 'is').val
969
969
  if (is) {
970
- el.is = parseMustache(is).result
970
+ el.is = parseMustacheWithContext(is).result
971
971
  } else {
972
972
  warn$1('<component> tag should have attrs[is].')
973
973
  }
@@ -979,7 +979,7 @@ function parseFuncStr2 (str) {
979
979
  const funcRE = /^([^()]+)(\((.*)\))?/
980
980
  const match = funcRE.exec(str)
981
981
  if (match) {
982
- const funcName = parseMustache(match[1]).result
982
+ const funcName = parseMustacheWithContext(match[1]).result
983
983
  const hasArgs = !!match[2]
984
984
  let args = match[3] ? `,${match[3]}` : ''
985
985
  const ret = /(,|^)\s*(\$event)\s*(,|$)/.exec(args)
@@ -1163,19 +1163,9 @@ function wrapMustache (val) {
1163
1163
  return val && !tagRE.test(val) ? `{{${val}}}` : val
1164
1164
  }
1165
1165
 
1166
- function parseMustache (raw = '') {
1167
- let replaced = false
1168
- if (tagRE.test(raw)) {
1169
- const ret = []
1170
- let lastLastIndex = 0
1171
- let match
1172
- while (match = tagREG.exec(raw)) {
1173
- const pre = raw.substring(lastLastIndex, match.index)
1174
- if (pre) {
1175
- ret.push(stringify(pre))
1176
- }
1177
- let exp = match[1]
1178
-
1166
+ function parseMustacheWithContext (raw = '') {
1167
+ return parseMustache(raw, (exp) => {
1168
+ if (defs) {
1179
1169
  // eval处理的话,和别的判断条件,比如运行时的判断混用情况下得不到一个结果,还是正则替换
1180
1170
  const defKeys = Object.keys(defs)
1181
1171
  defKeys.forEach((defKey) => {
@@ -1183,42 +1173,70 @@ function parseMustache (raw = '') {
1183
1173
  const defREG = new RegExp(`\\b${defKey}\\b`, 'g')
1184
1174
  if (defRE.test(exp)) {
1185
1175
  exp = exp.replace(defREG, stringify(defs[defKey]))
1186
- replaced = true
1187
1176
  }
1188
1177
  })
1178
+ }
1189
1179
 
1190
- if (i18n) {
1191
- for (const i18nFuncName of i18nFuncNames) {
1192
- const funcNameRE = new RegExp(`(?<![A-Za-z0-9_$.])${i18nFuncName}\\(`)
1193
- const funcNameREG = new RegExp(`(?<![A-Za-z0-9_$.])${i18nFuncName}\\(`, 'g')
1194
- if (funcNameRE.test(exp)) {
1195
- if (i18n.useComputed || !i18nFuncName.startsWith('\\$')) {
1196
- const i18nInjectComputedKey = `_i${i18nInjectableComputed.length + 1}`
1197
- i18nInjectableComputed.push(`${i18nInjectComputedKey} () {\nreturn ${exp.trim()}}`)
1198
- exp = i18nInjectComputedKey
1199
- } else {
1200
- exp = exp.replace(funcNameREG, `${i18nModuleName}.$1(null, _l, _fl, `)
1201
- }
1202
- hasI18n = true
1203
- replaced = true
1204
- break
1180
+ if (i18n) {
1181
+ for (const i18nFuncName of i18nFuncNames) {
1182
+ const funcNameRE = new RegExp(`(?<![A-Za-z0-9_$.])${i18nFuncName}\\(`)
1183
+ const funcNameREG = new RegExp(`(?<![A-Za-z0-9_$.])${i18nFuncName}\\(`, 'g')
1184
+ if (funcNameRE.test(exp)) {
1185
+ if (i18n.useComputed || !i18nFuncName.startsWith('\\$')) {
1186
+ const i18nInjectComputedKey = `_i${i18nInjectableComputed.length + 1}`
1187
+ i18nInjectableComputed.push(`${i18nInjectComputedKey} () {\nreturn ${exp.trim()}}`)
1188
+ exp = i18nInjectComputedKey
1189
+ } else {
1190
+ exp = exp.replace(funcNameREG, `${i18nModuleName}.$1(null, _l, _fl, `)
1205
1191
  }
1192
+ hasI18n = true
1193
+ break
1206
1194
  }
1207
1195
  }
1196
+ }
1197
+
1198
+ return exp
1199
+ })
1200
+ }
1201
+
1202
+ function parseMustache (raw = '', expHandler = exp => exp, strHandler = str => str) {
1203
+ let replaced = false
1204
+ if (tagRE.test(raw)) {
1205
+ const ret = []
1206
+ let lastLastIndex = 0
1207
+ let match
1208
+ while (match = tagREG.exec(raw)) {
1209
+ const pre = raw.substring(lastLastIndex, match.index)
1210
+ if (pre) {
1211
+ const pre2 = strHandler(pre)
1212
+ if (pre2 !== pre) replaced = true
1213
+ if (pre2) ret.push(stringify(pre2))
1214
+ }
1215
+
1216
+ const exp = match[1].trim()
1217
+ if (exp) {
1218
+ const exp2 = expHandler(exp)
1219
+ if (exp2 !== exp) replaced = true
1220
+ if (exp2) ret.push(`(${exp2})`)
1221
+ }
1208
1222
 
1209
- ret.push(`(${exp.trim()})`)
1210
1223
  lastLastIndex = tagREG.lastIndex
1211
1224
  }
1225
+
1212
1226
  const post = raw.substring(lastLastIndex)
1213
1227
  if (post) {
1214
- ret.push(stringify(post))
1228
+ const post2 = strHandler(post)
1229
+ if (post2 !== post) replaced = true
1230
+ if (post2) ret.push(stringify(post2))
1215
1231
  }
1232
+
1216
1233
  let result
1217
1234
  if (ret.length === 1) {
1218
1235
  result = ret[0]
1219
1236
  } else {
1220
1237
  result = `(${ret.join('+')})`
1221
1238
  }
1239
+
1222
1240
  return {
1223
1241
  result,
1224
1242
  hasBinding: true,
@@ -1226,10 +1244,14 @@ function parseMustache (raw = '') {
1226
1244
  replaced
1227
1245
  }
1228
1246
  }
1247
+
1248
+ const raw2 = strHandler(raw)
1249
+ if (raw2 !== raw) replaced = true
1250
+
1229
1251
  return {
1230
- result: stringify(raw),
1252
+ result: stringify(raw2),
1231
1253
  hasBinding: false,
1232
- val: raw,
1254
+ val: raw2,
1233
1255
  replaced
1234
1256
  }
1235
1257
  }
@@ -1247,14 +1269,14 @@ function processIf (el) {
1247
1269
  let val = getAndRemoveAttr(el, config[mode].directive.if).val
1248
1270
  if (val) {
1249
1271
  if (mode === 'swan') val = wrapMustache(val)
1250
- const parsed = parseMustache(val)
1272
+ const parsed = parseMustacheWithContext(val)
1251
1273
  el.if = {
1252
1274
  raw: parsed.val,
1253
1275
  exp: parsed.result
1254
1276
  }
1255
1277
  } else if (val = getAndRemoveAttr(el, config[mode].directive.elseif).val) {
1256
1278
  if (mode === 'swan') val = wrapMustache(val)
1257
- const parsed = parseMustache(val)
1279
+ const parsed = parseMustacheWithContext(val)
1258
1280
  el.elseif = {
1259
1281
  raw: parsed.val,
1260
1282
  exp: parsed.result
@@ -1296,7 +1318,7 @@ function processFor (el) {
1296
1318
  }
1297
1319
  } else {
1298
1320
  if (mode === 'swan') val = wrapMustache(val)
1299
- const parsed = parseMustache(val)
1321
+ const parsed = parseMustacheWithContext(val)
1300
1322
  el.for = {
1301
1323
  raw: parsed.val,
1302
1324
  exp: parsed.result
@@ -1408,14 +1430,14 @@ function processAttrs (el, options) {
1408
1430
  const isTemplateData = el.tag === 'template' && attr.name === 'data'
1409
1431
  const needWrap = isTemplateData && mode !== 'swan'
1410
1432
  const value = needWrap ? `{${attr.value}}` : attr.value
1411
- const parsed = parseMustache(value)
1433
+ const parsed = parseMustacheWithContext(value)
1412
1434
  if (parsed.hasBinding) {
1413
1435
  // 该属性判断用于提供给运行时对于计算属性作为props传递时提出警告
1414
1436
  const isProps = isComponentNode(el, options) && !(attr.name === 'class' || attr.name === 'style')
1415
1437
  addExp(el, parsed.result, isProps)
1416
- }
1417
- if (parsed.replaced) {
1418
- modifyAttr(el, attr.name, needWrap ? parsed.val.slice(1, -1) : parsed.val)
1438
+ if (parsed.replaced) {
1439
+ modifyAttr(el, attr.name, needWrap ? parsed.val.slice(1, -1) : parsed.val)
1440
+ }
1419
1441
  }
1420
1442
  })
1421
1443
  }
@@ -1547,7 +1569,7 @@ function processText (el) {
1547
1569
  if (el.type !== 3 || el.isComment) {
1548
1570
  return
1549
1571
  }
1550
- const parsed = parseMustache(el.text)
1572
+ const parsed = parseMustacheWithContext(el.text)
1551
1573
  if (parsed.hasBinding) {
1552
1574
  addExp(el, parsed.result)
1553
1575
  }
@@ -1592,8 +1614,8 @@ function processClass (el, meta) {
1592
1614
  let staticClass = getAndRemoveAttr(el, type).val || ''
1593
1615
  staticClass = staticClass.replace(/\s+/g, ' ')
1594
1616
  if (dynamicClass) {
1595
- const staticClassExp = parseMustache(staticClass).result
1596
- const dynamicClassExp = transDynamicClassExpr(parseMustache(dynamicClass).result, {
1617
+ const staticClassExp = parseMustacheWithContext(staticClass).result
1618
+ const dynamicClassExp = transDynamicClassExpr(parseMustacheWithContext(dynamicClass).result, {
1597
1619
  error: error$1
1598
1620
  })
1599
1621
  addAttrs(el, [{
@@ -1628,8 +1650,8 @@ function processStyle (el, meta) {
1628
1650
  let staticStyle = getAndRemoveAttr(el, type).val || ''
1629
1651
  staticStyle = staticStyle.replace(/\s+/g, ' ')
1630
1652
  if (dynamicStyle) {
1631
- const staticStyleExp = parseMustache(staticStyle).result
1632
- const dynamicStyleExp = parseMustache(dynamicStyle).result
1653
+ const staticStyleExp = parseMustacheWithContext(staticStyle).result
1654
+ const dynamicStyleExp = parseMustacheWithContext(dynamicStyle).result
1633
1655
  addAttrs(el, [{
1634
1656
  name: targetType,
1635
1657
  value: `{{${stringifyModuleName}.stringifyStyle(${staticStyleExp}, ${dynamicStyleExp})}}`
@@ -1870,7 +1892,7 @@ function processShow (el, options, root) {
1870
1892
  if (options.hasVirtualHost) {
1871
1893
  if (options.isComponent && el.parent === root && isRealNode(el)) {
1872
1894
  if (show !== undefined) {
1873
- show = `{{${parseMustache(show).result}&&mpxShow}}`
1895
+ show = `{{${parseMustacheWithContext(show).result}&&mpxShow}}`
1874
1896
  } else {
1875
1897
  show = '{{mpxShow}}'
1876
1898
  }
@@ -1892,7 +1914,7 @@ function processShow (el, options, root) {
1892
1914
 
1893
1915
  function processShowStyle () {
1894
1916
  if (show !== undefined) {
1895
- const showExp = parseMustache(show).result
1917
+ const showExp = parseMustacheWithContext(show).result
1896
1918
  let oldStyle = getAndRemoveAttr(el, 'style').val
1897
1919
  oldStyle = oldStyle ? oldStyle + ';' : ''
1898
1920
  addAttrs(el, [{
@@ -2376,6 +2398,7 @@ module.exports = {
2376
2398
  makeAttrsMap,
2377
2399
  stringifyAttr,
2378
2400
  parseMustache,
2401
+ parseMustacheWithContext,
2379
2402
  stringifyWithResolveComputed,
2380
2403
  addAttrs
2381
2404
  }
@@ -1,23 +1,9 @@
1
- const normalize = require('./normalize')
2
- const selectorPath = normalize.lib('selector.js')
3
- const scriptSetupPath = normalize.lib('script-setup-compiler/index.js')
4
- const mpxLoaderPath = normalize.lib('loader.js')
5
- const { has } = require('./set')
6
-
7
- const tsLoaderWatchRunFilterLoaders = new Set([
8
- selectorPath,
9
- scriptSetupPath,
10
- mpxLoaderPath,
11
- 'node_modules/vue-loader/lib/index.js'
12
- ])
13
-
14
1
  module.exports = (loaders, loaderIndex) => {
15
- for (let len = loaders.length; len > 0; --len) {
16
- const currentLoader = loaders[len - 1]
17
- if (!has(tsLoaderWatchRunFilterLoaders, filterLoaderPath => currentLoader.path.endsWith(filterLoaderPath))) {
18
- break
2
+ for (let i = loaderIndex; i >= 0; i--) {
3
+ const currentLoader = loaders[i]
4
+ if (currentLoader.path.endsWith('ts-loader/dist/stringify-loader.js')) {
5
+ return i
19
6
  }
20
- loaderIndex--
21
7
  }
22
8
  return loaderIndex
23
9
  }
@@ -2,26 +2,27 @@
2
2
  MIT License http://www.opensource.org/licenses/mit-license.php
3
3
  Author Tobias Koppers @sokra
4
4
  */
5
- module.exports = (cssWithMappingToString) => {
6
- const list = []
5
+ /* eslint no-var: off */
6
+ module.exports = function (cssWithMappingToString) {
7
+ var list = []
7
8
 
8
9
  // return the list of modules as css string
9
10
  list.toString = function toString () {
10
- return this.map((item) => {
11
- let content = ''
11
+ return this.map(function (item) {
12
+ var content = ''
12
13
 
13
- const needLayer = typeof item[5] !== 'undefined'
14
+ var needLayer = typeof item[5] !== 'undefined'
14
15
 
15
16
  if (item[4]) {
16
- content += `@supports (${item[4]}) {`
17
+ content += '@supports (' + item[4] + ') {'
17
18
  }
18
19
 
19
20
  if (item[2]) {
20
- content += `@media ${item[2]} {`
21
+ content += '@media ' + item[2] + '{'
21
22
  }
22
23
 
23
24
  if (needLayer) {
24
- content += `@layer${item[5].length > 0 ? ` ${item[5]}` : ''} {`
25
+ content += '@layer' + (item[5].length > 0 ? item[5] : '') + '{'
25
26
  }
26
27
 
27
28
  content += cssWithMappingToString(item)
@@ -48,11 +49,11 @@ module.exports = (cssWithMappingToString) => {
48
49
  modules = [[null, modules, undefined]]
49
50
  }
50
51
 
51
- const alreadyImportedModules = {}
52
+ var alreadyImportedModules = {}
52
53
 
53
54
  if (dedupe) {
54
- for (let k = 0; k < this.length; k++) {
55
- const id = this[k][0]
55
+ for (var k = 0; k < this.length; k++) {
56
+ var id = this[k][0]
56
57
 
57
58
  if (id != null) {
58
59
  alreadyImportedModules[id] = true
@@ -60,8 +61,8 @@ module.exports = (cssWithMappingToString) => {
60
61
  }
61
62
  }
62
63
 
63
- for (let k = 0; k < modules.length; k++) {
64
- const item = [].concat(modules[k])
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
@@ -71,9 +72,7 @@ module.exports = (cssWithMappingToString) => {
71
72
  if (typeof item[5] === 'undefined') {
72
73
  item[5] = layer
73
74
  } else {
74
- item[1] = `@layer${item[5].length > 0 ? ` ${item[5]}` : ''} {${
75
- item[1]
76
- }}`
75
+ item[1] = '@layer' + (item[5].length > 0 ? item[5] : '') + '{' + item[1] + '}'
77
76
  item[5] = layer
78
77
  }
79
78
  }
@@ -82,16 +81,16 @@ module.exports = (cssWithMappingToString) => {
82
81
  if (!item[2]) {
83
82
  item[2] = media
84
83
  } else {
85
- item[1] = `@media ${item[2]} {${item[1]}}`
84
+ item[1] = '@media' + item[2] + item[1]
86
85
  item[2] = media
87
86
  }
88
87
  }
89
88
 
90
89
  if (supports) {
91
90
  if (!item[4]) {
92
- item[4] = `${supports}`
91
+ item[4] = String(supports)
93
92
  } else {
94
- item[1] = `@supports (${item[4]}) {${item[1]}}`
93
+ item[1] = '@supports (' + item[4] + ')' + '{' + item[1] + '}'
95
94
  item[4] = supports
96
95
  }
97
96
  }
@@ -1 +1,3 @@
1
- module.exports = (i) => i[1]
1
+ module.exports = function (i) {
2
+ return i[1]
3
+ }
@@ -1,6 +1,7 @@
1
- module.exports = (item) => {
2
- const content = item[1]
3
- const cssMapping = item[3]
1
+ /* eslint no-var: off */
2
+ module.exports = function (item) {
3
+ var content = item[1]
4
+ var cssMapping = item[3]
4
5
 
5
6
  if (!cssMapping) {
6
7
  return content
@@ -8,13 +9,13 @@ module.exports = (item) => {
8
9
 
9
10
  if (typeof btoa === 'function') {
10
11
  // eslint-disable-next-line no-undef
11
- const base64 = btoa(
12
+ var base64 = btoa(
12
13
  unescape(encodeURIComponent(JSON.stringify(cssMapping)))
13
14
  )
14
- const data = `sourceMappingURL=data:application/json;charset=utf-8;base64,${base64}`
15
- const sourceMapping = `/*# ${data} */`
15
+ var data = `sourceMappingURL=data:application/json;charset=utf-8;base64,${base64}`
16
+ var sourceMapping = `/*# ${data} */`
16
17
 
17
- const sourceURLs = cssMapping.sources.map(
18
+ var sourceURLs = cssMapping.sources.map(
18
19
  (source) => `/*# sourceURL=${cssMapping.sourceRoot || ''}${source} */`
19
20
  )
20
21
 
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.9.0-beta.0",
3
+ "version": "2.9.0-beta.2",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
7
7
  ],
8
8
  "author": "donghongping",
9
- "license": "Apache",
9
+ "license": "Apache-2.0",
10
10
  "main": "lib/index.js",
11
11
  "directories": {
12
12
  "lib": "lib"
@@ -82,5 +82,5 @@
82
82
  "engines": {
83
83
  "node": ">=14.14.0"
84
84
  },
85
- "gitHead": "67b611aeae99f916d46ca8d5d9ed784ddf53f05c"
85
+ "gitHead": "2d61bab77c50eccb7470b9b9bd644e7bd6510467"
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