Skip to content

Commit

Permalink
fix(transformer/helper-loader): incorrect SymbolFlags for default i…
Browse files Browse the repository at this point in the history
…mport when `SourceType` is script (#7226)
  • Loading branch information
Dunqing committed Nov 9, 2024
1 parent b4258ee commit eea4ab8
Show file tree
Hide file tree
Showing 4 changed files with 1,896 additions and 41,027 deletions.
7 changes: 6 additions & 1 deletion crates/oxc_transformer/src/common/helper_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,12 @@ impl<'a> HelperLoaderStore<'a> {
source.push_str(helper_name);
let source = Atom::from(source.into_bump_str());

let binding = ctx.generate_uid_in_root_scope(helper_name, SymbolFlags::Import);
let flag = if transform_ctx.source_type.is_module() {
SymbolFlags::Import
} else {
SymbolFlags::FunctionScopedVariable
};
let binding = ctx.generate_uid_in_root_scope(helper_name, flag);

transform_ctx.module_imports.add_default_import(source, binding.clone(), false);

Expand Down
Loading

0 comments on commit eea4ab8

Please sign in to comment.