assetImportMetaUrl.spec.ts — vite Source File
Architecture documentation for assetImportMetaUrl.spec.ts, a typescript file in the vite codebase. 8 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 1186ae5f_9c47_47d1_a997_97009f0e87d5["assetImportMetaUrl.spec.ts"] 08724e3d_5bec_d6ae_9e92_c1e2fe8f89da["assetImportMetaUrl.ts"] 1186ae5f_9c47_47d1_a997_97009f0e87d5 --> 08724e3d_5bec_d6ae_9e92_c1e2fe8f89da 33523ba7_f2f0_89b0_b6ac_912e8d2dc8bc["assetImportMetaUrlPlugin"] 1186ae5f_9c47_47d1_a997_97009f0e87d5 --> 33523ba7_f2f0_89b0_b6ac_912e8d2dc8bc 7da774f9_eca5_d54e_6e01_6bee7d460a2b["config.ts"] 1186ae5f_9c47_47d1_a997_97009f0e87d5 --> 7da774f9_eca5_d54e_6e01_6bee7d460a2b 58c4a210_68fe_1b4d_ed49_d59203f97ef1["resolveConfig"] 1186ae5f_9c47_47d1_a997_97009f0e87d5 --> 58c4a210_68fe_1b4d_ed49_d59203f97ef1 84057c57_14eb_2f16_cd5c_1899e8da6db0["baseEnvironment.ts"] 1186ae5f_9c47_47d1_a997_97009f0e87d5 --> 84057c57_14eb_2f16_cd5c_1899e8da6db0 dc928824_33f2_0b61_b231_90d8800b77a5["PartialEnvironment"] 1186ae5f_9c47_47d1_a997_97009f0e87d5 --> dc928824_33f2_0b61_b231_90d8800b77a5 a340ba46_b2b7_3048_3bb3_6907a74c8464["vitest"] 1186ae5f_9c47_47d1_a997_97009f0e87d5 --> a340ba46_b2b7_3048_3bb3_6907a74c8464 91052f78_b6ab_99f1_a964_0e21b06fe727["parseAst"] 1186ae5f_9c47_47d1_a997_97009f0e87d5 --> 91052f78_b6ab_99f1_a964_0e21b06fe727 style 1186ae5f_9c47_47d1_a997_97009f0e87d5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { describe, expect, test } from 'vitest'
import { parseAst } from 'rollup/parseAst'
import { assetImportMetaUrlPlugin } from '../../plugins/assetImportMetaUrl'
import { resolveConfig } from '../../config'
import { PartialEnvironment } from '../../baseEnvironment'
async function createAssetImportMetaurlPluginTransform() {
const config = await resolveConfig({ configFile: false }, 'serve')
const instance = assetImportMetaUrlPlugin(config)
const environment = new PartialEnvironment('client', config)
return async (code: string) => {
// @ts-expect-error transform.handler should exist
const result = await instance.transform.handler.call(
{ environment, parse: parseAst },
code,
'foo.ts',
)
return result?.code || result
}
}
describe('assetImportMetaUrlPlugin', async () => {
const transform = await createAssetImportMetaurlPluginTransform()
test('variable between /', async () => {
expect(
await transform('new URL(`./foo/${dir}/index.js`, import.meta.url)'),
).toMatchInlineSnapshot(
`"new URL((import.meta.glob("./foo/*/index.js", {"eager":true,"import":"default","query":"?url"}))[\`./foo/\${dir}/index.js\`], import.meta.url)"`,
)
})
test('variable before non-/', async () => {
expect(
await transform('new URL(`./foo/${dir}.js`, import.meta.url)'),
).toMatchInlineSnapshot(
`"new URL((import.meta.glob("./foo/*.js", {"eager":true,"import":"default","query":"?url"}))[\`./foo/\${dir}.js\`], import.meta.url)"`,
)
})
test('two variables', async () => {
expect(
await transform('new URL(`./foo/${dir}${file}.js`, import.meta.url)'),
).toMatchInlineSnapshot(
`"new URL((import.meta.glob("./foo/*.js", {"eager":true,"import":"default","query":"?url"}))[\`./foo/\${dir}\${file}.js\`], import.meta.url)"`,
)
})
test('two variables between /', async () => {
expect(
await transform(
'new URL(`./foo/${dir}${dir2}/index.js`, import.meta.url)',
),
).toMatchInlineSnapshot(
`"new URL((import.meta.glob("./foo/*/index.js", {"eager":true,"import":"default","query":"?url"}))[\`./foo/\${dir}\${dir2}/index.js\`], import.meta.url)"`,
)
})
test('ignore starting with a variable', async () => {
expect(
await transform('new URL(`${file}.js`, import.meta.url)'),
).toMatchInlineSnapshot(`"new URL(\`\${file}.js\`, import.meta.url)"`)
})
})
Domain
Subdomains
Dependencies
Source
Frequently Asked Questions
What does assetImportMetaUrl.spec.ts do?
assetImportMetaUrl.spec.ts is a source file in the vite codebase, written in typescript. It belongs to the ViteCore domain, ConfigEngine subdomain.
What functions are defined in assetImportMetaUrl.spec.ts?
assetImportMetaUrl.spec.ts defines 1 function(s): createAssetImportMetaurlPluginTransform.
What does assetImportMetaUrl.spec.ts depend on?
assetImportMetaUrl.spec.ts imports 8 module(s): PartialEnvironment, assetImportMetaUrl.ts, assetImportMetaUrlPlugin, baseEnvironment.ts, config.ts, parseAst, resolveConfig, vitest.
Where is assetImportMetaUrl.spec.ts in the architecture?
assetImportMetaUrl.spec.ts is located at packages/vite/src/node/__tests__/plugins/assetImportMetaUrl.spec.ts (domain: ViteCore, subdomain: ConfigEngine, directory: packages/vite/src/node/__tests__/plugins).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free