Skip to content

Commit 402f81e

Browse files
committedDec 31, 2019
feat(alita): 添加module chunks字段
1 parent f92a0f8 commit 402f81e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed
 

‎src/packByWebpack/WatchModuleUpdatedPlugin.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {setModuleDeps} from '../util/cacheModuleInfos'
1+
import {setModuleDepsAndChunks} from '../util/cacheModuleInfos'
22

33
import {handleChanged, handleDeleted} from '../extractWxCompFiles'
44

@@ -48,8 +48,8 @@ export default class WatchModuleUpdatedPlugin {
4848
compilation.hooks.additionalChunkAssets.tap(
4949
"WatchModuleUpdatedPlugin",
5050
() => {
51-
// 设置module deps的文件全路径,生成小程序json文件会使用到
52-
setAllModuleDeps(compilation)
51+
// 设置module deps,chunks,生成小程序json文件会使用到
52+
setAllModuleDepsAndChunks(compilation)
5353

5454
hanldeModuleChanged(compilation, handleChanged, handleDeleted)
5555
}
@@ -58,7 +58,7 @@ export default class WatchModuleUpdatedPlugin {
5858
}
5959
}
6060

61-
function setAllModuleDeps(compilation) {
61+
function setAllModuleDepsAndChunks(compilation) {
6262
const allModules = {}
6363
compilation.modules.forEach(m => {
6464
m.__deps = {}
@@ -76,7 +76,7 @@ function setAllModuleDeps(compilation) {
7676
})
7777

7878
compilation.modules.forEach(m => {
79-
setModuleDeps(m.resource, m.__deps)
79+
setModuleDepsAndChunks(m.resource, m.__deps, m.getChunks().map(c => c.name))
8080
})
8181
}
8282

‎src/util/cacheModuleInfos.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ interface IModuleInfo {
2121

2222
deps?: any,
2323

24+
chunks?: any,
25+
2426
}
2527

2628
interface IModuleInfos {
@@ -58,12 +60,13 @@ export function setEntryModuleInfo(filepath, entryInfo) {
5860
moduleInfos[filepath].entryInfo = entryInfo
5961
}
6062

61-
export function setModuleDeps(filepath, deps) {
63+
export function setModuleDepsAndChunks(filepath, deps, chunks) {
6264
if (!moduleInfos[filepath]) {
6365
moduleInfos[filepath] = {} as IModuleInfo
6466
}
6567

6668
moduleInfos[filepath].deps = deps
69+
moduleInfos[filepath].chunks = chunks
6770
}
6871

6972
export function getModuleInfo(filepath) {

0 commit comments

Comments
 (0)