@mpxjs/webpack-plugin 2.8.25-alpha → 2.8.25-alpha.10

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.
@@ -76,7 +76,8 @@ ResolveDependency.Template = class ResolveDependencyTemplate {
76
76
  const { resolved = '' } = dep
77
77
  // for tenon
78
78
  if (dep.compilation.__mpx__.mode === 'tenon') {
79
- return `getRelativePath(currentURL, ${JSON.stringify(resolved)}) + '.js'`
79
+ // 暂时仅支持所有产物在一个目录下的场景
80
+ return `(Hummer.pageInfo && Hummer.pageInfo.url && Hummer.pageInfo.url.replace(/\\/[^/]+(?=\\.[^.]+($|\\?))/, '/${resolved}') || './${resolved}.js')`
80
81
  }
81
82
  // ?resolve 必定返回绝对路径
82
83
  return JSON.stringify('/' + resolved)
package/lib/loader.js CHANGED
@@ -70,7 +70,9 @@ module.exports = function (content) {
70
70
 
71
71
  if (ctorType === 'app') {
72
72
  const appName = getEntryName(this)
73
- this._module.addPresentationalDependency(new AppEntryDependency(resourcePath, appName))
73
+ if (appName) {
74
+ this._module.addPresentationalDependency(new AppEntryDependency(resourcePath, appName))
75
+ }
74
76
  }
75
77
  const loaderContext = this
76
78
  const stringifyRequest = r => loaderUtils.stringifyRequest(loaderContext, r)
@@ -263,6 +263,12 @@ module.exports = function getSpec ({ warn, error }) {
263
263
  name: 'ref',
264
264
  value: `__mpx_ref_${value}__`
265
265
  }
266
+ },
267
+ tenon ({ value }) {
268
+ return {
269
+ name: 'ref',
270
+ value: `${value}`
271
+ }
266
272
  }
267
273
  },
