parse.spec.ts — vite Source File
Architecture documentation for parse.spec.ts, a typescript file in the vite codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR bd61be4f_3dcc_2549_1583_12f4a8f96cd1["parse.spec.ts"] e962fae7_53df_5265_a6c6_b9cfe28d06e1["dynamicImportVars.ts"] bd61be4f_3dcc_2549_1583_12f4a8f96cd1 --> e962fae7_53df_5265_a6c6_b9cfe28d06e1 c8ee919d_d03e_b4e1_7f6d_c4e274847312["transformDynamicImport"] bd61be4f_3dcc_2549_1583_12f4a8f96cd1 --> c8ee919d_d03e_b4e1_7f6d_c4e274847312 031bc221_67a8_c579_f2bf_bb30a08beeb2["utils.ts"] bd61be4f_3dcc_2549_1583_12f4a8f96cd1 --> 031bc221_67a8_c579_f2bf_bb30a08beeb2 a4adb1a7_cf54_091f_eb63_8217e684a8e1["normalizePath"] bd61be4f_3dcc_2549_1583_12f4a8f96cd1 --> a4adb1a7_cf54_091f_eb63_8217e684a8e1 abfc9e70_3c15_b3f0_a595_3cf27afb7e64["utils.ts"] bd61be4f_3dcc_2549_1583_12f4a8f96cd1 --> abfc9e70_3c15_b3f0_a595_3cf27afb7e64 51e96894_3556_ed5c_1ede_97d449867adf["node:path"] bd61be4f_3dcc_2549_1583_12f4a8f96cd1 --> 51e96894_3556_ed5c_1ede_97d449867adf a340ba46_b2b7_3048_3bb3_6907a74c8464["vitest"] bd61be4f_3dcc_2549_1583_12f4a8f96cd1 --> a340ba46_b2b7_3048_3bb3_6907a74c8464 style bd61be4f_3dcc_2549_1583_12f4a8f96cd1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { resolve } from 'node:path'
import { describe, expect, it } from 'vitest'
import { transformDynamicImport } from '../../../plugins/dynamicImportVars'
import { normalizePath } from '../../../utils'
import { isWindows } from '../../../../shared/utils'
const dirname = import.meta.dirname
async function run(input: string) {
const { glob, rawPattern } =
(await transformDynamicImport(
input,
normalizePath(resolve(dirname, 'index.js')),
(id) =>
id
.replace('@', resolve(dirname, './mods/'))
.replace('#', resolve(dirname, '../../')),
dirname,
)) || {}
return `__variableDynamicImportRuntimeHelper(${glob}, \`${rawPattern}\`)`
}
describe('parse positives', () => {
it('basic', async () => {
expect(await run('`./mods/${base}.js`')).toMatchSnapshot()
})
it('alias path', async () => {
expect(await run('`@/${base}.js`')).toMatchSnapshot()
})
it('alias path with multi ../', async () => {
expect(await run('`#/${base}.js`')).toMatchSnapshot()
})
it('with query', async () => {
expect(await run('`./mods/${base}.js?foo=bar`')).toMatchSnapshot()
})
it('with query raw', async () => {
expect(await run('`./mods/${base}.js?raw`')).toMatchSnapshot()
})
it('with query url', async () => {
expect(await run('`./mods/${base}.js?url`')).toMatchSnapshot()
})
it('? in variables', async () => {
expect(await run('`./mods/${base ?? foo}.js?raw`')).toMatchSnapshot()
})
// ? is not escaped on windows (? cannot be used as a filename on windows)
it.skipIf(isWindows)('? in url', async () => {
expect(await run('`./mo?ds/${base ?? foo}.js?url`')).toMatchSnapshot()
})
// ? is not escaped on windows (? cannot be used as a filename on windows)
it.skipIf(isWindows)('? in worker', async () => {
expect(await run('`./mo?ds/${base ?? foo}.js?worker`')).toMatchSnapshot()
})
it('with ../ and itself', async () => {
expect(await run('`../dynamicImportVar/${name}.js`')).toMatchSnapshot()
})
it('with multi ../ and itself', async () => {
expect(
await run('`../../plugins/dynamicImportVar/${name}.js`'),
).toMatchSnapshot()
})
})
Domain
Subdomains
Functions
Dependencies
Source
Frequently Asked Questions
What does parse.spec.ts do?
parse.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 parse.spec.ts?
parse.spec.ts defines 1 function(s): run.
What does parse.spec.ts depend on?
parse.spec.ts imports 7 module(s): dynamicImportVars.ts, node:path, normalizePath, transformDynamicImport, utils.ts, utils.ts, vitest.
Where is parse.spec.ts in the architecture?
parse.spec.ts is located at packages/vite/src/node/__tests__/plugins/dynamicImportVar/parse.spec.ts (domain: ViteCore, subdomain: ConfigEngine, directory: packages/vite/src/node/__tests__/plugins/dynamicImportVar).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free