loader
Esta página aún no está disponible en tu idioma.
Functions
Section titled “Functions”bundleConfigFile()
Section titled “bundleConfigFile()”function bundleConfigFile(__namedParameters: { fileUrl: URL; }): Promise<{ code: any; dependencies: string[];}>
Defined in: loader.ts:18^
Bundle arbitrary mjs
or ts
file.
Simplified fork from Vite’s bundleConfigFile
function.
Parameters
Section titled “Parameters”__namedParameters
Section titled “__namedParameters”fileUrl
Section titled “fileUrl”URL
Returns
Section titled “Returns”Promise
<{
code
: any
;
dependencies
: string
[];
}>
https://github.com/vitejs/vite/blob/main/packages/vite/src/node/config.ts#L961^
importBundledFile()
Section titled “importBundledFile()”function importBundledFile(__namedParameters: ImportBundledFileArgs): Promise<{ default: unknown;}>
Defined in: loader.ts:49^
Forked from Vite config loader, replacing CJS-based path concat with ESM only
Parameters
Section titled “Parameters”__namedParameters
Section titled “__namedParameters”Returns
Section titled “Returns”Promise
<{
default
: unknown
;
}>
https://github.com/vitejs/vite/blob/main/packages/vite/src/node/config.ts#L1074^
loadAndBundleConfigFile()
Section titled “loadAndBundleConfigFile()”function loadAndBundleConfigFile(params: LoadAndBundleConfigFileArgs): Promise<LoadAndBundleConfigFileResult>
Defined in: loader.ts:77^
Loads and bundles a configuration file, then imports the bundled module.
Parameters
Section titled “Parameters”params
Section titled “params”The arguments for loading and bundling the config file.
Returns
Section titled “Returns”Promise
<LoadAndBundleConfigFileResult
>
A promise that resolves to an object containing the imported module (mod
)
and an array of its dependencies.
loadConfigFile()
Section titled “loadConfigFile()”function loadConfigFile<R>( root: URL, configPaths: string[],label?: string): Promise<undefined | R>
Defined in: loader.ts:113^
Loads a configuration file from a list of possible paths relative to a given root URL.
Iterates through the provided configPaths
, checking for the existence of each file.
If a file is found, it is loaded and bundled, and its default export is returned as the configuration object.
If no valid configuration file is found, or if the file does not have a valid default export, the function returns undefined
or throws an error, respectively.
Type Parameters
Section titled “Type Parameters”R
The expected shape of the configuration object.
Parameters
Section titled “Parameters”URL
The base URL to resolve configuration file paths against.
configPaths
Section titled “configPaths”string
[]
An array of possible configuration file paths to check, relative to root
.
label?
Section titled “label?”string
Returns
Section titled “Returns”Promise
<undefined
| R
>
A promise that resolves to the configuration object of type R
, or undefined
if no valid config file is found.
Throws
Section titled “Throws”If a config file is found but does not have a valid default export.