@mpxjs/webpack-plugin 2.7.0-alpha.0 → 2.7.0-alpha.2
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/README.md +1 -1
- package/lib/config.js +14 -0
- package/lib/dependencies/AddEntryDependency.js +24 -0
- package/lib/dependencies/AppEntryDependency.js +2 -0
- package/lib/dependencies/CommonJsAsyncDependency.js +51 -0
- package/lib/dependencies/CommonJsVariableDependency.js +13 -6
- package/lib/dependencies/DynamicEntryDependency.js +85 -41
- package/lib/dependencies/FlagPluginDependency.js +1 -0
- package/lib/dependencies/RecordIndependentDependency.js +44 -0
- package/lib/dependencies/RecordResourceMapDependency.js +62 -0
- package/lib/dependencies/RemoveEntryDependency.js +40 -0
- package/lib/dependencies/ResolveDependency.js +11 -6
- package/lib/extractor.js +17 -7
- package/lib/file-loader.js +2 -2
- package/lib/helpers.js +6 -12
- package/lib/independent-loader.js +52 -0
- package/lib/index.js +595 -304
- package/lib/json-compiler/helper.js +36 -32
- package/lib/json-compiler/index.js +119 -66
- package/lib/json-compiler/plugin.js +23 -7
- package/lib/loader.js +135 -90
- package/lib/native-loader.js +37 -69
- package/lib/parser.js +1 -2
- package/lib/partial-compile/index.js +35 -0
- package/lib/platform/json/wx/index.js +8 -3
- package/lib/platform/template/normalize-component-rules.js +2 -3
- package/lib/platform/template/wx/component-config/button.js +17 -5
- package/lib/platform/template/wx/component-config/image.js +4 -0
- package/lib/platform/template/wx/component-config/input.js +4 -0
- package/lib/platform/template/wx/component-config/navigator.js +1 -1
- package/lib/platform/template/wx/component-config/rich-text.js +4 -0
- package/lib/platform/template/wx/component-config/scroll-view.js +4 -0
- package/lib/platform/template/wx/component-config/switch.js +4 -0
- package/lib/platform/template/wx/component-config/text.js +4 -0
- package/lib/platform/template/wx/component-config/textarea.js +5 -0
- package/lib/platform/template/wx/component-config/view.js +4 -0
- package/lib/platform/template/wx/index.js +149 -3
- package/lib/record-loader.js +2 -2
- package/lib/resolve-loader.js +4 -1
- package/lib/resolver/AddEnvPlugin.js +4 -3
- package/lib/resolver/AddModePlugin.js +4 -3
- package/lib/resolver/FixDescriptionInfoPlugin.js +28 -0
- package/lib/resolver/PackageEntryPlugin.js +23 -36
- package/lib/runtime/base.styl +5 -0
- package/lib/runtime/components/tenon/getInnerListeners.js +317 -0
- package/lib/runtime/components/tenon/tenon-button.vue +305 -0
- package/lib/runtime/components/tenon/tenon-image.vue +61 -0
- package/lib/runtime/components/tenon/tenon-input.vue +99 -0
- package/lib/runtime/components/tenon/tenon-rich-text.vue +21 -0
- package/lib/runtime/components/tenon/tenon-scroll-view.vue +124 -0
- package/lib/runtime/components/tenon/tenon-switch.vue +91 -0
- package/lib/runtime/components/tenon/tenon-text-area.vue +64 -0
- package/lib/runtime/components/tenon/tenon-text.vue +64 -0
- package/lib/runtime/components/tenon/tenon-view.vue +93 -0
- package/lib/runtime/components/tenon/util.js +44 -0
- package/lib/runtime/components/web/getInnerListeners.js +51 -45
- package/lib/runtime/components/web/mpx-image.vue +20 -5
- package/lib/runtime/components/web/mpx-keep-alive.vue +4 -1
- package/lib/runtime/components/web/mpx-movable-view.vue +6 -2
- package/lib/runtime/components/web/mpx-swiper.vue +37 -8
- package/lib/runtime/components/web/mpx-tab-bar-container.vue +2 -2
- package/lib/runtime/components/web/mpx-textarea.vue +1 -1
- package/lib/runtime/i18n.wxs +28 -8
- package/lib/runtime/optionProcessor.js +50 -20
- package/lib/runtime/optionProcessor.tenon.js +386 -0
- package/lib/runtime/stringify.wxs +6 -4
- package/lib/selector.js +23 -5
- package/lib/style-compiler/index.js +12 -13
- package/lib/style-compiler/load-postcss-config.js +3 -1
- package/lib/style-compiler/plugins/conditional-strip.js +68 -65
- package/lib/style-compiler/plugins/hm.js +20 -0
- package/lib/style-compiler/plugins/rpx.js +43 -37
- package/lib/style-compiler/plugins/scope-id.js +79 -72
- package/lib/style-compiler/plugins/trans-special.js +25 -18
- package/lib/style-compiler/plugins/trim.js +13 -7
- package/lib/style-compiler/plugins/vw.js +19 -12
- package/lib/template-compiler/bind-this.js +4 -4
- package/lib/template-compiler/compiler.js +172 -62
- package/lib/template-compiler/index.js +8 -9
- package/lib/template-compiler/trans-dynamic-class-expr.js +32 -22
- package/lib/tenon/index.js +105 -0
- package/lib/tenon/processJSON.js +356 -0
- package/lib/tenon/processScript.js +261 -0
- package/lib/tenon/processStyles.js +21 -0
- package/lib/tenon/processTemplate.js +133 -0
- package/lib/utils/const.js +6 -1
- package/lib/utils/eval-json-js.js +31 -0
- package/lib/utils/get-entry-name.js +3 -3
- package/lib/utils/get-json-content.js +42 -0
- package/lib/utils/get-relative-path.js +25 -0
- package/lib/utils/match-condition.js +4 -1
- package/lib/utils/normalize.js +4 -2
- package/lib/utils/resolve.js +13 -0
- package/lib/web/processJSON.js +113 -144
- package/lib/web/processScript.js +45 -38
- package/lib/web/processTemplate.js +56 -41
- package/lib/wxml/loader.js +1 -6
- package/lib/wxs/WxsModuleIdsPlugin.js +11 -14
- package/lib/wxs/i18n-loader.js +5 -4
- package/lib/wxs/loader.js +87 -56
- package/lib/wxs/pre-loader.js +30 -10
- package/lib/wxss/loader.js +3 -3
- package/lib/wxss/processCss.js +135 -131
- package/package.json +23 -17
- package/lib/built-in-loader.js +0 -49
- package/lib/dependencies/RecordStaticResourceDependency.js +0 -47
- package/lib/utils/get-main-compilation.js +0 -6
- package/lib/utils/read-json-for-src.js +0 -34
package/lib/helpers.js
CHANGED
|
@@ -4,14 +4,6 @@ const selectorPath = normalize.lib('selector')
|
|
|
4
4
|
const addQuery = require('./utils/add-query')
|
|
5
5
|
const parseRequest = require('./utils/parse-request')
|
|
6
6
|
|
|
7
|
-
function getRawRequest ({ resource, loaderIndex, loaders }, excludedPreLoaders = /eslint-loader/) {
|
|
8
|
-
return loaderUtils.getRemainingRequest({
|
|
9
|
-
resource: resource,
|
|
10
|
-
loaderIndex: loaderIndex,
|
|
11
|
-
loaders: loaders.filter(loader => !excludedPreLoaders.test(loader.path))
|
|
12
|
-
})
|
|
13
|
-
}
|
|
14
|
-
|
|
15
7
|
const defaultLang = {
|
|
16
8
|
template: 'wxml',
|
|
17
9
|
styles: 'wxss',
|
|
@@ -21,7 +13,8 @@ const defaultLang = {
|
|
|
21
13
|
}
|
|
22
14
|
|
|
23
15
|
module.exports = function createHelpers (loaderContext) {
|
|
24
|
-
const rawRequest =
|
|
16
|
+
const rawRequest = loaderUtils.getRemainingRequest(loaderContext)
|
|
17
|
+
const { resourcePath, queryObj } = parseRequest(loaderContext.resource)
|
|
25
18
|
|
|
26
19
|
function getRequire (type, part, extraOptions, index) {
|
|
27
20
|
return 'require(' + getRequestString(type, part, extraOptions, index) + ')'
|
|
@@ -43,9 +36,9 @@ module.exports = function createHelpers (loaderContext) {
|
|
|
43
36
|
|
|
44
37
|
function getFakeRequest (type, part) {
|
|
45
38
|
const lang = part.lang || defaultLang[type] || type
|
|
46
|
-
const {
|
|
47
|
-
if (lang === 'json')
|
|
48
|
-
return addQuery(`${resourcePath}.${lang}`,
|
|
39
|
+
const options = { ...queryObj }
|
|
40
|
+
if (lang === 'json') options.asScript = true
|
|
41
|
+
return addQuery(`${resourcePath}.${lang}`, options)
|
|
49
42
|
}
|
|
50
43
|
|
|
51
44
|
function getRequestString (type, part, extraOptions = {}, index = 0) {
|
|
@@ -60,6 +53,7 @@ module.exports = function createHelpers (loaderContext) {
|
|
|
60
53
|
switch (type) {
|
|
61
54
|
case 'json':
|
|
62
55
|
options.asScript = true
|
|
56
|
+
if (part.useJSONJS) options.useJSONJS = true
|
|
63
57
|
// eslint-disable-next-line no-fallthrough
|
|
64
58
|
case 'styles':
|
|
65
59
|
case 'template':
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const parseComponent = require('./parser')
|
|
2
|
+
const createHelpers = require('./helpers')
|
|
3
|
+
const CommonJsVariableDependency = require('./dependencies/CommonJsVariableDependency')
|
|
4
|
+
const path = require('path')
|
|
5
|
+
const normalize = require('./utils/normalize')
|
|
6
|
+
|
|
7
|
+
module.exports = function (content) {
|
|
8
|
+
this.cacheable()
|
|
9
|
+
const mpx = this.getMpx()
|
|
10
|
+
if (!mpx) {
|
|
11
|
+
return content
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const mode = mpx.mode
|
|
15
|
+
const env = mpx.env
|
|
16
|
+
const i18n = mpx.i18n
|
|
17
|
+
const filePath = this.resourcePath
|
|
18
|
+
const extname = path.extname(filePath)
|
|
19
|
+
if (extname === '.mpx') {
|
|
20
|
+
const parts = parseComponent(content, {
|
|
21
|
+
filePath,
|
|
22
|
+
needMap: this.sourceMap,
|
|
23
|
+
mode,
|
|
24
|
+
env
|
|
25
|
+
})
|
|
26
|
+
const {
|
|
27
|
+
getRequire
|
|
28
|
+
} = createHelpers(this)
|
|
29
|
+
|
|
30
|
+
if (parts.script) {
|
|
31
|
+
content = getRequire('script', parts.script)
|
|
32
|
+
} else {
|
|
33
|
+
content = ''
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
let output = 'global.isIndependent = true\n'
|
|
38
|
+
// 注入i18n
|
|
39
|
+
if (i18n) {
|
|
40
|
+
const i18nWxsPath = normalize.lib('runtime/i18n.wxs')
|
|
41
|
+
const i18nWxsLoaderPath = normalize.lib('wxs/i18n-loader.js')
|
|
42
|
+
const i18nWxsRequest = i18nWxsLoaderPath + '!' + i18nWxsPath
|
|
43
|
+
this._module.addDependency(new CommonJsVariableDependency(i18nWxsRequest))
|
|
44
|
+
// 避免该模块被concatenate导致注入的i18n没有最先执行
|
|
45
|
+
this._module.buildInfo.moduleConcatenationBailout = 'i18n'
|
|
46
|
+
}
|
|
47
|
+
output += content
|
|
48
|
+
output += '\n'
|
|
49
|
+
output += 'delete global.isIndependent\n'
|
|
50
|
+
|
|
51
|
+
return output
|
|
52
|
+
}
|