268
274
  {
@@ -64,6 +64,9 @@ export default (function(){
64
64
  },
65
65
  },
66
66
  computed: {
67
+ originRef() {
68
+ return this.$refs["mpx-button"]
69
+ },
67
70
  className() {
68
71
  if (this.hoverClass && this.hoverClass !== "none" && this.hover) {
69
72
  return this.hoverClass;
@@ -109,6 +112,7 @@ export default (function(){
109
112
  };
110
113
  const data = {
111
114
  class: ["mpx-button", ...this.classNameList],
115
+ ref: "mpx-button",
112
116
  ...domProps,
113
117
  ...getInnerListeners(this, {
114
118
  mergeAfter,
@@ -38,11 +38,17 @@ export default {
38
38
  }
39
39
  return h("image", {
40
40
  class: "mpx-image",
41
+ ref: "mpx-image",
41
42
  src: this.src,
42
43
  resize,
43
44
  ...getInnerListeners(this)
44
45
  });
45
46
  },
47
+ computed: {
48
+ originRef() {
49
+ return this.$refs["mpx-image"]
50
+ }
51
+ },
46
52
  data() {
47
53
  return {};
48
54
  },
@@ -9,10 +9,15 @@ export default {
9
9
  value: {}
10
10
  }
11
11
  },
12
+ computed: {
13
+ originRef() {
14
+ return this.$refs["mpx-richtext"]
15
+ }
16
+ },
12
17
  render () {
13
-
14
18
  const data = {
15
19
  richText: this.richText,
20
+ ref: "mpx-richtext",
16
21
  ...getInnerListeners(this)
17
22
  }
18
23
  return h('text', data)
@@ -72,6 +72,9 @@ export default {
72
72
  return {};
73
73
  },
74
74
  computed: {
75
+ originRef() {
76
+ return this.$refs["scroll"]
77
+ },
75
78
  _scrollTop() {
76
79
  // return 1
77
80
  return processSize(this.scrollTop);
@@ -22,6 +22,11 @@ export default {
22
22
  default: "#04BE02",
23
23
  },
24
24
  },
25
+ computed: {
26
+ originRef() {
27
+ return this.$refs["switch"]
28
+ }
29
+ },
25
30
  watch: {
26
31
  checked(newVal) {
27
32
  this.switchChecked = newVal;
@@ -39,11 +39,17 @@ export default {
39
39
  "text",
40
40
  {
41
41
  class: classNames,
42
+ ref: "mpx-text",
42
43
  ...getInnerListeners(this),
43
44
  },
44
45
  text
45
46
  );
46
47
  },
48
+ computed: {
49
+ originRef() {
50
+ return this.$refs["mpx-text"]
51
+ }
52
+ },
47
53
  data() {
48
54
  return {};
49
55
  },
@@ -32,7 +32,6 @@ export default {
32
32
  default: -1,
33
33
  },
34
34
  },
35
-
36
35
  computed: {
37
36
  originRef() {
38
37
  return this.$refs["mpx-textarea"]
@@ -1918,7 +1918,7 @@ function postProcessTemplate (el) {
1918
1918
  }
1919
1919
  }
1920
1920
 
1921
- const isValidMode = makeMap('wx,ali,swan,tt,qq,web,qa,jd,dd,noMode')
1921
+ const isValidMode = makeMap('wx,ali,swan,tt,qq,web,qa,jd,dd,tenon,noMode')
1922
1922
 
1923
1923
  const wrapRE = /^\((.*)\)$/
1924
1924
 
@@ -129,16 +129,12 @@ module.exports = function (json, options, rawCallback) {
129
129
  defs,
130
130
  env
131
131
  })
132
- const json = parts.json || {}
133
- if (json.content) {
134
- content = json.content
135
- } else if (json.src) {
136
- return getJSONContent(json || {}, loaderContext, (err, content) => {
137
- callback(err, result, content)
138
- })
139
- }
132
+ getJSONContent(parts.json || {}, result, loaderContext, (err, content) => {
133
+ callback(err, result, content)
134
+ })
135
+ } else {
136
+ callback(null, result, content)
140
137
  }
141
- callback(null, result, content)
142
138
  },
143
139
  (result, content, callback) => {
144
140
  try {
@@ -5,6 +5,7 @@ const normalize = require('../utils/normalize')
5
5
  const builtInLoaderPath = normalize.lib('built-in-loader')
6
6
  const optionProcessorPath = normalize.lib('runtime/optionProcessor')
7
7
  const createJSONHelper = require('../json-compiler/helper')
8
+ const createHelpers = require('../helpers')
8
9
  const async = require('async')
9
10
  const hasOwn = require('../utils/has-own')
10
11
 
@@ -89,6 +90,8 @@ module.exports = function (script, options, callback) {
89
90
  emitError
90
91
  })
91
92
 
93
+ const { getRequire } = createHelpers(loaderContext)
94
+
92
95
  const stringifyRequest = r => loaderUtils.stringifyRequest(loaderContext, r)
93
96
  // let tabBarPagesMap = {}
94
97
  // if (tabBar && tabBarMap) {
@@ -188,10 +191,14 @@ module.exports = function (script, options, callback) {
188
191
  if (!isProduction) {
189
192
  content += ` global.currentResource = ${JSON.stringify(loaderContext.resourcePath)}\n`
190
193
  }
191
- // 为了正确获取currentSrcMode便于运行时进行转换,对于src引入的组件script采用require方式引入(由于webpack会将import的执行顺序上升至最顶),这意味着对于src引入脚本中的named export将不会生效,不过鉴于mpx和小程序中本身也没有在组件script中声明export的用法,所以应该没有影响
192
- content += script.src
193
- ? `require(${stringifyRequest(script.src)})\n`
194
- : (script.content + '\n') + '\n'
194
+ // 传递ctorType以补全js内容
195
+ const extraOptions = {
196
+ ctorType,
197
+ lang: script.lang || 'js'
198
+ }
199
+ // 使用 require 引入 script
200
+ content += ` ${getRequire('script', script, extraOptions)}\n`
201
+
195
202
  // createApp/Page/Component执行完成后立刻获取当前的option并暂存
196
203
  content += ` const currentOption = global.__mpxOptionsMap[${JSON.stringify(moduleId)}]\n`
197
204
  // 获取pageConfig
@@ -247,7 +254,7 @@ module.exports = function (script, options, callback) {
247
254
  let dynamicPageStr = ''
248
255
  async.each(localPagesMap, (pageCfg, callback) => {
249
256
  if (typeof pageCfg !== 'string') pageCfg.src = addQuery(pageCfg.src, { tenon: true })
250
- processPage(pageCfg, loaderContext.context, '', (err, entry, { key }) => {
257
+ processPage(pageCfg, loaderContext.context, '', (err, entry, { key } = {}) => {
251
258
  if (err) return callback()
252
259
  if (pageSet.has(key)) return callback()
253
260
  pageSet.add(key)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.8.25-alpha",
3
+ "version": "2.8.25-alpha.10",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -28,7 +28,7 @@
28
28
  "@better-scroll/wheel": "^2.2.1",
29
29
  "@better-scroll/zoom": "^2.2.1",
30
30
  "@hummer/tenon-dev-server-webpack-plugin": "0.0.2",
31
- "@hummer/tenon-loader": "^1.1.0",
31
+ "@hummer/tenon-loader": "^1.2.0",
32
32
  "@hummer/tenon-style-loader": "^0.2.0",
33
33
  "acorn-walk": "^7.2.0",
34
34
  "async": "^2.6.0",
@@ -85,5 +85,5 @@
85
85
  "engines": {
86
86
  "node": ">=14.14.0"
87
87
  },
88
- "gitHead": "345dc10820535a06d9aee8d2a1e6cc735ba08882"
88
+ "gitHead": "8644921e89035057c93f648063059b55537c83c3"
89
89
  }