@mpxjs/webpack-plugin 2.7.46 → 2.7.47

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
@@ -537,7 +537,6 @@ class MpxWebpackPlugin {
537
537
  assetsASTsMap: new Map(),
538
538
  usingComponents: {},
539
539
  // todo es6 map读写性能高于object,之后会逐步替换
540
- vueContentCache: new Map(),
541
540
  wxsAssetsCache: new Map(),
542
541
  currentPackageRoot: '',
543
542
  wxsContentMap: {},
package/lib/loader.js CHANGED
@@ -46,7 +46,6 @@ module.exports = function (content) {
46
46
  const globalSrcMode = mpx.srcMode
47
47
  const localSrcMode = queryObj.mode
48
48
  const srcMode = localSrcMode || globalSrcMode
49
- const vueContentCache = mpx.vueContentCache
50
49
  const autoScope = matchCondition(resourcePath, mpx.autoScopeRules)
51
50
 
52
51
  let ctorType = 'app'
@@ -60,7 +59,7 @@ module.exports = function (content) {
60
59
 
61
60
  // 支持资源query传入isPage或isComponent支持页面/组件单独编译
62
61
  if (ctorType === 'app' && (queryObj.isComponent || queryObj.isPage)) {
63
- const entryName = getEntryName(this) || (queryObj.isComponent ? 'noEntryComponent' : 'noEntryPage')
62
+ const entryName = getEntryName(this) || mpx.getOutputPath(resourcePath, queryObj.isComponent ? 'component' : 'page')
64
63
  ctorType = queryObj.isComponent ? 'component' : 'page'
65
64
  this._module.addPresentationalDependency(new RecordResourceMapDependency(resourcePath, ctorType, entryName, packageRoot))
66
65
  }
@@ -94,10 +93,6 @@ module.exports = function (content) {
94
93
  })
95
94
  },
96
95
  (callback) => {
97
- // web输出模式下没有任何inject,可以通过cache直接返回,由于读取src json可能会新增模块依赖,需要在之后返回缓存内容
98
- if (vueContentCache.has(filePath)) {
99
- return callback(null, vueContentCache.get(filePath))
100
- }
101
96
  const hasScoped = parts.styles.some(({ scoped }) => scoped) || autoScope
102
97
  const templateAttrs = parts.template && parts.template.attrs
103
98
  const hasComment = templateAttrs && templateAttrs.comments
@@ -204,7 +199,6 @@ module.exports = function (content) {
204
199
  ], (err, scriptRes) => {
205
200
  if (err) return callback(err)
206
201
  output += scriptRes.output
207
- vueContentCache.set(filePath, output)
208
202
  callback(null, output)
209
203
  })
210
204
  }
@@ -2,6 +2,7 @@ const genComponentTag = require('../utils/gen-component-tag')
2
2
  const loaderUtils = require('loader-utils')
3
3
  const addQuery = require('../utils/add-query')
4
4
  const normalize = require('../utils/normalize')
5
+ const parseRequest = require('../utils/parse-request')
5
6
  const optionProcessorPath = normalize.lib('runtime/optionProcessor')
6
7
  const tabBarContainerPath = normalize.lib('runtime/components/web/mpx-tab-bar-container.vue')
7
8
  const tabBarPath = normalize.lib('runtime/components/web/mpx-tab-bar.vue')
@@ -49,6 +50,7 @@ module.exports = function (script, {
49
50
  projectRoot
50
51
  } = mpx
51
52
 
53
+ const { queryObj } = parseRequest(loaderContext.resource)
52
54
  const tabBar = jsonConfig.tabBar
53
55
 
54
56
  const emitWarning = (msg) => {
@@ -219,7 +221,8 @@ module.exports = function (script, {
219
221
  // 为了正确获取currentSrcMode便于运行时进行转换,对于src引入的组件script采用require方式引入(由于webpack会将import的执行顺序上升至最顶),这意味着对于src引入脚本中的named export将不会生效,不过鉴于mpx和小程序中本身也没有在组件script中声明export的用法,所以应该没有影响
220
222
  content += '\n\n\n/** Source start **/\n'
221
223
  content += script.src
222
- ? `require(${stringifyRequest(script.src)})\n`
224
+ // 继承单文件组件query避免多个单文件模块实例引用一个src模块,因模块缓存导致createComponent不执行的问题
225
+ ? `require(${stringifyRequest(addQuery(script.src, queryObj))})\n`
223
226
  : script.content
224
227
  content += '\n/** Source end **/\n\n\n'
225
228
  // createApp/Page/Component执行完成后立刻获取当前的option并暂存
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.7.46",
3
+ "version": "2.7.47",
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": "5c8b46722d862bba145badd164c4675a43a577c3"
83
+ "gitHead": "05354d5750021d76f4bf0ae2a4ab73fb2f8ef83b"
84
84
  }