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