@mpxjs/webpack-plugin 2.6.103 → 2.7.0-alpha.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.
Files changed (58) hide show
  1. package/lib/dependencies/AppEntryDependency.js +56 -0
  2. package/lib/dependencies/CommonJsVariableDependency.js +74 -0
  3. package/lib/dependencies/DynamicEntryDependency.js +127 -0
  4. package/lib/dependencies/FlagPluginDependency.js +23 -0
  5. package/lib/dependencies/InjectDependency.js +43 -0
  6. package/lib/dependencies/RecordGlobalComponentsDependency.js +50 -0
  7. package/lib/dependencies/RecordStaticResourceDependency.js +47 -0
  8. package/lib/{dependency → dependencies}/ReplaceDependency.js +19 -2
  9. package/lib/dependencies/ResolveDependency.js +83 -0
  10. package/lib/extractor.js +72 -179
  11. package/lib/file-loader.js +7 -19
  12. package/lib/helpers.js +41 -331
  13. package/lib/index.js +475 -365
  14. package/lib/json-compiler/helper.js +152 -0
  15. package/lib/json-compiler/index.js +148 -407
  16. package/lib/json-compiler/plugin.js +134 -0
  17. package/lib/json-compiler/{theme-loader.js → theme.js} +5 -3
  18. package/lib/loader.js +78 -177
  19. package/lib/native-loader.js +40 -70
  20. package/lib/record-loader.js +11 -0
  21. package/lib/{path-loader.js → resolve-loader.js} +0 -0
  22. package/lib/runtime/i18n.wxs +3 -3
  23. package/lib/selector.js +8 -7
  24. package/lib/style-compiler/index.js +14 -15
  25. package/lib/template-compiler/compiler.js +16 -153
  26. package/lib/template-compiler/index.js +46 -132
  27. package/lib/url-loader.js +11 -29
  28. package/lib/utils/add-query.js +1 -1
  29. package/lib/utils/const.js +5 -0
  30. package/lib/utils/emit-file.js +10 -0
  31. package/lib/utils/get-entry-name.js +13 -0
  32. package/lib/utils/is-url-request.js +10 -1
  33. package/lib/utils/normalize.js +0 -13
  34. package/lib/utils/parse-request.js +3 -3
  35. package/lib/utils/set.js +47 -0
  36. package/lib/utils/stringify-loaders-resource.js +25 -0
  37. package/lib/utils/stringify-query.js +4 -0
  38. package/lib/web/processScript.js +3 -3
  39. package/lib/web/processTemplate.js +2 -0
  40. package/lib/wxml/{wxml-loader.js → loader.js} +24 -60
  41. package/lib/wxs/WxsModuleIdsPlugin.js +32 -0
  42. package/lib/wxs/WxsParserPlugin.js +2 -2
  43. package/lib/wxs/WxsPlugin.js +4 -8
  44. package/lib/wxs/WxsTemplatePlugin.js +46 -92
  45. package/lib/wxs/{wxs-i18n-loader.js → i18n-loader.js} +0 -0
  46. package/lib/wxs/{wxs-loader.js → loader.js} +33 -38
  47. package/lib/wxs/{wxs-pre-loader.js → pre-loader.js} +0 -0
  48. package/lib/wxss/loader.js +31 -43
  49. package/lib/wxss/localsLoader.js +1 -5
  50. package/package.json +4 -8
  51. package/lib/content-loader.js +0 -13
  52. package/lib/dependency/ChildCompileDependency.js +0 -24
  53. package/lib/dependency/InjectDependency.js +0 -26
  54. package/lib/dependency/RemovedModuleDependency.js +0 -23
  55. package/lib/dependency/ResolveDependency.js +0 -49
  56. package/lib/plugin-loader.js +0 -287
  57. package/lib/utils/try-require.js +0 -16
  58. package/lib/wxss/getImportPrefix.js +0 -30
@@ -1,37 +1,27 @@
1
1
  const path = require('path')
2
2
  const JSON5 = require('json5')
3
3
  const parseRequest = require('./utils/parse-request')
4
- const loaderUtils = require('loader-utils')
5
4
  const config = require('./config')
