File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -533,16 +533,23 @@ impl Module for ExternalModule {
533533
534534 async fn build (
535535 & mut self ,
536- _build_context : BuildContext ,
536+ build_context : BuildContext ,
537537 _: Option < & Compilation > ,
538538 ) -> Result < BuildResult > {
539+ self . build_info . module = build_context. compiler_options . output . module ;
539540 let resolved_external_type = self . resolve_external_type ( ) ;
540541
541542 // TODO add exports_type for request
542543 match resolved_external_type {
543544 "this" => self . build_info . strict = false ,
544545 "system" => self . build_meta . exports_type = BuildMetaExportsType :: Namespace ,
545- "module" => self . build_meta . exports_type = BuildMetaExportsType :: Namespace ,
546+ "module" => {
547+ self . build_meta . exports_type = BuildMetaExportsType :: Namespace ;
548+ // align with https://github.com/webpack/webpack/blob/3919c844eca394d73ca930e4fc5506fb86e2b094/lib/ExternalModule.js#L597
549+ if !self . build_info . module {
550+ self . build_meta . has_top_level_await = true ;
551+ }
552+ }
546553 "script" | "promise" => self . build_meta . has_top_level_await = true ,
547554 "import" => {
548555 self . build_meta . has_top_level_await = true ;
Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ pub struct BuildInfo {
6868 pub top_level_declarations : Option < HashSet < Atom > > ,
6969 pub module_concatenation_bailout : Option < String > ,
7070 pub assets : HashMap < String , CompilationAsset > ,
71+ pub module : bool ,
7172}
7273
7374impl Default for BuildInfo {
@@ -87,6 +88,7 @@ impl Default for BuildInfo {
8788 top_level_declarations : None ,
8889 module_concatenation_bailout : None ,
8990 assets : Default :: default ( ) ,
91+ module : false ,
9092 }
9193 }
9294}
@@ -168,6 +170,7 @@ impl Display for ExportsArgument {
168170#[ serde( rename_all = "camelCase" ) ]
169171pub struct BuildMeta {
170172 pub strict_esm_module : bool ,
173+ // same as is_async https://github.com/webpack/webpack/blob/3919c844eca394d73ca930e4fc5506fb86e2b094/lib/Module.js#L107
171174 pub has_top_level_await : bool ,
172175 pub esm : bool ,
173176 pub exports_type : BuildMetaExportsType ,
You can’t perform that action at this time.
0 commit comments