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

Function createDefaultImportMeta

packages/vite/src/module-runner/createImportMeta.ts:14–36  ·  view source on GitHub ↗
(
  modulePath: string,
)

Source from the content-addressed store, hash-verified

12})
13
14export function createDefaultImportMeta(
15 modulePath: string,
16): ModuleRunnerImportMeta {
17 const href = posixPathToFileHref(modulePath)
18 const filename = modulePath
19 const dirname = posixDirname(modulePath)
20 return {
21 filename: isWindows ? toWindowsPath(filename) : filename,
22 dirname: isWindows ? toWindowsPath(dirname) : dirname,
23 url: href,
24 env: envProxy,
25 resolve(_id: string, _parent?: string) {
26 throw new Error('[module runner] "import.meta.resolve" is not supported.')
27 },
28 // should be replaced during transformation
29 glob() {
30 throw new Error(
31 `[module runner] "import.meta.glob" is statically replaced during ` +
32 `file transformation. Make sure to reference it by the full name.`,
33 )
34 },
35 }
36}
37
38/**
39 * Create import.meta object for Node.js.

Callers 1

createNodeImportMetaFunction · 0.85

Calls 2

posixPathToFileHrefFunction · 0.90
toWindowsPathFunction · 0.90

Tested by

no test coverage detected