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

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.
@@ -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
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.1",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"
@@ -85,5 +85,5 @@
85
85
  "engines": {
86
86
  "node": ">=14.14.0"
87
87
  },
88
- "gitHead": "345dc10820535a06d9aee8d2a1e6cc735ba08882"
88
+ "gitHead": "0d932ec0de2bf893ac37811b9280c1c693e644ef"
89
89
  }