6
5
  const createHelpers = require('./helpers')
7
- const InjectDependency = require('./dependency/InjectDependency')
8
- const addQuery = require('./utils/add-query')
9
6
  const mpxJSON = require('./utils/mpx-json')
10
7
  const async = require('async')
11
8
  const matchCondition = require('./utils/match-condition')
12
9
  const fixUsingComponent = require('./utils/fix-using-component')
13
- const getMainCompilation = require('./utils/get-main-compilation')
14
10
 
15
11
  module.exports = function (content) {
16
12
  this.cacheable()
17
13
 
18
- const mainCompilation = getMainCompilation(this._compilation)
19
- const mpx = mainCompilation.__mpx__
14
+ const mpx = this.getMpx()
20
15
  if (!mpx) {
21
16
  return content
22
17
  }
23
18
 
24
19
  const nativeCallback = this.async()
25
-
26
20
  const loaderContext = this
27
21
  const isProduction = this.minimize || process.env.NODE_ENV === 'production'
28
- const options = Object.assign({}, mpx.loaderOptions, loaderUtils.getOptions(this))
29
-
30
22
  const filePath = this.resourcePath
31
-
32
23
  const moduleId = 'm' + mpx.pathHash(filePath)
33
24
  const { resourcePath, queryObj } = parseRequest(this.resource)
34
- const projectRoot = mpx.projectRoot
35
25
  const mode = mpx.mode
36
26
  const defs = mpx.defs
37
27
  const globalSrcMode = mpx.srcMode
@@ -41,7 +31,7 @@ module.exports = function (content) {
41
31
  const componentsMap = mpx.componentsMap[packageName]
42
32
  const parsed = path.parse(resourcePath)
43
33
  const resourceName = path.join(parsed.dir, parsed.name)
44
- const isApp = !pagesMap[resourcePath] && !componentsMap[resourcePath]
34
+ const isApp = !(pagesMap[resourcePath] || componentsMap[resourcePath])
45
35
  const srcMode = localSrcMode || globalSrcMode
46
36
  const fs = this._compiler.inputFileSystem
47
37
  const typeExtMap = config[srcMode].typeExtMap
@@ -177,61 +167,52 @@ module.exports = function (content) {
177
167
  }
178
168
  } catch (e) {
179
169
  }
180
- const {
181
- getRequireForSrc,
182
- getNamedExportsForSrc
183
- } = createHelpers({
184
- loaderContext,
185
- options,
186
- moduleId,
187
- hasScoped,
188
- hasComment,
189
- usingComponents,
190
- srcMode,
191
- isNative,
192
- projectRoot
193
- })
194
170
 
195
- const getRequire = (type) => {
196
- const localQuery = Object.assign({}, queryObj)
197
- let src = typeResourceMap[type]
198
- localQuery.resourcePath = resourcePath
199
- if (type !== 'script') {
200
- this.addDependency(src)
201
- }
202
- if (type === 'template' && isApp) {
203
- return ''
204
- }
205
- if (type === 'json' && !useMPXJSON) {
206
- localQuery.__component = true
207
- }
208
- src = addQuery(src, localQuery, true)
209
- const partsOpts = { src }
171
+ const {
172
+ getRequire
173
+ } = createHelpers(loaderContext)
174
+
175
+ const getRequireByType = (type) => {
176
+ const src = typeResourceMap[type]
177
+ const part = { src }
178
+ const extraOptions = Object.assign({}, queryObj, {
179
+ resourcePath
180
+ })
210
181
 
211
- if (type === 'script') {
212
- return getNamedExportsForSrc(type, partsOpts)
213
- }
214
- if (type === 'styles') {
215
- if (cssLang) {
216
- partsOpts.lang = cssLang
217
- }
218
- if (hasScoped) {
219
- return getRequireForSrc(type, partsOpts, 0, true)
220
- }
182
+ if (type !== 'script') this.addDependency(src)
183
+
184
+ switch (type) {
185
+ case 'template':
186
+ if (isApp) return ''
187
+ Object.assign(extraOptions, {
188
+ hasScoped,
189
+ hasComment,
190
+ isNative,
191
+ moduleId,
192
+ usingComponents
193
+ })
194
+ break
195
+ case 'styles':
196
+ if (cssLang) part.lang = cssLang
197
+ Object.assign(extraOptions, {
198
+ moduleId,
199
+ scoped: hasScoped
200
+ })
201
+ break
221
202
  }
222
- return getRequireForSrc(type, partsOpts)
203
+ return getRequire(type, part, extraOptions)
223
204
  }
224
205
 
225
206
  // 注入模块id及资源路径
226
- let globalInjectCode = `global.currentModuleId = ${JSON.stringify(moduleId)}\n`
207
+ let output = `global.currentModuleId = ${JSON.stringify(moduleId)}\n`
227
208
  if (!isProduction) {
228
- globalInjectCode += `global.currentResource = ${JSON.stringify(filePath)}\n`
209
+ output += `global.currentResource = ${JSON.stringify(filePath)}\n`
229
210
  }
230
211
 
231
212
  // 注入构造函数
232
213
  let ctor = 'App'
233
214
  if (pagesMap[resourcePath]) {
234
- if (mpx.forceUsePageCtor || mode === 'ali') {
215
+ if (mpx.forceUsePageCtor || mode === 'ali' || mode === 'swan') {
235
216
  ctor = 'Page'
236
217
  } else {
237
218
  ctor = 'Component'
@@ -239,28 +220,17 @@ module.exports = function (content) {
239
220
  } else if (componentsMap[resourcePath]) {
240
221
  ctor = 'Component'
241
222
  }
242
- globalInjectCode += `global.currentCtor = ${ctor}\n`
243
- globalInjectCode += `global.currentCtorType = ${JSON.stringify(ctor.replace(/^./, (match) => {
223
+ output += `global.currentCtor = ${ctor}\n`
224
+ output += `global.currentCtorType = ${JSON.stringify(ctor.replace(/^./, (match) => {
244
225
  return match.toLowerCase()
245
226
  }))}\n`
246
227
 
247
228
  if (srcMode) {
248
- globalInjectCode += `global.currentSrcMode = ${JSON.stringify(srcMode)}\n`
229
+ output += `global.currentSrcMode = ${JSON.stringify(srcMode)}\n`
249
230
  }
250
231
 
251
- if (!mpx.forceDisableInject) {
252
- const dep = new InjectDependency({
253
- content: globalInjectCode,
254
- index: -3
255
- })
256
- this._module.addDependency(dep)
257
- }
258
-
259
- // 触发webpack global var 注入
260
- let output = 'global.currentModuleId;\n'
261
-
262
232
  for (let type in typeResourceMap) {
263
- output += `/* ${type} */\n${getRequire(type)}\n\n`
233
+ output += `/* ${type} */\n${getRequireByType(type)}\n\n`
264
234
  }
265
235
 
266
236
  callback(null, output)
@@ -0,0 +1,11 @@
1
+ const parseRequest = require('./utils/parse-request')
2
+ const RecordStaticResourceDependency = require('./dependencies/RecordStaticResourceDependency')
3
+
4
+ module.exports = function (source) {
5
+ const mpx = this.getMpx()
6
+ const { resourcePath, queryObj } = parseRequest(this.resource)
7
+ const file = mpx.getExtractedFile(this.resource)
8
+ const packageRoot = queryObj.packageRoot || ''
9
+ this._module.addPresentationalDependency(new RecordStaticResourceDependency(resourcePath, file, packageRoot))
10
+ return source
11
+ }
File without changes
@@ -265,17 +265,17 @@ var dateTimeFormats = {}
265
265
  var numberFormats = {}
266
266
 
267
267
  function getMessages () {
268
- // __mpx_messages__会在编译时通过lib/wxs/wxs-i18n-loader注入
268
+ // __mpx_messages__会在编译时通过lib/wxs/i18n-loader注入
269
269
  return __mpx_messages__ || messages
270
270
  }
271
271
 
272
272
  function getDateTimeFormats () {
273
- // __mpx_datetime_formats__会在编译时通过lib/wxs/wxs-i18n-loader注入
273
+ // __mpx_datetime_formats__会在编译时通过lib/wxs/i18n-loader注入
274
274
  return __mpx_datetime_formats__ || dateTimeFormats
275
275
  }
276
276
 
277
277
  function getNumberFormats () {
278
- // __mpx_number_formats__会在编译时通过lib/wxs/wxs-i18n-loader注入
278
+ // __mpx_number_formats__会在编译时通过lib/wxs/i18n-loader注入
279
279
  return __mpx_number_formats__ || numberFormats
280
280
  }
281
281
 
package/lib/selector.js CHANGED
@@ -1,18 +1,19 @@
1
1
  const parseComponent = require('./parser')
2
- const loaderUtils = require('loader-utils')
3
- const getMainCompilation = require('./utils/get-main-compilation')
2
+ const parseRequest = require('./utils/parse-request')
4
3
 
5
4
  module.exports = function (content) {
6
5
  this.cacheable()
7
- const mainCompilation = getMainCompilation(this._compilation)
8
- const mpx = mainCompilation.__mpx__
6
+ // todo 移除mpx访问依赖,支持thread-loader
7
+ const mpx = this.getMpx()
9
8
  if (!mpx) {
10
9
  return content
11
10
  }
11
+ const { queryObj } = parseRequest(this.resource)
12
+ const type = queryObj.type
13
+ const index = queryObj.index || 0
12
14
  const mode = mpx.mode
13
15
  const env = mpx.env
14
16
  const defs = mpx.defs
15
- const query = loaderUtils.getOptions(this) || {}
16
17
  const filePath = this.resourcePath
17
18
  const parts = parseComponent(content, {
18
19
  filePath,
@@ -21,9 +22,9 @@ module.exports = function (content) {
21
22
  defs,
22
23
  env
23
24
  })
24
- let part = parts[query.type] || {}
25
+ let part = parts[type] || {}
25
26
  if (Array.isArray(part)) {
26
- part = part[query.index] || {
27
+ part = part[index] || {
27
28
  content: ''
28
29
  }
29
30
  }
@@ -1,8 +1,5 @@
1
- const getMainCompilation = require('../utils/get-main-compilation')
2
1
  const postcss = require('postcss')
3
- const loaderUtils = require('loader-utils')
4
2
  const loadPostcssConfig = require('./load-postcss-config')
5
-
6
3
  const trim = require('./plugins/trim')
7
4
  const rpx = require('./plugins/rpx')
8
5
  const vw = require('./plugins/vw')
@@ -10,18 +7,21 @@ const pluginCondStrip = require('./plugins/conditional-strip')
10
7
  const scopeId = require('./plugins/scope-id')
11
8
  const transSpecial = require('./plugins/trans-special')
12
9
  const matchCondition = require('../utils/match-condition')
10
+ const parseRequest = require('../utils/parse-request')
13
11
 
14
12
  module.exports = function (css, map) {
15
13
  this.cacheable()
16
14
  const cb = this.async()
17
- const loaderOptions = loaderUtils.getOptions(this) || {}
18
-
19
- const mainCompilation = getMainCompilation(this._compilation)
20
- const mpx = mainCompilation.__mpx__
15
+ const { resourcePath, queryObj } = parseRequest(this.resource)
16
+ const id = queryObj.moduleId || queryObj.mid
17
+ const mpx = this.getMpx()
21
18
  const defs = mpx.defs
22
-
19
+ const mode = mpx.mode
20
+ const packageName = queryObj.packageRoot || mpx.currentPackageRoot || 'main'
21
+ const componentsMap = mpx.componentsMap[packageName]
22
+ const pagesMap = mpx.pagesMap
23
+ const isApp = !(pagesMap[resourcePath] || componentsMap[resourcePath])
23
24
  const transRpxRulesRaw = mpx.transRpxRules
24
-
25
25
  const transRpxRules = transRpxRulesRaw ? (Array.isArray(transRpxRulesRaw) ? transRpxRulesRaw : [transRpxRulesRaw]) : []
26
26
 
27
27
  const testResolveRange = (include = () => true, exclude) => {
@@ -40,13 +40,12 @@ module.exports = function (css, map) {
40
40
  config.options
41
41
  )
42
42
  // ali环境处理host选择器
43
- if (mpx.mode === 'ali') {
44
- plugins.push(transSpecial({ id: loaderOptions.moduleId || loaderOptions.mid }))
43
+ if (mode === 'ali') {
44
+ plugins.push(transSpecial({ id }))
45
45
  }
46
46
 
47
- if (loaderOptions.scoped) {
48
- const moduleId = loaderOptions.moduleId || loaderOptions.mid
49
- plugins.push(scopeId({ id: moduleId }))
47
+ if (queryObj.scoped) {
48
+ plugins.push(scopeId({ id }))
50
49
  }
51
50
 
52
51
  plugins.push(pluginCondStrip({
@@ -85,7 +84,7 @@ module.exports = function (css, map) {
85
84
  .process(css, options)
86
85
  .then(result => {
87
86
  // ali环境添加全局样式抹平root差异
88
- if (mpx.mode === 'ali' && loaderOptions.ctorType === 'app') {
87
+ if (mode === 'ali' && isApp) {
89
88
  result.css += '\n.mpx-root-view { display: inline; line-height: normal; }\n'
90
89
  }
91
90
  if (result.messages) {
@@ -129,107 +129,6 @@ function isForbiddenTag (el) {
129
129
  )
130
130
  }
131
131
 
132
- // mpx special comments
133
- // example
134
- /*
135
- {
136
- 'tt,swan': {
137
- remove: [
138
- 'open-type',
139
- // src mode attr
140
- 'wx:if'
141
- ],
142
- add: {
143
- type: 'primary',
144
- // attr name only
145
- foo: null,
146
- }
147
- }
148
- }
149
- */
150
- let curMpxComment = null
151
-
152
- function evalMpxCommentExp (exp) {
153
- /* eslint-disable no-new-func */
154
- const f = new Function(`return ${exp};`)
155
- return f()
156
- }
157
-
158
- function isMpxCommentAttrs (content) {
159
- return /@mpx-attrs/.test(content)
160
- }
161
-
162
- function normalizePlatformMpxAttrsOpts (opts) {
163
- const ret = {}
164
- // Array to map for removing attributes
165
- ret.remove = (opts.remove || []).reduce((acc, val) => {
166
- acc[val] = true
167
- return acc
168
- }, {})
169
- // Default adding map
170
- ret.add = opts.add || {}
171
- return ret
172
- }
173
-
174
- function produceMpxCommentAttrs (content) {
175
- const exp = /@mpx-attrs[^(]*?\(([\s\S]*)\)/.exec(content)[1].trim()
176
- const tmpOpts = evalMpxCommentExp(exp)
177
- // normalize
178
- Object.keys(tmpOpts).forEach(k => {
179
- Object.assign(tmpOpts[k], normalizePlatformMpxAttrsOpts(tmpOpts[k]))
180
-
181
- if (k.indexOf(',') > -1) {
182
- const modes = k.split(',')
183
- modes.forEach(mode => {
184
- tmpOpts[mode] = tmpOpts[k]
185
- })
186
- delete tmpOpts[k]
187
- }
188
- })
189
- curMpxComment = tmpOpts
190
- }
191
-
192
- function modifyAttrsFromCurMpxAttrOptions (attrs, curModeMpxComment) {
193
- const removeMap = curModeMpxComment.remove
194
- const addMap = curModeMpxComment.add
195
-
196
- const newAttrs = []
197
- attrs.forEach(attr => {
198
- if (!removeMap[attr.name]) {
199
- newAttrs.push(attr)
200
- }
201
- })
202
-
203
- Object.keys(addMap).forEach(name => {
204
- newAttrs.push({
205
- name,
206
- value: addMap[name]
207
- })
208
- })
209
-
210
- return newAttrs
211
- }
212
-
213
- function consumeMpxCommentAttrs (attrs, mode) {
214
- let ret = attrs
215
- if (curMpxComment) {
216
- const curModeMpxComment = curMpxComment[mode]
217
- if (curModeMpxComment) {
218
- ret = modifyAttrsFromCurMpxAttrOptions(attrs, curModeMpxComment)
219
- }
220
-
221
- // reset
222
- curMpxComment = null
223
- }
224
- return ret
225
- }
226
-
227
- function assertMpxCommentAttrsEnd () {
228
- if (curMpxComment) {
229
- error$1('No target for @mpx-attrs!')
230
- }
231
- }
232
-
233
132
  // Browser environment sniffing
234
133
  const UA = inBrowser && window.navigator.userAgent.toLowerCase()
235
134
  const isIE = UA && /msie|trident/.test(UA)
@@ -253,6 +152,9 @@ let forScopesMap = {}
253
152
  let hasI18n = false
254
153
  let i18nInjectableComputed = []
255
154
  let env
155
+ let platformGetTagNamespace
156
+ let filePath
157
+ let refId
256
158
 
257
159
  function updateForScopesMap () {
258
160
  forScopes.forEach((scope) => {
@@ -279,9 +181,6 @@ const deleteErrorInResultMap = (node) => {
279
181
  rulesResultMap.delete(node)
280
182
  Array.isArray(node.children) && node.children.forEach(item => deleteErrorInResultMap(item))
281
183
  }
282
- let platformGetTagNamespace
283
- let basename
284
- let refId
285
184
 
286
185
  function baseWarn (msg) {
287
186
  console.warn(('[template compiler]: ' + msg))
@@ -310,7 +209,7 @@ function decode (value) {
310
209
 
311
210
  const i18nFuncNames = ['\\$(t)', '\\$(tc)', '\\$(te)', '\\$(d)', '\\$(n)']
312
211
  const i18nWxsPath = normalize.lib('runtime/i18n.wxs')
313
- const i18nWxsLoaderPath = normalize.lib('wxs/wxs-i18n-loader.js')
212
+ const i18nWxsLoaderPath = normalize.lib('wxs/i18n-loader.js')
314
213
  // 添加~前缀避免wxs绝对路径在存在projectRoot时被拼接为错误路径
315
214
  const i18nWxsRequest = '~' + i18nWxsLoaderPath + '!' + i18nWxsPath
316
215
  const i18nModuleName = '__i18n__'
@@ -599,6 +498,7 @@ function parseComponent (content, options) {
599
498
  mode = options.mode || 'wx'
600
499
  defs = options.defs || {}
601
500
  env = options.env
501
+ filePath = options.filePath
602
502
 
603
503
  let sfc = {
604
504
  template: null,
@@ -691,9 +591,6 @@ function parseComponent (content, options) {
691
591
  if (attr.name === 'scoped') {
692
592
  block.scoped = true
693
593
  }
694
- if (attr.name === 'module') {
695
- block.module = attr.value || true
696
- }
697
594
  if (attr.name === 'src') {
698
595
  block.src = attr.value
699
596
  }
@@ -721,7 +618,7 @@ function parseComponent (content, options) {
721
618
 
722
619
  // 对于<script name="json">的标签,传参调用函数,其返回结果作为json的内容
723
620
  if (currentBlock.tag === 'script' && !/^application\/json/.test(currentBlock.type) && currentBlock.name === 'json') {
724
- text = mpxJSON.compileMPXJSONText({ source: text, defs, filePath: options.filePath })
621
+ text = mpxJSON.compileMPXJSONText({ source: text, defs, filePath })
725
622
  }
726
623
  currentBlock.content = text
727
624
  currentBlock = null
@@ -773,7 +670,7 @@ function parse (template, options) {
773
670
  defs = options.defs || {}
774
671
  srcMode = options.srcMode || mode
775
672
  isNative = options.isNative
776
- basename = options.basename
673
+ filePath = options.filePath
777
674
  i18n = options.i18n
778
675
  refId = 0
779
676
 
@@ -824,16 +721,6 @@ function parse (template, options) {
824
721
  attrs = guardIESVGBug(attrs)
825
722
  }
826
723
 
827
- if (options.globalMpxAttrsFilter) {
828
- attrs = modifyAttrsFromCurMpxAttrOptions(attrs, normalizePlatformMpxAttrsOpts(options.globalMpxAttrsFilter({
829
- tagName: tag,
830
- attrs,
831
- __mpx_mode__: mode,
832
- filePath: options.filePath
833
- }) || {}))
834
- }
835
- attrs = consumeMpxCommentAttrs(attrs, mode)
836
-
837
724
  let element = createASTElement(tag, attrs, currentParent)
838
725
  if (ns) {
839
726
  element.ns = ns
@@ -848,21 +735,6 @@ function parse (template, options) {
848
735
  )
849
736
  }
850
737
 
851
- // single root
852
- // // gen root
853
- // if (!root) {
854
- // root = element
855
- // } else {
856
- // // mount element
857
- // if (currentParent) {
858
- // currentParent.children.push(element)
859
- // element.parent = currentParent
860
- // } else {
861
- // multiRootError = true
862
- // return
863
- // }
864
- // }
865
-
866
738
  // multi root
867
739
  if (!currentParent) genTempRoot()
868
740
 
@@ -931,10 +803,7 @@ function parse (template, options) {
931
803
  },
932
804
  comment: function comment (text) {
933
805
  if (!currentParent) genTempRoot()
934
- // special comments should not be output
935
- if (isMpxCommentAttrs(text)) {
936
- produceMpxCommentAttrs(text)
937
- } else if (options.hasComment) {
806
+ if (options.hasComment) {
938
807
  currentParent.children.push({
939
808
  type: 3,
940
809
  text: text,
@@ -945,8 +814,6 @@ function parse (template, options) {
945
814
  }
946
815
  })
947
816
 
948
- assertMpxCommentAttrsEnd()
949
-
950
817
  if (multiRootError) {
951
818
  error$1('Template fields should has one single root, considering wrapping your template content with <view> or <text> tag!')
952
819
  }
@@ -1136,15 +1003,6 @@ function processComponentIs (el, options) {
1136
1003
  }
1137
1004
  }
1138
1005
 
1139
- // function processComponentDepth (el, options) {
1140
- // if (isComponentNode(el,options)) {
1141
- // addAttrs(el, [{
1142
- // name: 'mpxDepth',
1143
- // value: '{{mpxDepth + 1}}'
1144
- // }])
1145
- // }
1146
- // }
1147
-
1148
1006
  const eventIdentifier = '__mpx_event__'
1149
1007
 
1150
1008
  function parseFuncStr2 (str) {
@@ -1552,9 +1410,13 @@ function postProcessWxs (el, meta) {
1552
1410
  content = el.children.filter((child) => {
1553
1411
  return child.type === 3 && !child.isComment
1554
1412
  }).map(child => child.text).join('\n')
1555
- src = addQuery('./' + basename, {
1413
+
1414
+ const fakeRequest = filePath + config[mode].wxs.ext
1415
+
1416
+ src = addQuery(`~${fakeRequest}!=!${filePath}`, {
1556
1417
  wxsModule: module
1557
1418
  })
1419
+
1558
1420
  addAttrs(el, [{
1559
1421
  name: config[mode].wxs.src,
1560
1422
  value: src
@@ -1635,9 +1497,9 @@ function postProcessFor (el) {
1635
1497
  }
1636
1498
 
1637
1499
  function evalExp (exp) {
1638
- // eslint-disable-next-line no-new-func
1639
1500
  let result = { success: false }
1640
1501
  try {
1502
+ // eslint-disable-next-line no-new-func
1641
1503
  const fn = new Function(`return ${exp};`)
1642
1504
  result = {
1643
1505
  success: true,
@@ -1914,6 +1776,7 @@ function processAliStyleClassHack (el, options) {
1914
1776
  }
1915
1777
  })
1916
1778
  }
1779
+
1917
1780
  // 有virtualHost情况wx组件注入virtualHost。无virtualHost阿里组件注入root-view。其他跳过。
1918
1781
  function getVirtualHostRoot (options, meta) {
1919
1782
  if (mode === 'wx' && options.hasVirtualHost && options.isComponent) {
@@ -1928,7 +1791,7 @@ function getVirtualHostRoot (options, meta) {
1928
1791
  },
1929
1792
  {
1930
1793
  name: 'style',
1931
- style: `{{mpxStyle||''}}`
1794
+ value: `{{mpxStyle||''}}`
1932
1795
  }
1933
1796
  ])
1934
1797
  }