@@ -60,6 +60,7 @@ const getMatchModuleGlobCondition = memoize(
6060/** @import RequestShortener from "../util/RequestShortener" */
6161/** @import { ResolverWithOptions } from "../resolve/ResolverFactory" */
6262/** @import ESMImportDependency from "../dependencies/esm/ESMImportDependency" */
63+ /** @import { JavascriptModuleBuildMeta } from "../javascript/JavascriptModule" */
6364/** @import Hash from "../util/Hash" */
6465/** @import { InputFileSystem } from "../fs/fs" */
6566
@@ -235,8 +236,9 @@ class LazyCompilationProxyModule extends Module {
235236 * @param {ModuleResult["client"] } client client
236237 * @param {ModuleResult["data"] } data data
237238 * @param {ModuleResult["active"] } active true when active, otherwise false
239+ * @param {boolean } strict whether its importers are strict ES modules
238240 */
239- constructor ( context , originalModule , request , client , data , active ) {
241+ constructor ( context , originalModule , request , client , data , active , strict ) {
240242 super (
241243 WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY ,
242244 context ,
@@ -255,14 +257,16 @@ class LazyCompilationProxyModule extends Module {
255257 this . data = data ;
256258 /** @type {boolean } */
257259 this . active = active ;
260+ /** @type {boolean } */
261+ this . strict = strict ;
258262 }
259263
260264 /**
261265 * Returns the unique identifier used to reference this module.
262266 * @returns {string } a unique identifier of the module
263267 */
264268 identifier ( ) {
265- return `${ WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY } |${ this . originalModule . identifier ( ) } ` ;
269+ return `${ WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY } |${ this . originalModule . identifier ( ) } ${ this . strict ? "|strict" : "" } ` ;
266270 }
267271
268272 /**
@@ -291,6 +295,7 @@ class LazyCompilationProxyModule extends Module {
291295 this . client = m . client ;
292296 this . data = m . data ;
293297 this . active = m . active ;
298+ this . strict = m . strict ;
294299 }
295300
296301 /**
@@ -419,7 +424,7 @@ class LazyCompilationProxyModule extends Module {
419424 module,
420425 request : this . request ,
421426 dependency : dep ,
422- strict : false , // TODO this should be inherited from the original module
427+ strict : this . strict ,
423428 message : "import()" ,
424429 runtimeRequirements,
425430 originModule : this
@@ -622,14 +627,26 @@ class LazyCompilationPlugin {
622627 const moduleInfo = backend . module ( module ) ;
623628 if ( ! moduleInfo ) return module ;
624629 const { client, data, active } = moduleInfo ;
630+ // The proxy builds the namespace its importers get, and a strict ES module
631+ // importer needs another shape than a loose one, so each gets its own proxy.
632+ const importer = compilation . moduleGraph . getParentModule (
633+ resolveData . dependencies [ 0 ]
634+ ) ;
635+ const strict = Boolean (
636+ importer &&
637+ importer . buildMeta &&
638+ /** @type {JavascriptModuleBuildMeta } */ ( importer . buildMeta )
639+ . strictHarmonyModule
640+ ) ;
625641
626642 return new LazyCompilationProxyModule (
627643 compiler . context ,
628644 module ,
629645 resolveData . request ,
630646 client ,
631647 data ,
632- active
648+ active ,
649+ strict
633650 ) ;
634651 }
635652 ) ;
0 commit comments