@mpxjs/webpack-plugin 2.9.43 → 2.9.48
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/react/index.js +1 -1
- package/lib/react/processMainScript.js +8 -4
- package/lib/react/processTemplate.js +1 -0
- package/lib/react/script-helper.js +10 -1
- package/lib/web/index.js +1 -5
- package/lib/web/processMainScript.js +1 -9
- package/lib/web/script-helper.js +12 -11
- package/package.json +2 -2
package/lib/react/index.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
// 该文件下的字符串语句需要使用 es5 语法
|
|
2
2
|
const addQuery = require('../utils/add-query')
|
|
3
|
-
|
|
4
3
|
const {
|
|
5
|
-
stringifyRequest
|
|
4
|
+
stringifyRequest,
|
|
5
|
+
buildI18n
|
|
6
6
|
} = require('./script-helper')
|
|
7
7
|
|
|
8
|
-
module.exports = function (
|
|
8
|
+
module.exports = function ({
|
|
9
9
|
loaderContext
|
|
10
10
|
}, callback) {
|
|
11
|
-
const { projectName } = loaderContext.getMpx()
|
|
11
|
+
const { i18n, projectName } = loaderContext.getMpx()
|
|
12
12
|
|
|
13
13
|
let output = 'import { AppRegistry } from \'react-native\'\n'
|
|
14
|
+
|
|
15
|
+
if (i18n) {
|
|
16
|
+
output += buildI18n({ loaderContext })
|
|
17
|
+
}
|
|
14
18
|
// 此处可添加前置于App执行的语句
|
|
15
19
|
output += `var App = require(${stringifyRequest(loaderContext, addQuery(loaderContext.resource, { isApp: true }))}).default\n`
|
|
16
20
|
output += `AppRegistry.registerComponent(${JSON.stringify(projectName)}, () => App)\n`
|
|
@@ -2,6 +2,7 @@ const loaderUtils = require('loader-utils')
|
|
|
2
2
|
const createHelpers = require('../helpers')
|
|
3
3
|
const parseRequest = require('../utils/parse-request')
|
|
4
4
|
const shallowStringify = require('../utils/shallow-stringify')
|
|
5
|
+
const normalize = require('../utils/normalize')
|
|
5
6
|
|
|
6
7
|
function stringifyRequest (loaderContext, request) {
|
|
7
8
|
return loaderUtils.stringifyRequest(loaderContext, request)
|
|
@@ -125,10 +126,18 @@ global.currentInject.firstPage = ${JSON.stringify(firstPage)}\n`
|
|
|
125
126
|
return content
|
|
126
127
|
}
|
|
127
128
|
|
|
129
|
+
function buildI18n ({ loaderContext }) {
|
|
130
|
+
const i18nWxsPath = normalize.lib('runtime/i18n.wxs')
|
|
131
|
+
const i18nWxsLoaderPath = normalize.lib('wxs/i18n-loader.js')
|
|
132
|
+
const i18nWxsRequest = i18nWxsLoaderPath + '!' + i18nWxsPath
|
|
133
|
+
return `require(${stringifyRequest(loaderContext, i18nWxsRequest)})\n`
|
|
134
|
+
}
|
|
135
|
+
|
|
128
136
|
module.exports = {
|
|
129
137
|
buildPagesMap,
|
|
130
138
|
buildComponentsMap,
|
|
131
139
|
getRequireScript,
|
|
132
140
|
buildGlobalParams,
|
|
133
|
-
stringifyRequest
|
|
141
|
+
stringifyRequest,
|
|
142
|
+
buildI18n
|
|
134
143
|
}
|
package/lib/web/index.js
CHANGED
|
@@ -35,13 +35,9 @@ module.exports = function ({
|
|
|
35
35
|
}, callback)
|
|
36
36
|
},
|
|
37
37
|
(jsonRes, callback) => {
|
|
38
|
-
processMainScript(
|
|
38
|
+
processMainScript({
|
|
39
39
|
loaderContext,
|
|
40
|
-
srcMode,
|
|
41
|
-
moduleId,
|
|
42
|
-
isProduction,
|
|
43
40
|
jsonConfig: jsonRes.jsonObj,
|
|
44
|
-
outputPath: queryObj.outputPath || '',
|
|
45
41
|
localComponentsMap: jsonRes.localComponentsMap,
|
|
46
42
|
tabBar: jsonRes.jsonObj.tabBar,
|
|
47
43
|
tabBarMap: jsonRes.tabBarMap,
|
|
@@ -12,11 +12,8 @@ const {
|
|
|
12
12
|
buildI18n
|
|
13
13
|
} = require('./script-helper')
|
|
14
14
|
|
|
15
|
-
module.exports = function (
|
|
15
|
+
module.exports = function ({
|
|
16
16
|
loaderContext,
|
|
17
|
-
srcMode,
|
|
18
|
-
moduleId,
|
|
19
|
-
isProduction,
|
|
20
17
|
jsonConfig,
|
|
21
18
|
localComponentsMap,
|
|
22
19
|
tabBar,
|
|
@@ -40,8 +37,6 @@ module.exports = function (script, {
|
|
|
40
37
|
jsonConfig
|
|
41
38
|
})
|
|
42
39
|
|
|
43
|
-
const scriptSrcMode = script ? script.mode || srcMode : srcMode
|
|
44
|
-
|
|
45
40
|
let output = 'import \'@mpxjs/webpack-plugin/lib/runtime/base.styl\'\n'
|
|
46
41
|
// hasUnoCSS由@mpxjs/unocss-plugin注入
|
|
47
42
|
if (hasUnoCSS) {
|
|
@@ -58,10 +53,7 @@ Vue.use(VueRouter)\n`
|
|
|
58
53
|
}
|
|
59
54
|
|
|
60
55
|
output += buildGlobalParams({
|
|
61
|
-
moduleId,
|
|
62
|
-
scriptSrcMode,
|
|
63
56
|
loaderContext,
|
|
64
|
-
isProduction,
|
|
65
57
|
jsonConfig,
|
|
66
58
|
webConfig,
|
|
67
59
|
isMain: true,
|
package/lib/web/script-helper.js
CHANGED
|
@@ -170,17 +170,18 @@ function buildGlobalParams ({
|
|
|
170
170
|
if (globalTabBar) {
|
|
171
171
|
content += globalTabBar
|
|
172
172
|
}
|
|
173
|
-
} else
|
|
174
|
-
|
|
175
|
-
global.__mpxGenericsMap = global.__mpxGenericsMap || {}
|
|
176
|
-
global.__mpxOptionsMap = global.__mpxOptionsMap || {}
|
|
177
|
-
global.__mpxTransRpxFn = ${webConfig.transRpxFn}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
173
|
+
} else {
|
|
174
|
+
if (!hasApp) {
|
|
175
|
+
content += ' global.__mpxGenericsMap = global.__mpxGenericsMap || {}\n'
|
|
176
|
+
content += ' global.__mpxOptionsMap = global.__mpxOptionsMap || {}\n'
|
|
177
|
+
content += ` global.__mpxTransRpxFn = ${webConfig.transRpxFn}\n`
|
|
178
|
+
}
|
|
179
|
+
content += ` global.currentModuleId = ${JSON.stringify(moduleId)}\n`
|
|
180
|
+
content += ` global.currentSrcMode = ${JSON.stringify(scriptSrcMode)}\n`
|
|
181
|
+
content += ` global.currentInject = ${JSON.stringify({ moduleId })}\n`
|
|
182
|
+
if (!isProduction) {
|
|
183
|
+
content += ` global.currentResource = ${JSON.stringify(loaderContext.resourcePath)}\n`
|
|
184
|
+
}
|
|
184
185
|
}
|
|
185
186
|
return content
|
|
186
187
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.48",
|
|
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": "
|
|
88
|
+
"gitHead": "f1bd7c32ec48c4401ab1bf68247bc68834ca932b"
|
|
89
89
|
}
|