@mpxjs/webpack-plugin 2.7.24 → 2.7.31
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/json-compiler/helper.js +1 -1
- package/lib/style-compiler/index.js +1 -1
- package/lib/template-compiler/index.js +1 -1
- package/lib/utils/eval-json-js.js +1 -0
- package/lib/web/processJSON.js +1 -1
- package/lib/web/processScript.js +10 -3
- package/lib/wxml/loader.js +0 -5
- package/lib/wxs/loader.js +1 -1
- package/package.json +2 -2
|
@@ -12,7 +12,7 @@ module.exports = function createJSONHelper ({ loaderContext, emitWarning, custom
|
|
|
12
12
|
const resolveMode = mpx.resolveMode
|
|
13
13
|
const externals = mpx.externals
|
|
14
14
|
const root = mpx.projectRoot
|
|
15
|
-
const publicPath = loaderContext._compilation
|
|
15
|
+
const publicPath = (loaderContext._compilation && loaderContext._compilation.outputOptions.publicPath) || ''
|
|
16
16
|
const pathHash = mpx.pathHash
|
|
17
17
|
const getOutputPath = mpx.getOutputPath
|
|
18
18
|
const mode = mpx.mode
|
|
@@ -14,8 +14,8 @@ module.exports = function (css, map) {
|
|
|
14
14
|
this.cacheable()
|
|
15
15
|
const cb = this.async()
|
|
16
16
|
const { resourcePath, queryObj } = parseRequest(this.resource)
|
|
17
|
-
const id = queryObj.moduleId || queryObj.mid
|
|
18
17
|
const mpx = this.getMpx()
|
|
18
|
+
const id = queryObj.moduleId || queryObj.mid || 'm' + mpx.pathHash(resourcePath)
|
|
19
19
|
const appInfo = mpx.appInfo
|
|
20
20
|
const defs = mpx.defs
|
|
21
21
|
const mode = mpx.mode
|
|
@@ -24,7 +24,7 @@ module.exports = function (raw) {
|
|
|
24
24
|
const hasComment = queryObj.hasComment
|
|
25
25
|
const isNative = queryObj.isNative
|
|
26
26
|
const hasScoped = queryObj.hasScoped
|
|
27
|
-
const moduleId = queryObj.moduleId
|
|
27
|
+
const moduleId = queryObj.moduleId || 'm' + mpx.pathHash(resourcePath)
|
|
28
28
|
|
|
29
29
|
const warn = (msg) => {
|
|
30
30
|
this.emitWarning(
|
|
@@ -22,6 +22,7 @@ module.exports = function evalJSONJS (source, filename, loaderContext) {
|
|
|
22
22
|
request = path.join(dirname, request)
|
|
23
23
|
}
|
|
24
24
|
const filename = require.resolve(request)
|
|
25
|
+
loaderContext.addDependency(filename)
|
|
25
26
|
const source = fs.readFileSync(filename).toString('utf-8')
|
|
26
27
|
return evalJSONJS(source, filename, loaderContext)
|
|
27
28
|
}, filename, dirname, ...defValues)
|
package/lib/web/processJSON.js
CHANGED
|
@@ -222,7 +222,7 @@ module.exports = function (json, {
|
|
|
222
222
|
loaderContext._module && loaderContext._module.addPresentationalDependency(new RecordResourceMapDependency(resourcePath, 'page', outputPath))
|
|
223
223
|
localPagesMap[outputPath] = {
|
|
224
224
|
resource: addQuery(resource, { isPage: true }),
|
|
225
|
-
async:
|
|
225
|
+
async: queryObj.async || tarRoot,
|
|
226
226
|
isFirst
|
|
227
227
|
}
|
|
228
228
|
callback()
|
package/lib/web/processScript.js
CHANGED
|
@@ -20,6 +20,13 @@ function shallowStringify (obj) {
|
|
|
20
20
|
return `{${arr.join(',')}}`
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
function getAsyncChunkName (chunkName) {
|
|
24
|
+
if (chunkName && typeof chunkName !== 'boolean') {
|
|
25
|
+
return `/* webpackChunkName: "${chunkName}" */`
|
|
26
|
+
}
|
|
27
|
+
return ''
|
|
28
|
+
}
|
|
29
|
+
|
|
23
30
|
module.exports = function (script, {
|
|
24
31
|
loaderContext,
|
|
25
32
|
ctorType,
|
|
@@ -62,7 +69,7 @@ module.exports = function (script, {
|
|
|
62
69
|
if (pageCfg) {
|
|
63
70
|
const pageRequest = stringifyRequest(pageCfg.resource)
|
|
64
71
|
if (pageCfg.async) {
|
|
65
|
-
tabBarPagesMap[pagePath] = `()=>import(${pageRequest}).then(res => getComponent(res, { __mpxPageRoute: ${JSON.stringify(pagePath)} }))`
|
|
72
|
+
tabBarPagesMap[pagePath] = `()=>import(${getAsyncChunkName(pageCfg.async)}${pageRequest}).then(res => getComponent(res, { __mpxPageRoute: ${JSON.stringify(pagePath)} }))`
|
|
66
73
|
} else {
|
|
67
74
|
tabBarPagesMap[pagePath] = `getComponent(require(${pageRequest}), { __mpxPageRoute: ${JSON.stringify(pagePath)} })`
|
|
68
75
|
}
|
|
@@ -177,7 +184,7 @@ module.exports = function (script, {
|
|
|
177
184
|
pagesMap[pagePath] = `getComponent(require(${stringifyRequest(tabBarContainerPath)}), { __mpxBuiltIn: true })`
|
|
178
185
|
} else {
|
|
179
186
|
if (pageCfg.async) {
|
|
180
|
-
pagesMap[pagePath] = `()=>import(${pageRequest}).then(res => getComponent(res, { __mpxPageRoute: ${JSON.stringify(pagePath)} }))`
|
|
187
|
+
pagesMap[pagePath] = `()=>import(${getAsyncChunkName(pageCfg.async)} ${pageRequest}).then(res => getComponent(res, { __mpxPageRoute: ${JSON.stringify(pagePath)} }))`
|
|
181
188
|
} else {
|
|
182
189
|
// 为了保持小程序中app->page->component的js执行顺序,所有的page和component都改为require引入
|
|
183
190
|
pagesMap[pagePath] = `getComponent(require(${pageRequest}), { __mpxPageRoute: ${JSON.stringify(pagePath)} })`
|
|
@@ -193,7 +200,7 @@ module.exports = function (script, {
|
|
|
193
200
|
const componentCfg = localComponentsMap[componentName]
|
|
194
201
|
const componentRequest = stringifyRequest(componentCfg.resource)
|
|
195
202
|
if (componentCfg.async) {
|
|
196
|
-
componentsMap[componentName] = `()=>import(${componentRequest}).then(res => getComponent(res))`
|
|
203
|
+
componentsMap[componentName] = `()=>import(${getAsyncChunkName(componentCfg.async)}${componentRequest}).then(res => getComponent(res))`
|
|
197
204
|
} else {
|
|
198
205
|
componentsMap[componentName] = `getComponent(require(${componentRequest}))`
|
|
199
206
|
}
|
package/lib/wxml/loader.js
CHANGED
|
@@ -17,13 +17,10 @@ module.exports = function (content) {
|
|
|
17
17
|
const externals = mpx.externals
|
|
18
18
|
|
|
19
19
|
const { queryObj } = parseRequest(this.resource)
|
|
20
|
-
const moduleId = queryObj.moduleId
|
|
21
20
|
const hasScoped = false
|
|
22
21
|
const hasComment = false
|
|
23
22
|
const isNative = true
|
|
24
23
|
|
|
25
|
-
const usingComponents = []
|
|
26
|
-
|
|
27
24
|
const mode = mpx.mode
|
|
28
25
|
const localSrcMode = queryObj.mode
|
|
29
26
|
const customAttributes = options.attributes || mpx.attributes || []
|
|
@@ -90,8 +87,6 @@ module.exports = function (content) {
|
|
|
90
87
|
hasScoped,
|
|
91
88
|
hasComment,
|
|
92
89
|
isNative,
|
|
93
|
-
moduleId,
|
|
94
|
-
usingComponents,
|
|
95
90
|
isStatic: true
|
|
96
91
|
}
|
|
97
92
|
requestString = getRequestString('template', { src, mode: localSrcMode }, extraOptions)
|
package/lib/wxs/loader.js
CHANGED
|
@@ -22,7 +22,7 @@ module.exports.pitch = function (remainingRequest) {
|
|
|
22
22
|
let { resourcePath, queryObj } = parseRequest(this.resource)
|
|
23
23
|
const issuer = moduleGraph.getIssuer(this._module)
|
|
24
24
|
const { resourcePath: issuerResourcePath, queryObj: issuerQueryObj } = parseRequest(queryObj.issuerResource || issuer.resource)
|
|
25
|
-
const issuerPackageName = issuerQueryObj.packageRoot ||
|
|
25
|
+
const issuerPackageName = issuerQueryObj.packageRoot || 'main'
|
|
26
26
|
const pagesMap = mpx.pagesMap
|
|
27
27
|
const componentsMap = mpx.componentsMap[issuerPackageName]
|
|
28
28
|
const staticResourcesMap = mpx.staticResourcesMap[issuerPackageName]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.31",
|
|
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": "
|
|
83
|
+
"gitHead": "c9cfb014d084999cc30890231dc10b8a1f4771a9"
|
|
84
84
|
}
|