MCPcopy
hub / github.com/vitejs/vite / resolve

Function resolve

packages/vite/src/node/idResolver.ts:52–86  ·  view source on GitHub ↗
(
    environment: PartialEnvironment,
    id: string,
    importer?: string,
  )

Source from the content-addressed store, hash-verified

50 EnvironmentPluginContainer
51 >()
52 async function resolve(
53 environment: PartialEnvironment,
54 id: string,
55 importer?: string,
56 ): Promise<PartialResolvedId | null> {
57 let pluginContainer = pluginContainerMap.get(environment)
58 if (!pluginContainer) {
59 pluginContainer = await createEnvironmentPluginContainer(
60 environment as Environment,
61 [
62 // @ts-expect-error the aliasPlugin uses rollup types
63 aliasPlugin({ entries: environment.config.resolve.alias }),
64 ...oxcResolvePlugin(
65 {
66 root: config.root,
67 isProduction: config.isProduction,
68 isBuild: config.command === 'build',
69 asSrc: true,
70 preferRelative: false,
71 tryIndex: true,
72 ...options,
73 // Ignore sideEffects and other computations as we only need the id
74 idOnly: true,
75 },
76 environment.config,
77 true,
78 ),
79 ],
80 undefined,
81 false,
82 )
83 pluginContainerMap.set(environment, pluginContainer)
84 }
85 return await pluginContainer.resolveId(id, importer, { scan })
86 }
87
88 const aliasOnlyPluginContainerMap = new Map<
89 PartialEnvironment,

Callers 1

Calls 5

oxcResolvePluginFunction · 0.90
getMethod · 0.45
setMethod · 0.45
resolveIdMethod · 0.45

Tested by

no test coverage detected