Skip to content

Commit 203b8af

Browse files
fix: update deprecated API for webpack modules (#75)
Signed-off-by: Yingchun <zhangyingchun@oppo.com>
1 parent 1de02bf commit 203b8af

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

packages/hap-packager/src/plugins/lite-card-plugin.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,11 @@ class LiteCardPlugin {
4040
pathSrc = pathSrc.replace(/\\/g, '/')
4141
const moduleGraph = compilation.moduleGraph
4242
for (const chunk of compilation.chunks) {
43-
const entryModule = chunk.entryModule
43+
const entryModule = this.getEntryModule(compilation, chunk)
4444
if (!entryModule) {
45-
// console.log('=== LiteCardPlugin no entry module:', chunk.name, entryModule)
4645
continue
4746
}
4847
const { rawRequest: entryRawRequest, request } = entryModule
49-
// console.log('LiteCardPlugin >>> entryRawRequest:', entryRawRequest)
5048
if (this.isLightCard(entryRawRequest)) {
5149
const { templateFileName, cssFileName, bundleFilePath } = this.getLightCardBuildPath(
5250
request,
@@ -259,6 +257,17 @@ class LiteCardPlugin {
259257
cssFileName: `${bundleFilePath}.css.json`
260258
}
261259
}
260+
261+
getEntryModule(compilation, chunk) {
262+
const chunkModules = compilation.chunkGraph.getChunkModules(chunk)
263+
for (let i = 0; i < chunkModules.length; i++) {
264+
const module = chunkModules[i]
265+
if (compilation.chunkGraph.isEntryModuleInChunk(module, chunk)) {
266+
return module
267+
}
268+
}
269+
return null
270+
}
262271
}
263272

264273
const componentIdMap = new Map()

packages/hap-packager/src/plugins/widget-fingerprint-plugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class WidgetFingerprintPlugin {
6969
const widgetKey = widgetNameKeyMap[chunkName]
7070
const widgetDigestMap = {}
7171
const arr = []
72-
for (const module of chunk.modulesIterable) {
72+
for (const module of compilation.chunkGraph.getChunkModules(chunk)) {
7373
const { _source, rawRequest, request } = module
7474
arr.push(rawRequest)
7575
if (!request) {

0 commit comments

Comments
 (0)