1mod auto_imports;
19mod dynamic_imports;
20pub(crate) mod fallbacks;
21pub(crate) mod inline_loaders;
22mod jsx_runtime;
23mod memo;
24mod output_entry;
25mod package_credit;
26mod path_info;
27mod re_exports;
28mod react_native;
29mod require_imports;
30mod specifier;
31mod static_imports;
32#[cfg(test)]
33mod tests;
34mod types;
35mod upgrades;
36mod work;
37mod workspace_alias;
38
39pub use auto_imports::{UnreadableAutoImportRead, unreadable_auto_import_reads};
40pub use fallbacks::extract_package_name_from_node_modules_path;
41pub use inline_loaders::InlineLoaderRequest;
42pub use output_entry::{directory_index_entry, output_entry_to_source_path};
43pub use path_info::{
44 extract_package_name, is_bare_specifier, is_path_alias, is_valid_package_name,
45 normalize_npm_specifier,
46};
47pub use react_native::{PlatformFamilyKey, has_react_native_plugin, platform_family_key};
48pub use types::{
49 MISSING_ONLY_OUTPUT_DIRS, MissingExportTarget, OUTPUT_DIRS, ResolveResult, ResolvedImport,
50 ResolvedModule, ResolvedProject, ResolvedReExport, ResolvedReplacedModuleTarget,
51 ResolvedSourceEdge,
52};
53pub use work::ResolveWork;
54
55use std::sync::Arc;
56
57use std::path::{Path, PathBuf};
58use std::sync::Mutex;
59
60use rayon::prelude::*;
61use rustc_hash::{FxHashMap, FxHashSet};
62
63use fallow_config::{AutoImportKind, AutoImportRule, JsxImportSourceRule};
64use fallow_types::discover::{DiscoveredFile, FileId};
65use fallow_types::extract::{ImportInfo, ImportedName, ModuleInfo, SemanticFact};
66use oxc_span::Span;
67
68use auto_imports::synthesize_auto_import_edges;
69use dynamic_imports::{GlobMatcherCache, resolve_dynamic_imports, resolve_dynamic_patterns};
70use jsx_runtime::resolve_config_jsx_runtime_imports;
71pub use jsx_runtime::{CompiledJsxRule, compile_jsx_rules};
72use re_exports::resolve_re_exports;
73use react_native::{build_condition_names, build_extensions, synthesize_platform_family_edges};
74use require_imports::resolve_require_imports;
75use specifier::{build_resolve_options, create_resolver};
76use static_imports::resolve_static_imports;
77use types::{DenoImportMapEntry, PackageManifestInfo, ResolveContext};
78use upgrades::{ResolvedVitestMockOperation, apply_specifier_upgrades};
79
80pub struct ResolveAllImportsInput<'a> {
82 pub modules: &'a [ModuleInfo],
84 pub files: &'a [DiscoveredFile],
86 pub workspaces: &'a [fallow_config::WorkspaceInfo],
88 pub active_plugins: &'a [String],
90 pub path_aliases: &'a [(String, String)],
92 pub auto_imports: &'a [AutoImportRule],
94 pub jsx_import_sources: &'a [JsxImportSourceRule],
97 pub scss_include_paths: &'a [PathBuf],
99 pub static_dir_mappings: &'a [(PathBuf, String)],
101 pub framework_static_dir_mappings: &'a [(PathBuf, String)],
103 pub root: &'a Path,
105 pub extra_conditions: &'a [String],
107}
108
109pub struct ResolverSession {
120 resolver: oxc_resolver::Resolver,
121 script_resolver: oxc_resolver::Resolver,
122 style_resolver: oxc_resolver::Resolver,
123 extensions: Vec<String>,
124 condition_names: Vec<String>,
125 package_manifests: Vec<PackageManifestInfo>,
126 has_deno_import_maps: bool,
127 canonical_ws_roots: Vec<PathBuf>,
128 root_is_canonical: bool,
129}
130
131impl ResolverSession {
132 #[must_use]
140 pub fn new(input: &ResolveAllImportsInput<'_>) -> Self {
141 let canonical_ws_roots: Vec<PathBuf> = input
142 .workspaces
143 .par_iter()
144 .map(|ws| dunce::canonicalize(&ws.root).unwrap_or_else(|_| ws.root.clone()))
145 .collect();
146 let package_manifests = build_package_manifests(input, &canonical_ws_roots);
147 let has_deno_import_maps = package_manifests
148 .iter()
149 .any(|manifest| !manifest.deno_import_map.is_empty());
150 let root_is_canonical = dunce::canonicalize(input.root).is_ok_and(|c| c == input.root);
151
152 let extensions = build_extensions(input.active_plugins);
153 let condition_names = build_condition_names(input.active_plugins, input.extra_conditions);
154 let resolver = create_resolver(input.root, input.active_plugins, input.extra_conditions);
155 let script_resolver = specifier::create_script_resolver(&resolver);
156 let mut style_conditions = input.extra_conditions.to_vec();
157 style_conditions.push("sass".to_string());
158 style_conditions.push("style".to_string());
159 let style_resolver = resolver.clone_with_options(build_resolve_options(
162 input.root,
163 input.active_plugins,
164 &style_conditions,
165 ));
166
167 Self {
168 resolver,
169 script_resolver,
170 style_resolver,
171 extensions,
172 condition_names,
173 package_manifests,
174 has_deno_import_maps,
175 canonical_ws_roots,
176 root_is_canonical,
177 }
178 }
179}
180
181#[must_use]
183pub fn resolve_all_imports(input: &ResolveAllImportsInput<'_>) -> ResolvedProject {
184 let session = ResolverSession::new(input);
185 resolve_all_imports_with_session(input, &session)
186}
187
188#[must_use]
196pub fn resolve_all_imports_with_session(
197 input: &ResolveAllImportsInput<'_>,
198 session: &ResolverSession,
199) -> ResolvedProject {
200 let root_is_canonical = session.root_is_canonical;
201 let workspace_roots = build_workspace_roots(input.workspaces, &session.canonical_ws_roots);
202 let canonical_paths = build_canonical_file_paths(input.files, root_is_canonical);
203 let mut work = ResolveWork {
204 canonicalize_calls: canonical_paths.len() as u64,
205 ..ResolveWork::default()
206 };
207 let path_to_id = build_path_to_id(input.files, &canonical_paths, root_is_canonical);
208 let raw_path_to_id: FxHashMap<&Path, FileId> = input
209 .files
210 .iter()
211 .map(|f| (f.path.as_path(), f.id))
212 .collect();
213
214 let file_paths: Vec<&Path> = input.files.iter().map(|f| f.path.as_path()).collect();
215
216 let canonical_fallback = if root_is_canonical {
217 Some(types::CanonicalFallback::new(input.files))
218 } else {
219 None
220 };
221
222 let tsconfig_warned: Mutex<FxHashSet<String>> = Mutex::new(FxHashSet::default());
223 let tsconfig_cache = types::TsconfigCache::default();
224 let canonicalize_cache = types::CanonicalizeCache::default();
225 let glob_matcher_cache = GlobMatcherCache::default();
226 let pattern_root = if canonical_paths.is_empty() {
230 input.root.to_path_buf()
231 } else {
232 dunce::canonicalize(input.root).unwrap_or_else(|_| input.root.to_path_buf())
233 };
234 let jsx_rules = compile_jsx_rules(input.jsx_import_sources);
235
236 let ctx = ResolveContext {
237 resolver: &session.resolver,
238 script_resolver: &session.script_resolver,
239 style_resolver: &session.style_resolver,
240 extensions: &session.extensions,
241 path_to_id: &path_to_id,
242 raw_path_to_id: &raw_path_to_id,
243 workspace_roots: &workspace_roots,
244 package_manifests: &session.package_manifests,
245 has_deno_import_maps: session.has_deno_import_maps,
246 condition_names: &session.condition_names,
247 path_aliases: input.path_aliases,
248 scss_include_paths: input.scss_include_paths,
249 static_dir_mappings: input.static_dir_mappings,
250 framework_static_dir_mappings: input.framework_static_dir_mappings,
251 root: input.root,
252 canonical_fallback: canonical_fallback.as_ref(),
253 tsconfig_warned: &tsconfig_warned,
254 tsconfig_cache: &tsconfig_cache,
255 canonicalize_cache: &canonicalize_cache,
256 };
257
258 let resolved_outputs: Vec<ResolvedModuleOutput> = input
259 .modules
260 .par_iter()
261 .filter_map(|module| {
262 resolve_module_imports(
263 module,
264 &ctx,
265 &ProjectResolveRules {
266 glob_matcher_cache: &glob_matcher_cache,
267 pattern_root: &pattern_root,
268 jsx_rules: &jsx_rules,
269 },
270 &file_paths,
271 &canonical_paths,
272 input.files,
273 )
274 })
275 .collect();
276 let mut resolved = Vec::with_capacity(resolved_outputs.len());
277 let mut vitest_mock_operations = Vec::new();
278 for output in resolved_outputs {
279 resolved.push(output.module);
280 vitest_mock_operations.extend(output.vitest_mock_operations);
281 work += output.work;
282 }
283 work.canonicalize_calls += canonicalize_cache.distinct_paths() as u64;
284
285 apply_specifier_upgrades(&mut resolved, &mut vitest_mock_operations);
286
287 synthesize_platform_family_edges(&mut resolved, input.files, input.active_plugins);
288
289 synthesize_auto_import_edges(
290 &mut resolved,
291 input.modules,
292 input.auto_imports,
293 &path_to_id,
294 &raw_path_to_id,
295 );
296
297 let replaced_module_targets = final_replaced_module_targets(vitest_mock_operations);
298
299 ResolvedProject {
300 modules: resolved,
301 replaced_module_targets,
302 work,
303 }
304}
305
306fn build_workspace_roots<'a>(
307 workspaces: &'a [fallow_config::WorkspaceInfo],
308 canonical_ws_roots: &'a [PathBuf],
309) -> FxHashMap<&'a str, &'a Path> {
310 workspaces
311 .iter()
312 .zip(canonical_ws_roots.iter())
313 .map(|(ws, canonical)| (ws.name.as_str(), canonical.as_path()))
314 .collect()
315}
316
317fn build_canonical_file_paths(files: &[DiscoveredFile], root_is_canonical: bool) -> Vec<PathBuf> {
318 if root_is_canonical {
319 return Vec::new();
320 }
321
322 files
323 .par_iter()
324 .map(|f| dunce::canonicalize(&f.path).unwrap_or_else(|_| f.path.clone()))
325 .collect()
326}
327
328fn build_package_manifests(
335 input: &ResolveAllImportsInput<'_>,
336 canonical_ws_roots: &[PathBuf],
337) -> Vec<PackageManifestInfo> {
338 let root_canonical =
339 dunce::canonicalize(input.root).unwrap_or_else(|_| input.root.to_path_buf());
340 let root_probe = fallow_config::probe_dir_manifest(input.root);
341 let root_import_map = merge_deno_import_maps(&[], input.root, root_probe.deno_import_map);
342 let mut package_manifests = Vec::new();
343 if let Ok(Some((_name, package_json, _deps))) = root_probe.manifest {
344 package_manifests.push(PackageManifestInfo {
345 root: input.root.to_path_buf(),
346 canonical_root: root_canonical,
347 name: package_json.name.clone(),
348 package_json,
349 deno_import_map: root_import_map.clone(),
350 });
351 }
352 for (ws, canonical_root) in input.workspaces.iter().zip(canonical_ws_roots.iter()) {
353 let ws_probe = fallow_config::probe_dir_manifest(&ws.root);
354 if let Ok(Some((_name, package_json, _deps))) = ws_probe.manifest {
355 package_manifests.push(PackageManifestInfo {
356 root: ws.root.clone(),
357 canonical_root: canonical_root.clone(),
358 name: package_json.name.clone().or_else(|| Some(ws.name.clone())),
359 package_json,
360 deno_import_map: merge_deno_import_maps(
361 &root_import_map,
362 &ws.root,
363 ws_probe.deno_import_map,
364 ),
365 });
366 }
367 }
368 package_manifests
369}
370
371fn merge_deno_import_maps(
377 inherited: &[DenoImportMapEntry],
378 package_root: &Path,
379 local: Option<(PathBuf, Vec<(String, String)>)>,
380) -> Vec<DenoImportMapEntry> {
381 let mut entries: FxHashMap<String, DenoImportMapEntry> = inherited
382 .iter()
383 .cloned()
384 .map(|entry| (entry.key.clone(), entry))
385 .collect();
386
387 if let Some((config_path, local_entries)) = local {
388 let declaring_dir = config_path.parent().unwrap_or(package_root).to_path_buf();
389 for (key, target) in local_entries {
390 entries.insert(
391 key.clone(),
392 DenoImportMapEntry {
393 key,
394 target,
395 declaring_dir: declaring_dir.clone(),
396 },
397 );
398 }
399 }
400
401 let mut entries: Vec<_> = entries.into_values().collect();
402 entries.sort_by(|a, b| a.key.cmp(&b.key));
403 entries
404}
405
406fn build_path_to_id<'a>(
409 files: &'a [DiscoveredFile],
410 canonical_paths: &'a [PathBuf],
411 root_is_canonical: bool,
412) -> FxHashMap<&'a Path, FileId> {
413 if root_is_canonical {
414 files.iter().map(|f| (f.path.as_path(), f.id)).collect()
415 } else {
416 canonical_paths
417 .iter()
418 .enumerate()
419 .map(|(idx, canonical)| (canonical.as_path(), files[idx].id))
420 .collect()
421 }
422}
423
424struct ProjectResolveRules<'a> {
426 glob_matcher_cache: &'a GlobMatcherCache,
427 pattern_root: &'a Path,
428 jsx_rules: &'a [CompiledJsxRule<'a>],
429}
430
431fn resolve_module_imports(
432 module: &ModuleInfo,
433 ctx: &ResolveContext<'_>,
434 rules: &ProjectResolveRules<'_>,
435 file_paths: &[&Path],
436 canonical_paths: &[PathBuf],
437 files: &[DiscoveredFile],
438) -> Option<ResolvedModuleOutput> {
439 let Some(file_path) = file_paths.get(module.file_id.0 as usize) else {
440 tracing::warn!(
441 file_id = module.file_id.0,
442 "Skipping module with unknown file_id during resolution"
443 );
444 return None;
445 };
446
447 let resolve = || {
448 let mut all_imports = resolve_static_imports(ctx, file_path, &module.imports);
449 all_imports.extend(resolve_config_jsx_runtime_imports(
450 ctx,
451 file_path,
452 module,
453 rules.jsx_rules,
454 ));
455 all_imports.extend(resolve_require_imports(
456 ctx,
457 file_path,
458 &module.require_calls,
459 ));
460
461 let from_dir = if canonical_paths.is_empty() {
462 file_path.parent().unwrap_or(file_path)
463 } else {
464 canonical_paths
465 .get(module.file_id.0 as usize)
466 .and_then(|p| p.parent())
467 .unwrap_or(file_path)
468 };
469
470 let vitest_mock_operations =
471 resolve_vitest_mock_operations(module.file_id, &module.semantic_facts, ctx, file_path);
472 let module = build_resolved_module(ResolvedModuleBuildInput {
473 module,
474 ctx,
475 glob_matcher_cache: rules.glob_matcher_cache,
476 pattern_root: rules.pattern_root,
477 file_path,
478 from_dir,
479 canonical_paths,
480 files,
481 all_imports,
482 });
483 (module, vitest_mock_operations)
484 };
485 let ((module, vitest_mock_operations), work) =
486 memo::in_file_scope(file_path, || work::in_module_scope(resolve));
487
488 Some(ResolvedModuleOutput {
489 module,
490 vitest_mock_operations,
491 work,
492 })
493}
494
495struct ResolvedModuleOutput {
496 module: ResolvedModule,
497 vitest_mock_operations: Vec<ResolvedVitestMockOperation>,
498 work: ResolveWork,
499}
500
501fn resolve_vitest_mock_operations(
502 source_file: FileId,
503 semantic_facts: &[SemanticFact],
504 ctx: &ResolveContext<'_>,
505 file_path: &Path,
506) -> Vec<ResolvedVitestMockOperation> {
507 let mut operations: Vec<_> = semantic_facts
508 .iter()
509 .filter_map(|fact| {
510 let SemanticFact::VitestModuleMockOperation(operation) = fact else {
511 return None;
512 };
513 Some(ResolvedVitestMockOperation {
514 source_file,
515 source_specifier: operation.source.clone(),
516 call_start: operation.call_start,
517 action: operation.action,
518 target: specifier::resolve_import_specifier(
519 ctx,
520 file_path,
521 &operation.source,
522 false,
523 ),
524 })
525 })
526 .collect();
527 operations.sort_unstable_by(|left, right| {
528 left.call_start
529 .cmp(&right.call_start)
530 .then_with(|| left.source_specifier.cmp(&right.source_specifier))
531 });
532 operations
533}
534
535fn final_replaced_module_targets(
536 mut operations: Vec<ResolvedVitestMockOperation>,
537) -> Vec<ResolvedReplacedModuleTarget> {
538 operations.sort_unstable_by(|left, right| {
539 left.source_file
540 .0
541 .cmp(&right.source_file.0)
542 .then_with(|| left.call_start.cmp(&right.call_start))
543 .then_with(|| left.source_specifier.cmp(&right.source_specifier))
544 });
545
546 let mut final_operations = FxHashMap::default();
547 for operation in operations {
548 let Some(target_file) = operation.target.internal_file_id() else {
549 continue;
550 };
551 final_operations.insert((operation.source_file, target_file), operation.action);
552 }
553
554 let mut targets: Vec<_> = final_operations
555 .into_iter()
556 .filter_map(|((source_file, target_file), action)| {
557 action
558 .replaces_original()
559 .then_some(ResolvedReplacedModuleTarget {
560 source_file,
561 target_file,
562 })
563 })
564 .collect();
565 targets.sort_unstable_by_key(|target| (target.source_file.0, target.target_file.0));
566 targets
567}
568
569struct ResolvedModuleBuildInput<'a> {
570 module: &'a ModuleInfo,
571 ctx: &'a ResolveContext<'a>,
572 glob_matcher_cache: &'a GlobMatcherCache,
573 pattern_root: &'a Path,
574 file_path: &'a Path,
575 from_dir: &'a Path,
576 canonical_paths: &'a [PathBuf],
577 files: &'a [DiscoveredFile],
578 all_imports: Vec<types::ResolvedImport>,
579}
580
581fn build_resolved_module(input: ResolvedModuleBuildInput<'_>) -> ResolvedModule {
582 let ctx = input.ctx;
583 let mut module = resolved_module_without_export_hints(input);
584 module.missing_export_targets = collect_missing_export_targets(ctx, &module);
585 module
586}
587
588fn collect_missing_export_targets(
590 ctx: &ResolveContext<'_>,
591 module: &ResolvedModule,
592) -> Vec<MissingExportTarget> {
593 let mut seen: FxHashSet<&str> = FxHashSet::default();
594 let mut targets: Vec<MissingExportTarget> = module
595 .all_resolved_source_edges()
596 .filter_map(|edge| match edge.target() {
597 ResolveResult::Unresolvable(specifier) => Some(specifier.as_str()),
598 _ => None,
599 })
600 .filter(|specifier| seen.insert(specifier))
601 .filter_map(|specifier| {
602 let aliased = workspace_alias::aliased_specifier(ctx, &module.path, specifier);
603 fallbacks::missing_package_export_paths(ctx, aliased.as_deref().unwrap_or(specifier))
604 .map(|paths| MissingExportTarget {
605 specifier: specifier.to_string(),
606 paths,
607 })
608 })
609 .collect();
610 targets.sort_unstable_by(|left, right| left.specifier.cmp(&right.specifier));
611 targets
612}
613
614fn resolved_module_without_export_hints(input: ResolvedModuleBuildInput<'_>) -> ResolvedModule {
615 ResolvedModule {
616 file_id: input.module.file_id,
617 path: input.file_path.to_path_buf(),
618 exports: Arc::clone(&input.module.exports),
619 re_exports: resolve_re_exports(input.ctx, input.file_path, &input.module.re_exports),
620 resolved_imports: input.all_imports,
621 resolved_dynamic_imports: resolve_dynamic_imports(
622 input.ctx,
623 input.file_path,
624 &input.module.dynamic_imports,
625 ),
626 resolved_dynamic_patterns: resolve_dynamic_patterns(
627 input.glob_matcher_cache,
628 input.pattern_root,
629 input.from_dir,
630 &input.module.dynamic_import_patterns,
631 input.canonical_paths,
632 input.files,
633 ),
634 member_accesses: Arc::clone(&input.module.member_accesses),
635 semantic_facts: Arc::clone(&input.module.semantic_facts),
636 whole_object_uses: Arc::clone(&input.module.whole_object_uses),
637 has_cjs_exports: input.module.has_cjs_exports,
638 has_angular_component_template_url: input.module.has_angular_component_template_url,
639 unused_import_bindings: input
640 .module
641 .unused_import_bindings
642 .iter()
643 .cloned()
644 .collect(),
645 type_referenced_import_bindings: input.module.type_referenced_import_bindings.clone(),
646 value_referenced_import_bindings: input.module.value_referenced_import_bindings.clone(),
647 namespace_object_aliases: input.module.namespace_object_aliases.clone(),
648 exported_factory_returns: Arc::clone(&input.module.exported_factory_returns),
649 exported_factory_return_object_shapes: Arc::clone(
650 &input.module.exported_factory_return_object_shapes,
651 ),
652 type_member_types: Arc::clone(&input.module.type_member_types),
653 missing_export_targets: Vec::new(),
654 }
655}
656
657fn is_auto_import_builtin(name: &str) -> bool {
658 is_js_auto_import_builtin(name)
659 || is_vue_auto_import_builtin(name)
660 || is_nuxt_auto_import_builtin(name)
661}
662
663fn is_js_auto_import_builtin(name: &str) -> bool {
664 matches!(
665 name,
666 "AbortController"
667 | "AbortSignal"
668 | "Array"
669 | "ArrayBuffer"
670 | "BigInt"
671 | "Blob"
672 | "Boolean"
673 | "Buffer"
674 | "CSS"
675 | "DOMParser"
676 | "Date"
677 | "Document"
678 | "Error"
679 | "Event"
680 | "EventTarget"
681 | "File"
682 | "FormData"
683 | "Intl"
684 | "JSON"
685 | "Map"
686 | "Math"
687 | "Number"
688 | "Object"
689 | "Promise"
690 | "Reflect"
691 | "RegExp"
692 | "Response"
693 | "Set"
694 | "String"
695 | "Symbol"
696 | "URL"
697 | "URLSearchParams"
698 | "WeakMap"
699 | "WeakSet"
700 | "Window"
701 | "alert"
702 | "clearInterval"
703 | "clearTimeout"
704 | "console"
705 | "document"
706 | "fetch"
707 | "global"
708 | "globalThis"
709 | "localStorage"
710 | "navigator"
711 | "process"
712 | "requestAnimationFrame"
713 | "sessionStorage"
714 | "setInterval"
715 | "setTimeout"
716 | "window"
717 )
718}
719
720fn is_vue_auto_import_builtin(name: &str) -> bool {
721 matches!(name, |"computed"| "customRef"
722 | "defineAsyncComponent"
723 | "defineComponent"
724 | "effectScope"
725 | "getCurrentInstance"
726 | "h"
727 | "inject"
728 | "isProxy"
729 | "isReactive"
730 | "isReadonly"
731 | "isRef"
732 | "markRaw"
733 | "nextTick"
734 | "onActivated"
735 | "onBeforeMount"
736 | "onBeforeUnmount"
737 | "onBeforeUpdate"
738 | "onDeactivated"
739 | "onErrorCaptured"
740 | "onMounted"
741 | "onRenderTracked"
742 | "onRenderTriggered"
743 | "onScopeDispose"
744 | "onServerPrefetch"
745 | "onUnmounted"
746 | "onUpdated"
747 | "provide"
748 | "reactive"
749 | "readonly"
750 | "ref"
751 | "resolveComponent"
752 | "shallowReactive"
753 | "shallowReadonly"
754 | "shallowRef"
755 | "toRaw"
756 | "toRef"
757 | "toRefs"
758 | "triggerRef"
759 | "unref"
760 | "watch"
761 | "watchEffect"
762 | "watchPostEffect"
763 | "watchSyncEffect")
764}
765
766fn is_nuxt_auto_import_builtin(name: &str) -> bool {
767 matches!(name, |"useAsyncData"| "useCookie"
768 | "useError"
769 | "useFetch"
770 | "useHead"
771 | "useLazyAsyncData"
772 | "useLazyFetch"
773 | "useNuxtApp"
774 | "useRequestEvent"
775 | "useRequestHeaders"
776 | "useRoute"
777 | "useRouter"
778 | "useRuntimeConfig"
779 | "useSeoMeta"
780 | "useState")
781}
782
783fn synthetic_auto_import_info(name: &str, kind: AutoImportKind) -> ImportInfo {
786 let imported_name = match kind {
787 AutoImportKind::Named => ImportedName::Named(name.to_string()),
788 AutoImportKind::Default | AutoImportKind::DefaultComponent => ImportedName::Default,
789 };
790 ImportInfo {
791 source: format!("<auto-import:{name}>"),
792 imported_name,
793 local_name: name.to_string(),
794 is_type_only: false,
795 is_type_only_star: false,
796 from_style: false,
797 span: Span::default(),
798 source_span: Span::default(),
799 }
800}