diff --git a/packages/hap-packager/src/plugins/lite-card-plugin.js b/packages/hap-packager/src/plugins/lite-card-plugin.js index 8ffe11f..2706a00 100644 --- a/packages/hap-packager/src/plugins/lite-card-plugin.js +++ b/packages/hap-packager/src/plugins/lite-card-plugin.js @@ -40,13 +40,11 @@ class LiteCardPlugin { pathSrc = pathSrc.replace(/\\/g, '/') const moduleGraph = compilation.moduleGraph for (const chunk of compilation.chunks) { - const entryModule = chunk.entryModule + const entryModule = this.getEntryModule(compilation, chunk) if (!entryModule) { - // console.log('=== LiteCardPlugin no entry module:', chunk.name, entryModule) continue } const { rawRequest: entryRawRequest, request } = entryModule - // console.log('LiteCardPlugin >>> entryRawRequest:', entryRawRequest) if (this.isLightCard(entryRawRequest)) { const { templateFileName, cssFileName, bundleFilePath } = this.getLightCardBuildPath( request, @@ -259,6 +257,17 @@ class LiteCardPlugin { cssFileName: `${bundleFilePath}.css.json` } } + + getEntryModule(compilation, chunk) { + const chunkModules = compilation.chunkGraph.getChunkModules(chunk) + for (let i = 0; i < chunkModules.length; i++) { + const module = chunkModules[i] + if (compilation.chunkGraph.isEntryModuleInChunk(module, chunk)) { + return module + } + } + return null + } } const componentIdMap = new Map() diff --git a/packages/hap-packager/src/plugins/widget-fingerprint-plugin.js b/packages/hap-packager/src/plugins/widget-fingerprint-plugin.js index 14ac667..cf25dc0 100644 --- a/packages/hap-packager/src/plugins/widget-fingerprint-plugin.js +++ b/packages/hap-packager/src/plugins/widget-fingerprint-plugin.js @@ -69,7 +69,7 @@ class WidgetFingerprintPlugin { const widgetKey = widgetNameKeyMap[chunkName] const widgetDigestMap = {} const arr = [] - for (const module of chunk.modulesIterable) { + for (const module of compilation.chunkGraph.getChunkModules(chunk)) { const { _source, rawRequest, request } = module arr.push(rawRequest) if (!request) {