detectPolyfills() — vite Function Reference
Architecture documentation for the detectPolyfills() function in index.ts from the vite codebase.
Entity Profile
Dependency Diagram
graph TD 8f96a660_631f_d882_8813_44cfe1cdb28f["detectPolyfills()"] 9776ecb6_00c0_b3b9_b3f7_177fedabeacc["index.ts"] 8f96a660_631f_d882_8813_44cfe1cdb28f -->|defined in| 9776ecb6_00c0_b3b9_b3f7_177fedabeacc cf21e8d8_cce6_30a7_7732_696ed5cdf103["viteLegacyPlugin()"] cf21e8d8_cce6_30a7_7732_696ed5cdf103 -->|calls| 8f96a660_631f_d882_8813_44cfe1cdb28f b52618ce_8781_f4f2_b33b_cd2b4ed2b715["loadBabel()"] 8f96a660_631f_d882_8813_44cfe1cdb28f -->|calls| b52618ce_8781_f4f2_b33b_cd2b4ed2b715 style 8f96a660_631f_d882_8813_44cfe1cdb28f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/plugin-legacy/src/index.ts lines 788–832
export async function detectPolyfills(
code: string,
targets: any,
assumptions: Record<string, boolean>,
list: Set<string>,
): Promise<void> {
const babel = await loadBabel()
const result = babel.transform(code, {
ast: true,
code: false,
babelrc: false,
configFile: false,
compact: false,
targets,
assumptions,
browserslistConfigFile: false,
plugins: [
[
(await import('babel-plugin-polyfill-corejs3')).default,
{
method: 'usage-global',
version: _require('core-js/package.json').version,
shippedProposals: true,
},
],
[
(await import('babel-plugin-polyfill-regenerator')).default,
{
method: 'usage-global',
},
],
],
})
for (const node of result!.ast!.program.body) {
if (node.type === 'ImportDeclaration') {
const source = node.source.value
if (
source.startsWith('core-js/') ||
source.startsWith('regenerator-runtime/')
) {
list.add(source)
}
}
}
}
Domain
Subdomains
Defined In
Calls
Called By
Source
Frequently Asked Questions
What does detectPolyfills() do?
detectPolyfills() is a function in the vite codebase, defined in packages/plugin-legacy/src/index.ts.
Where is detectPolyfills() defined?
detectPolyfills() is defined in packages/plugin-legacy/src/index.ts at line 788.
What does detectPolyfills() call?
detectPolyfills() calls 1 function(s): loadBabel.
What calls detectPolyfills()?
detectPolyfills() is called by 1 function(s): viteLegacyPlugin.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free