API › @qwik.dev/qwik/optimizer
BundleGraphAdder
A function that returns a map of bundle names to their dependencies.
export type BundleGraphAdder = (manifest: QwikManifest) => Record<
string,
{
imports?: string[];
dynamicImports?: string[];
}
>;
References: QwikManifest
each
enableRequestRewrite
ExperimentalFeatures
Use false to check if feature x is enabled. It will be replaced with true or false via an exact string replacement.
Add experimental features to this enum definition.
export declare enum ExperimentalFeatures
Member | Value | Description |
|---|---|---|
each |
| Enable the Each keyed-list primitive |
enableRequestRewrite |
| Enable request.rewrite() |
insights |
| Enable the ability to use the Qwik Insights vite plugin and |
noSPA |
| Disable SPA navigation handler in Qwik Router |
preventNavigate |
| Enable the usePreventNavigate hook |
valibot |
| Enable the Valibot form validation |
webWorker |
| Enable worker$ |
GlobalInjections
export interface GlobalInjections
Property | Modifiers | Type | Description |
|---|---|---|---|
attributes? | { [key: string]: string; } | (Optional) | |
location | 'head' | 'body' | ||
tag | string |
insights
noSPA
preventNavigate
QwikAsset
export interface QwikAsset
Property | Modifiers | Type | Description |
|---|---|---|---|
name | string | undefined | Name of the asset | |
size | number | Size of the asset |
QwikBuildMode
export type QwikBuildMode = "production" | "development";
QwikBuildTarget
export type QwikBuildTarget = "client" | "ssr" | "lib" | "test";
QwikBundle
export interface QwikBundle
Property | Modifiers | Type | Description |
|---|---|---|---|
dynamicImports? | string[] | (Optional) Dynamic imports | |
imports? | string[] | (Optional) Direct imports | |
interactivity? | number | (Optional) Interactivity score of the bundle | |
origins? | string[] | (Optional) Source files of the bundle | |
size | number | Size of the bundle | |
symbols? | string[] | (Optional) Symbols in the bundle | |
total | number | Total size of this bundle's static import graph |
QwikBundleGraph
Bundle graph.
Format: [ 'bundle-a.js', 3, 5 // Depends on 'bundle-b.js' and 'bundle-c.js' 'bundle-b.js', 5, // Depends on 'bundle-c.js' 'bundle-c.js', ]
export type QwikBundleGraph = Array<string | number>;
QwikManifest
The metadata of the build. One of its uses is storing where QRL symbols are located.
export interface QwikManifest
Property | Modifiers | Type | Description |
|---|---|---|---|
assets? | { [fileName: string]: QwikAsset; } | (Optional) All assets. The key is the fileName relative to the rootDir | |
bundleGraph? | (Optional) All bundles in a compact graph format with probabilities | ||
bundleGraphAsset? | string | (Optional) The bundle graph fileName | |
bundles | { [fileName: string]: QwikBundle; } | All code bundles, used to know the import graph. The key is the bundle fileName relative to "build/" | |
core? | string | (Optional) The Qwik core bundle fileName | |
injections? | (Optional) CSS etc to inject in the document head | ||
manifestHash | string | Content hash of the manifest, if this changes, the code changed | |
mapping | { [symbolName: string]: string; } | Where QRLs are located. The key is the symbol name, the value is the bundle fileName | |
options? | { target?: string; buildMode?: string; entryStrategy?: { type: EntryStrategy['type']; }; } | (Optional) The options used to build the manifest | |
platform? | { [name: string]: string; } | (Optional) The platform used to build the manifest | |
preloader? | string | (Optional) The preloader bundle fileName | |
qwikLoader? | string | (Optional) The Qwik loader bundle fileName | |
symbols | { [symbolName: string]: QwikSymbol; } | QRL symbols | |
version | string | The version of the manifest |
qwikRollup
export declare function qwikRollup(
qwikRollupOpts?: QwikRollupPluginOptions,
): any;
Parameter | Type | Description |
|---|---|---|
qwikRollupOpts | (Optional) |
Returns:
any
QwikRollupPluginOptions
export interface QwikRollupPluginOptions
Property | Modifiers | Type | Description |
|---|---|---|---|
buildMode? | (Optional) Build Default | ||
csr? | boolean | (Optional) | |
debug? | boolean | (Optional) Prints verbose Qwik plugin debug logs. Default | |
entryStrategy? | EntryStrategy | (Optional) The Qwik entry strategy to use while building for production. During development the type is always Default | |
experimental? | (keyof typeof ExperimentalFeatures)[] | (Optional) Experimental features. These can come and go in patch releases, and their API is not guaranteed to be stable between releases. | |
lint? | boolean | (Optional) Run eslint on the source files for the ssr build or dev server. This can slow down startup on large projects. Defaults to | |
manifestInput? | (Optional) The SSR build requires the manifest generated during the client build. The Default | ||
manifestOutput? | (manifest: QwikManifest) => Promise<void> | void | (Optional) The client build will create a manifest and this hook is called with the generated build data. Default | |
optimizerOptions? | OptimizerOptions | (Optional) | |
rootDir? | string | (Optional) The root of the application, which is commonly the same directory as Default | |
srcDir? | string | (Optional) The source directory to find all the Qwik components. Since Qwik does not have a single input, the Default | |
srcInputs? | TransformModuleInput[] | null | (Optional) Alternative to Default: | |
target? | (Optional) Target Default | ||
transformedModuleOutput? | ((transformedModules: TransformModule[]) => Promise<void> | void) | null | (Optional) Hook that's called after the build and provides all of the transformed modules that were used before bundling. |
QwikSymbol
export interface QwikSymbol
Property | Modifiers | Type | Description |
|---|---|---|---|
canonicalFilename | string | ||
captureNames? | string[] | (Optional) The transformed names of scoped variables, if any | |
captures | boolean | Whether the symbol captures a variable | |
ctxKind | 'function' | 'eventHandler' | ||
ctxName | string | ||
displayName | string | ||
hash | string | ||
loc | [number, number] | ||
origin | string | ||
paramNames? | string[] | (Optional) The parameter names if it's a function with parameters | |
parent | string | null |
qwikVite
The types for Vite/Rollup don't allow us to be too specific about the return type. The correct return type is [QwikVitePlugin, VitePlugin<never>], and if you search the plugin by name you'll get the QwikVitePlugin.
export declare function qwikVite(qwikViteOpts?: QwikVitePluginOptions): any;
Parameter | Type | Description |
|---|---|---|
qwikViteOpts | (Optional) |
Returns:
any
QwikVitePlugin
This is the type of the "pre" Qwik Vite plugin. qwikVite actually returns a tuple of two plugins, but after Vite flattens them, you can find the plugin by name.
export type QwikVitePlugin = P<QwikVitePluginApi> & {
name: "vite-plugin-qwik";
};
References: QwikVitePluginApi
QwikVitePluginApi
export interface QwikVitePluginApi
Property | Modifiers | Type | Description |
|---|---|---|---|
getAssetsDir | () => string | undefined | ||
getClientOutDir | () => string | null | ||
getClientPublicOutDir | () => string | null | ||
getManifest | () => QwikManifest | null | ||
getOptimizer | () => Optimizer | null | ||
getOptions | () => NormalizedQwikPluginOptions | ||
getRootDir | () => string | null | ||
registerBundleGraphAdder | (adder: BundleGraphAdder) => void |
QwikVitePluginOptions
export type QwikVitePluginOptions =
| QwikVitePluginCSROptions
| QwikVitePluginSSROptions;
ResolvedManifest
export interface ResolvedManifest
Property | Modifiers | Type | Description |
|---|---|---|---|
bundleGraph? | (Optional) | ||
injections? | (Optional) | ||
manifest | |||
mapper |
ServerQwikManifest
The manifest values that are needed for SSR.
export type ServerQwikManifest = Pick<
QwikManifest,
| "manifestHash"
| "injections"
| "bundleGraph"
| "bundleGraphAsset"
| "mapping"
| "preloader"
| "core"
| "qwikLoader"
>;
References: QwikManifest
SymbolMapper
export type SymbolMapper = Record<
string,
readonly [symbol: string, chunk: string]
>;
SymbolMapperFn
export type SymbolMapperFn = (
symbolName: string,
mapper: SymbolMapper | undefined,
parent?: string,
) => readonly [symbol: string, chunk: string] | undefined;
References: SymbolMapper