@mpxjs/webpack-plugin 2.6.114-alpha.8 → 2.6.115
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/built-in-loader.js +49 -0
- package/lib/config.js +0 -14
- package/lib/content-loader.js +13 -0
- package/lib/dependency/ChildCompileDependency.js +24 -0
- package/lib/dependency/InjectDependency.js +26 -0
- package/lib/dependency/RemovedModuleDependency.js +23 -0
- package/lib/{dependencies → dependency}/ReplaceDependency.js +2 -19
- package/lib/dependency/ResolveDependency.js +49 -0
- package/lib/extractor.js +178 -82
- package/lib/file-loader.js +19 -7
- package/lib/helpers.js +334 -39
- package/lib/index.js +525 -889
- package/lib/json-compiler/index.js +451 -245
- package/lib/json-compiler/{theme.js → theme-loader.js} +3 -5
- package/lib/loader.js +241 -178
- package/lib/native-loader.js +133 -71
- package/lib/parser.js +2 -1
- package/lib/path-loader.js +3 -0
- package/lib/platform/json/wx/index.js +1 -1
- package/lib/platform/template/normalize-component-rules.js +3 -2
- package/lib/platform/template/wx/component-config/button.js +2 -14
- package/lib/platform/template/wx/component-config/image.js +0 -4
- package/lib/platform/template/wx/component-config/input.js +0 -4
- package/lib/platform/template/wx/component-config/rich-text.js +0 -4
- package/lib/platform/template/wx/component-config/scroll-view.js +0 -4
- package/lib/platform/template/wx/component-config/switch.js +0 -4
- package/lib/platform/template/wx/component-config/text.js +0 -4
- package/lib/platform/template/wx/component-config/textarea.js +0 -5
- package/lib/platform/template/wx/component-config/view.js +0 -4
- package/lib/platform/template/wx/index.js +3 -149
- package/lib/plugin-loader.js +287 -0
- package/lib/resolver/AddEnvPlugin.js +3 -4
- package/lib/resolver/AddModePlugin.js +3 -4
- package/lib/resolver/PackageEntryPlugin.js +36 -23
- package/lib/runtime/base.styl +0 -5
- package/lib/runtime/components/web/getInnerListeners.js +3 -1
- package/lib/runtime/components/web/mpx-image.vue +5 -20
- package/lib/runtime/components/web/mpx-movable-view.vue +2 -6
- package/lib/runtime/components/web/mpx-swiper.vue +3 -18
- package/lib/runtime/i18n.wxs +11 -31
- package/lib/runtime/optionProcessor.js +3 -48
- package/lib/selector.js +10 -29
- package/lib/staticConfig.js +4 -0
- package/lib/style-compiler/index.js +24 -16
- package/lib/style-compiler/load-postcss-config.js +1 -3
- package/lib/style-compiler/plugins/conditional-strip.js +65 -68
- package/lib/style-compiler/plugins/rpx.js +37 -43
- package/lib/style-compiler/plugins/scope-id.js +72 -79
- package/lib/style-compiler/plugins/trans-special.js +18 -25
- package/lib/style-compiler/plugins/trim.js +7 -13
- package/lib/style-compiler/plugins/vw.js +16 -22
- package/lib/template-compiler/compiler.js +199 -106
- package/lib/template-compiler/index.js +139 -52
- package/lib/template-compiler/trans-dynamic-class-expr.js +13 -18
- package/lib/url-loader.js +29 -11
- package/lib/utils/add-query.js +1 -1
- package/lib/utils/get-main-compilation.js +6 -0
- package/lib/utils/is-url-request.js +1 -10
- package/lib/utils/match-condition.js +1 -4
- package/lib/utils/normalize.js +15 -4
- package/lib/utils/parse-request.js +3 -3
- package/lib/utils/read-json-for-src.js +34 -0
- package/lib/utils/stringify-query.js +0 -4
- package/lib/utils/try-require.js +16 -0
- package/lib/web/processJSON.js +144 -113
- package/lib/web/processScript.js +34 -47
- package/lib/web/processTemplate.js +40 -57
- package/lib/wxml/{loader.js → wxml-loader.js} +62 -21
- package/lib/wxs/WxsParserPlugin.js +2 -2
- package/lib/wxs/WxsPlugin.js +8 -4
- package/lib/wxs/WxsTemplatePlugin.js +92 -46
- package/lib/wxs/{i18n-loader.js → wxs-i18n-loader.js} +4 -5
- package/lib/wxs/wxs-loader.js +117 -0
- package/lib/wxs/{pre-loader.js → wxs-pre-loader.js} +5 -20
- package/lib/wxss/getImportPrefix.js +30 -0
- package/lib/wxss/loader.js +43 -31
- package/lib/wxss/localsLoader.js +5 -1
- package/lib/wxss/processCss.js +103 -107
- package/package.json +18 -21
- package/LICENSE +0 -433
- package/lib/dependencies/AddEntryDependency.js +0 -24
- package/lib/dependencies/AppEntryDependency.js +0 -58
- package/lib/dependencies/CommonJsAsyncDependency.js +0 -51
- package/lib/dependencies/CommonJsVariableDependency.js +0 -81
- package/lib/dependencies/DynamicEntryDependency.js +0 -171
- package/lib/dependencies/FlagPluginDependency.js +0 -24
- package/lib/dependencies/InjectDependency.js +0 -43
- package/lib/dependencies/RecordGlobalComponentsDependency.js +0 -50
- package/lib/dependencies/RecordIndependentDependency.js +0 -44
- package/lib/dependencies/RecordResourceMapDependency.js +0 -62
- package/lib/dependencies/RemoveEntryDependency.js +0 -40
- package/lib/dependencies/ResolveDependency.js +0 -88
- package/lib/independent-loader.js +0 -52
- package/lib/json-compiler/helper.js +0 -156
- package/lib/json-compiler/plugin.js +0 -150
- package/lib/partial-compile/index.js +0 -35
- package/lib/record-loader.js +0 -11
- package/lib/resolve-loader.js +0 -6
- package/lib/resolver/FixDescriptionInfoPlugin.js +0 -28
- package/lib/runtime/components/tenon/getInnerListeners.js +0 -317
- package/lib/runtime/components/tenon/tenon-button.vue +0 -305
- package/lib/runtime/components/tenon/tenon-image.vue +0 -61
- package/lib/runtime/components/tenon/tenon-input.vue +0 -99
- package/lib/runtime/components/tenon/tenon-rich-text.vue +0 -21
- package/lib/runtime/components/tenon/tenon-scroll-view.vue +0 -124
- package/lib/runtime/components/tenon/tenon-switch.vue +0 -91
- package/lib/runtime/components/tenon/tenon-text-area.vue +0 -64
- package/lib/runtime/components/tenon/tenon-text.vue +0 -64
- package/lib/runtime/components/tenon/tenon-view.vue +0 -93
- package/lib/runtime/components/tenon/util.js +0 -44
- package/lib/runtime/optionProcessor.tenon.js +0 -386
- package/lib/style-compiler/plugins/hm.js +0 -20
- package/lib/tenon/index.js +0 -105
- package/lib/tenon/processJSON.js +0 -360
- package/lib/tenon/processScript.js +0 -260
- package/lib/tenon/processStyles.js +0 -21
- package/lib/tenon/processTemplate.js +0 -133
- package/lib/utils/const.js +0 -10
- package/lib/utils/emit-file.js +0 -10
- package/lib/utils/eval-json-js.js +0 -31
- package/lib/utils/get-entry-name.js +0 -13
- package/lib/utils/get-json-content.js +0 -42
- package/lib/utils/get-relative-path.js +0 -24
- package/lib/utils/resolve.js +0 -13
- package/lib/utils/set.js +0 -47
- package/lib/utils/stringify-loaders-resource.js +0 -25
- package/lib/wxs/WxsModuleIdsPlugin.js +0 -29
- package/lib/wxs/loader.js +0 -142
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const normalize = require('../utils/normalize')
|
|
3
|
-
const nativeLoaderPath = normalize.lib('native-loader')
|
|
4
|
-
const isUrlRequestRaw = require('../utils/is-url-request')
|
|
5
|
-
const parseRequest = require('../utils/parse-request')
|
|
6
|
-
const addQuery = require('../utils/add-query')
|
|
7
|
-
const loaderUtils = require('loader-utils')
|
|
8
|
-
const resolve = require('../utils/resolve')
|
|
9
|
-
|
|
10
|
-
module.exports = function createJSONHelper ({ loaderContext, emitWarning, customGetDynamicEntry }) {
|
|
11
|
-
const mpx = loaderContext.getMpx()
|
|
12
|
-
const resolveMode = mpx.resolveMode
|
|
13
|
-
const externals = mpx.externals
|
|
14
|
-
const root = mpx.projectRoot
|
|
15
|
-
const publicPath = (loaderContext._compilation && loaderContext._compilation.outputOptions.publicPath) || ''
|
|
16
|
-
const pathHash = mpx.pathHash
|
|
17
|
-
const getOutputPath = mpx.getOutputPath
|
|
18
|
-
const mode = mpx.mode
|
|
19
|
-
|
|
20
|
-
const isUrlRequest = r => isUrlRequestRaw(r, root, externals)
|
|
21
|
-
const urlToRequest = r => loaderUtils.urlToRequest(r)
|
|
22
|
-
|
|
23
|
-
const dynamicEntryMap = new Map()
|
|
24
|
-
|
|
25
|
-
let dynamicEntryCount = 0
|
|
26
|
-
|
|
27
|
-
const getDynamicEntry = (request, type, outputPath = '', packageRoot = '', relativePath = '', context = '') => {
|
|
28
|
-
if (typeof customGetDynamicEntry === 'function') return customGetDynamicEntry(request, type, outputPath, packageRoot, relativePath, context)
|
|
29
|
-
const key = `mpx_dynamic_entry_${dynamicEntryCount++}`
|
|
30
|
-
const value = `__mpx_dynamic_entry__( ${JSON.stringify(request)},${JSON.stringify(type)},${JSON.stringify(outputPath)},${JSON.stringify(packageRoot)},${JSON.stringify(relativePath)},${JSON.stringify(context)})`
|
|
31
|
-
dynamicEntryMap.set(key, value)
|
|
32
|
-
return key
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const processDynamicEntry = (output) => {
|
|
36
|
-
return output.replace(/"mpx_dynamic_entry_\d+"/g, (match) => {
|
|
37
|
-
const key = match.slice(1, -1)
|
|
38
|
-
return dynamicEntryMap.get(key)
|
|
39
|
-
})
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const processComponent = (component, context, { tarRoot = '', outputPath = '', relativePath = '' }, callback) => {
|
|
43
|
-
if (!isUrlRequest(component)) return callback(null, component)
|
|
44
|
-
if (resolveMode === 'native') {
|
|
45
|
-
component = urlToRequest(component)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
resolve(context, component, loaderContext, (err, resource, info) => {
|
|
49
|
-
if (err) return callback(err)
|
|
50
|
-
const { resourcePath, queryObj } = parseRequest(resource)
|
|
51
|
-
|
|
52
|
-
if (queryObj.root) {
|
|
53
|
-
// 删除root query
|
|
54
|
-
resource = addQuery(resource, {}, false, ['root'])
|
|
55
|
-
// 目前只有微信支持分包异步化
|
|
56
|
-
if (mode === 'wx') tarRoot = queryObj.root
|
|
57
|
-
}
|
|
58
|
-
const parsed = path.parse(resourcePath)
|
|
59
|
-
const ext = parsed.ext
|
|
60
|
-
const resourceName = path.join(parsed.dir, parsed.name)
|
|
61
|
-
|
|
62
|
-
if (!outputPath) {
|
|
63
|
-
if (ext === '.js' && resourceName.includes('node_modules') && mode !== 'web') {
|
|
64
|
-
let root = info.descriptionFileRoot
|
|
65
|
-
let name = 'nativeComponent'
|
|
66
|
-
if (info.descriptionFileData) {
|
|
67
|
-
if (info.descriptionFileData.miniprogram) {
|
|
68
|
-
root = path.join(root, info.descriptionFileData.miniprogram)
|
|
69
|
-
}
|
|
70
|
-
if (info.descriptionFileData.name) {
|
|
71
|
-
// 去掉name里面的@符号,因为支付宝不支持文件路径上有@
|
|
72
|
-
name = info.descriptionFileData.name.replace(/@/g, '')
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
let relative = path.relative(root, resourceName)
|
|
76
|
-
outputPath = path.join('components', name + pathHash(root), relative)
|
|
77
|
-
} else {
|
|
78
|
-
outputPath = getOutputPath(resourcePath, 'component')
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (ext === '.js' && mode !== 'web') {
|
|
82
|
-
resource = `!!${nativeLoaderPath}!${resource}`
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const entry = getDynamicEntry(resource, 'component', outputPath, tarRoot, relativePath)
|
|
86
|
-
callback(null, entry)
|
|
87
|
-
})
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const processPage = (page, context, tarRoot = '', callback) => {
|
|
91
|
-
let aliasPath = ''
|
|
92
|
-
if (typeof page !== 'string') {
|
|
93
|
-
aliasPath = page.path
|
|
94
|
-
page = page.src
|
|
95
|
-
}
|
|
96
|
-
if (!isUrlRequest(page)) return callback(null, page)
|
|
97
|
-
if (resolveMode === 'native') {
|
|
98
|
-
page = urlToRequest(page)
|
|
99
|
-
}
|
|
100
|
-
// 增加 page 标识
|
|
101
|
-
page = addQuery(page, { isPage: true })
|
|
102
|
-
resolve(context, page, loaderContext, (err, resource) => {
|
|
103
|
-
if (err) return callback(err)
|
|
104
|
-
const { resourcePath, queryObj: { isFirst } } = parseRequest(resource)
|
|
105
|
-
const ext = path.extname(resourcePath)
|
|
106
|
-
let outputPath
|
|
107
|
-
if (aliasPath) {
|
|
108
|
-
outputPath = aliasPath.replace(/^\//, '')
|
|
109
|
-
} else {
|
|
110
|
-
const relative = path.relative(context, resourcePath)
|
|
111
|
-
if (/^\./.test(relative)) {
|
|
112
|
-
// 如果当前page不存在于context中,对其进行重命名
|
|
113
|
-
outputPath = getOutputPath(resourcePath, 'page')
|
|
114
|
-
emitWarning(`Current page [${resourcePath}] is not in current pages directory [${context}], the page path will be replaced with [${outputPath}], use ?resolve to get the page path and navigate to it!`)
|
|
115
|
-
} else {
|
|
116
|
-
outputPath = /^(.*?)(\.[^.]*)?$/.exec(relative)[1]
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (ext === '.js' && mode !== 'web') {
|
|
120
|
-
resource = `!!${nativeLoaderPath}!${resource}`
|
|
121
|
-
}
|
|
122
|
-
const entry = getDynamicEntry(resource, 'page', outputPath, tarRoot, publicPath + tarRoot)
|
|
123
|
-
const key = [resourcePath, outputPath, tarRoot].join('|')
|
|
124
|
-
callback(null, entry, {
|
|
125
|
-
isFirst,
|
|
126
|
-
key
|
|
127
|
-
})
|
|
128
|
-
})
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const processJsExport = (js, context, tarRoot = '', callback) => {
|
|
132
|
-
if (resolveMode === 'native') {
|
|
133
|
-
js = urlToRequest(js)
|
|
134
|
-
}
|
|
135
|
-
resolve(context, js, loaderContext, (err, resource) => {
|
|
136
|
-
if (err) return callback(err)
|
|
137
|
-
const { resourcePath } = parseRequest(resource)
|
|
138
|
-
const relative = path.relative(context, resourcePath)
|
|
139
|
-
if (/^\./.test(relative)) {
|
|
140
|
-
return callback(new Error(`The js export path ${resourcePath} must be in the context ${context}!`))
|
|
141
|
-
}
|
|
142
|
-
const outputPath = /^(.*?)(\.[^.]*)?$/.exec(relative)[1]
|
|
143
|
-
const entry = getDynamicEntry(resource, 'export', outputPath, tarRoot, publicPath + tarRoot)
|
|
144
|
-
callback(null, entry)
|
|
145
|
-
})
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return {
|
|
149
|
-
processComponent,
|
|
150
|
-
processDynamicEntry,
|
|
151
|
-
processPage,
|
|
152
|
-
processJsExport,
|
|
153
|
-
isUrlRequest,
|
|
154
|
-
urlToRequest
|
|
155
|
-
}
|
|
156
|
-
}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
const async = require('async')
|
|
2
|
-
const JSON5 = require('json5')
|
|
3
|
-
const getEntryName = require('../utils/get-entry-name')
|
|
4
|
-
const FlagPluginDependency = require('../dependencies/FlagPluginDependency')
|
|
5
|
-
const RemoveEntryDependency = require('../dependencies/RemoveEntryDependency')
|
|
6
|
-
const createJSONHelper = require('./helper')
|
|
7
|
-
const { MPX_DISABLE_EXTRACTOR_CACHE, RESOLVE_IGNORED_ERR } = require('../utils/const')
|
|
8
|
-
|
|
9
|
-
module.exports = function (source) {
|
|
10
|
-
// 该loader中会在每次编译中动态添加entry,不能缓存,否则watch不好使
|
|
11
|
-
const nativeCallback = this.async()
|
|
12
|
-
|
|
13
|
-
const mpx = this.getMpx()
|
|
14
|
-
|
|
15
|
-
if (!mpx) {
|
|
16
|
-
return nativeCallback(null, source)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// json模块必须每次都创建(但并不是每次都需要build),用于动态添加编译入口,传递信息以禁用父级extractor的缓存
|
|
20
|
-
this.emitFile(MPX_DISABLE_EXTRACTOR_CACHE, '', undefined, { skipEmit: true })
|
|
21
|
-
|
|
22
|
-
this._module.addPresentationalDependency(new FlagPluginDependency())
|
|
23
|
-
|
|
24
|
-
const emitWarning = (msg) => {
|
|
25
|
-
this.emitWarning(
|
|
26
|
-
new Error('[plugin loader][' + this.resource + ']: ' + msg)
|
|
27
|
-
)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const emitError = (msg) => {
|
|
31
|
-
this.emitError(
|
|
32
|
-
new Error('[plugin loader][' + this.resource + ']: ' + msg)
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const {
|
|
37
|
-
processPage,
|
|
38
|
-
processDynamicEntry,
|
|
39
|
-
processComponent,
|
|
40
|
-
processJsExport
|
|
41
|
-
} = createJSONHelper({
|
|
42
|
-
loaderContext: this,
|
|
43
|
-
emitWarning,
|
|
44
|
-
emitError
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
const context = this.context
|
|
48
|
-
const relativePath = this._compilation.outputOptions.publicPath || ''
|
|
49
|
-
const mode = mpx.mode
|
|
50
|
-
const srcMode = mpx.srcMode
|
|
51
|
-
const entryName = getEntryName(this)
|
|
52
|
-
// 最终输出中不需要为plugin.json产生chunk,而是使用extractor输出,删除plugin.json对应的entrypoint
|
|
53
|
-
if (entryName) this._module.addPresentationalDependency(new RemoveEntryDependency(entryName))
|
|
54
|
-
|
|
55
|
-
// 新模式下plugin.json输出依赖于extractor
|
|
56
|
-
const callback = (err, processOutput) => {
|
|
57
|
-
if (err) return nativeCallback(err)
|
|
58
|
-
let output = `var pluginEntry = ${JSON.stringify(pluginEntry, null, 2)};\n`
|
|
59
|
-
if (processOutput) output = processOutput(output)
|
|
60
|
-
output += `module.exports = JSON.stringify(pluginEntry, null, 2);\n`
|
|
61
|
-
nativeCallback(null, output)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
let pluginEntry
|
|
65
|
-
try {
|
|
66
|
-
pluginEntry = JSON5.parse(source)
|
|
67
|
-
} catch (err) {
|
|
68
|
-
return callback(err)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const processMain = (main, callback) => {
|
|
72
|
-
if (!main) return callback()
|
|
73
|
-
processJsExport(main, context, '', (err, entry) => {
|
|
74
|
-
if (err === RESOLVE_IGNORED_ERR) {
|
|
75
|
-
delete pluginEntry.main
|
|
76
|
-
return callback()
|
|
77
|
-
}
|
|
78
|
-
if (err) return callback(err)
|
|
79
|
-
pluginEntry.main = entry
|
|
80
|
-
callback()
|
|
81
|
-
})
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const processComponents = (components, callback) => {
|
|
85
|
-
if (!components) return callback()
|
|
86
|
-
async.eachOf(components, (component, name, callback) => {
|
|
87
|
-
processComponent(component, context, { relativePath }, (err, entry) => {
|
|
88
|
-
if (err === RESOLVE_IGNORED_ERR) {
|
|
89
|
-
delete components[name]
|
|
90
|
-
return callback()
|
|
91
|
-
}
|
|
92
|
-
if (err) return callback(err)
|
|
93
|
-
components[name] = entry
|
|
94
|
-
callback()
|
|
95
|
-
})
|
|
96
|
-
}, callback)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const processPages = (pages, callback) => {
|
|
100
|
-
if (!pages) return callback()
|
|
101
|
-
if (srcMode === 'ali') {
|
|
102
|
-
const reversedMap = {}
|
|
103
|
-
const publicPages = pluginEntry.publicPages || {}
|
|
104
|
-
Object.keys(publicPages).forEach((key) => {
|
|
105
|
-
const item = publicPages[key]
|
|
106
|
-
reversedMap[item] = key
|
|
107
|
-
})
|
|
108
|
-
pages = pages.reduce((page, target, index) => {
|
|
109
|
-
const key = reversedMap[page] || `__private_page_${index}__`
|
|
110
|
-
target[key] = page
|
|
111
|
-
}, {})
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
if (mode === 'ali') {
|
|
115
|
-
pluginEntry.publicPages = {}
|
|
116
|
-
pluginEntry.pages = []
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
async.eachOf(pages, (page, key, callback) => {
|
|
120
|
-
processPage(page, context, '', (err, entry) => {
|
|
121
|
-
if (err === RESOLVE_IGNORED_ERR) {
|
|
122
|
-
delete pages[key]
|
|
123
|
-
return callback()
|
|
124
|
-
}
|
|
125
|
-
if (err) return callback(err)
|
|
126
|
-
if (mode === 'ali') {
|
|
127
|
-
pluginEntry.pages.push(entry)
|
|
128
|
-
if (!/^__private_page_\d+__$/.test(key)) {
|
|
129
|
-
pluginEntry.publicPages[key] = entry
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
132
|
-
pages[key] = entry
|
|
133
|
-
}
|
|
134
|
-
callback()
|
|
135
|
-
})
|
|
136
|
-
}, callback)
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
async.parallel([
|
|
140
|
-
(callback) => {
|
|
141
|
-
return processMain(pluginEntry.main, callback)
|
|
142
|
-
}, (callback) => {
|
|
143
|
-
return processComponents(pluginEntry.publicComponents, callback)
|
|
144
|
-
}, (callback) => {
|
|
145
|
-
return processPages(pluginEntry.pages, callback)
|
|
146
|
-
}
|
|
147
|
-
], (err) => {
|
|
148
|
-
return callback(err, processDynamicEntry)
|
|
149
|
-
})
|
|
150
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
const { matchCondition } = require('../utils/match-condition')
|
|
2
|
-
const { parseQuery } = require('loader-utils')
|
|
3
|
-
|
|
4
|
-
class MpxPartialCompilePlugin {
|
|
5
|
-
constructor (condition) {
|
|
6
|
-
this.condition = condition
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
isResolvingPage (obj) {
|
|
10
|
-
// valid query should start with '?'
|
|
11
|
-
const query = obj.query || '?'
|
|
12
|
-
return parseQuery(query).isPage
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
apply (compiler) {
|
|
16
|
-
compiler.resolverFactory.hooks.resolver.intercept({
|
|
17
|
-
factory: (type, hook) => {
|
|
18
|
-
hook.tap('MpxPartialCompilePlugin', (resolver) => {
|
|
19
|
-
resolver.hooks.result.tapAsync({
|
|
20
|
-
name: 'MpxPartialCompilePlugin',
|
|
21
|
-
stage: -100
|
|
22
|
-
}, (obj, resolverContext, callback) => {
|
|
23
|
-
if (this.isResolvingPage(obj) && !matchCondition(obj.path, this.condition)) {
|
|
24
|
-
obj.path = false
|
|
25
|
-
}
|
|
26
|
-
callback(null, obj)
|
|
27
|
-
})
|
|
28
|
-
})
|
|
29
|
-
return hook
|
|
30
|
-
}
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
module.exports = MpxPartialCompilePlugin
|
package/lib/record-loader.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const parseRequest = require('./utils/parse-request')
|
|
2
|
-
const RecordResourceMapDependency = require('./dependencies/RecordResourceMapDependency')
|
|
3
|
-
|
|
4
|
-
module.exports = function (source) {
|
|
5
|
-
const mpx = this.getMpx()
|
|
6
|
-
const { resourcePath, queryObj } = parseRequest(this.resource)
|
|
7
|
-
const file = mpx.getExtractedFile(this.resource)
|
|
8
|
-
const packageRoot = queryObj.packageRoot || ''
|
|
9
|
-
this._module.addPresentationalDependency(new RecordResourceMapDependency(resourcePath, 'staticResource', file, packageRoot))
|
|
10
|
-
return source
|
|
11
|
-
}
|
package/lib/resolve-loader.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
|
|
3
|
-
module.exports = class FixDescriptionInfoPlugin {
|
|
4
|
-
apply (resolver) {
|
|
5
|
-
resolver.hooks.result.tap('FixDescriptionInfoPlugin', (request) => {
|
|
6
|
-
const { path: resourcePath } = request
|
|
7
|
-
const segments = resourcePath.split(path.sep)
|
|
8
|
-
let rootIndex = -1
|
|
9
|
-
for (let i = segments.length - 1; i >= 0; i--) {
|
|
10
|
-
const segment = segments[i]
|
|
11
|
-
if (segment === 'node_modules') {
|
|
12
|
-
rootIndex = segments[i + 1].startsWith('@') ? i + 2 : i + 1
|
|
13
|
-
break
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
if (rootIndex !== -1) {
|
|
17
|
-
const descriptionFileRoot = segments.slice(0, rootIndex + 1).join(path.sep)
|
|
18
|
-
const descriptionFilePath = path.join(descriptionFileRoot, 'package.json')
|
|
19
|
-
if (descriptionFilePath !== request.descriptionFilePath) {
|
|
20
|
-
Object.assign(request, {
|
|
21
|
-
descriptionFileRoot,
|
|
22
|
-
descriptionFilePath
|
|
23
|
-
})
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
}
|
|
28
|
-
}
|