API โบ @builder.io/qwik/optimizer
basename
basename(path: string, ext?: string): string;
Parameter  | Type  | Description  | 
|---|---|---|
path  | string  | |
ext  | string  | (Optional)  | 
Returns:
string
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
ComponentEntryStrategy
export interface ComponentEntryStrategy
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
Record<string, string>  | (Optional)  | ||
'component'  | 
createOptimizer
createOptimizer: (optimizerOptions?: OptimizerOptions) => Promise<Optimizer>;
Parameter  | Type  | Description  | 
|---|---|---|
optimizerOptions  | (Optional)  | 
Returns:
Promise<Optimizer>
Diagnostic
export interface Diagnostic
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
string | null  | |||
string  | |||
string  | |||
string  | |||
string[] | null  | 
DiagnosticCategory
export type DiagnosticCategory = "error" | "warning" | "sourceError";
dirname
dirname(path: string): string;
Parameter  | Type  | Description  | 
|---|---|---|
path  | string  | 
Returns:
string
enableRequestRewrite
EntryStrategy
export type EntryStrategy =
  | InlineEntryStrategy
  | HoistEntryStrategy
  | SingleEntryStrategy
  | HookEntryStrategy
  | SegmentEntryStrategy
  | ComponentEntryStrategy
  | SmartEntryStrategy;
References: InlineEntryStrategy, SingleEntryStrategy, SegmentEntryStrategy, ComponentEntryStrategy, SmartEntryStrategy
ExperimentalFeatures
This API is provided as an alpha preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Use __EXPERIMENTAL__.x 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  | 
|---|---|---|
enableRequestRewrite  | 
  | (ALPHA) Enable request.rewrite()  | 
noSPA  | 
  | (ALPHA) Disable SPA navigation handler in Qwik City  | 
preventNavigate  | 
  | (ALPHA) Enable the usePreventNavigate hook  | 
valibot  | 
  | (ALPHA) Enable the Valibot form validation  | 
extname
extname(path: string): string;
Parameter  | Type  | Description  | 
|---|---|---|
path  | string  | 
Returns:
string
format
format(pathObject: {
        root: string;
        dir: string;
        base: string;
        ext: string;
        name: string;
    }): string;
Parameter  | Type  | Description  | 
|---|---|---|
pathObject  | { root: string; dir: string; base: string; ext: string; name: string; }  | 
Returns:
string
GlobalInjections
export interface GlobalInjections
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
{ [key: string]: string; }  | (Optional)  | ||
'head' | 'body'  | |||
string  | 
InlineEntryStrategy
export interface InlineEntryStrategy
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
'inline'  | 
isAbsolute
isAbsolute(path: string): boolean;
Parameter  | Type  | Description  | 
|---|---|---|
path  | string  | 
Returns:
boolean
join
join(...paths: string[]): string;
Parameter  | Type  | Description  | 
|---|---|---|
paths  | string[]  | 
Returns:
string
MinifyMode
export type MinifyMode = "simplify" | "none";
normalize
normalize(path: string): string;
Parameter  | Type  | Description  | 
|---|---|---|
path  | string  | 
Returns:
string
noSPA
Optimizer
export interface Optimizer
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
Optimizer system use. This can be updated with a custom file system.  | 
Method  | Description  | 
|---|---|
Transforms the directory from the file system.  | |
Transforms the directory from the file system.  | |
Transforms the input code string, does not access the file system.  | |
Transforms the input code string, does not access the file system.  | 
OptimizerOptions
export interface OptimizerOptions
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
any  | (Optional)  | ||
number  | (Optional) Inline the global styles if they're smaller than this  | ||
boolean  | (Optional) Enable sourcemaps  | ||
(Optional)  | 
OptimizerSystem
export interface OptimizerSystem
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
() => string  | |||
(path: string) => Promise<any>  | |||
(rootDir: string) => Promise<TransformModuleInput[]>  | (Optional)  | ||
string  | |||
(path: string) => Promise<any>  | 
parse
parse(path: string): {
        root: string;
        dir: string;
        base: string;
        ext: string;
        name: string;
    };
Parameter  | Type  | Description  | 
|---|---|---|
path  | string  | 
Returns:
{ root: string; dir: string; base: string; ext: string; name: string; }
Path
export interface Path
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
  | string  | ||
  | |||
  | string  | ||
  | null  | 
Method  | Description  | 
|---|---|
preventNavigate
QwikAsset
export interface QwikAsset
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
string | undefined  | Name of the asset  | ||
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  | 
|---|---|---|---|
string[]  | (Optional) Dynamic imports  | ||
string[]  | (Optional) Direct imports  | ||
number  | (Optional) Interactivity score of the bundle  | ||
string[]  | (Optional) Source files of the bundle  | ||
number  | Size of the bundle  | ||
string[]  | (Optional) Symbols in the bundle  | ||
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  | 
|---|---|---|---|
{ [fileName: string]: QwikAsset; }  | (Optional) All assets. The key is the fileName relative to the rootDir  | ||
(Optional) All bundles in a compact graph format with probabilities  | |||
string  | (Optional) The bundle graph fileName  | ||
{ [fileName: string]: QwikBundle; }  | All code bundles, used to know the import graph. The key is the bundle fileName relative to "build/"  | ||
string  | (Optional) The Qwik core bundle fileName  | ||
(Optional) CSS etc to inject in the document head  | |||
string  | Content hash of the manifest, if this changes, the code changed  | ||
{ [symbolName: string]: string; }  | Where QRLs are located. The key is the symbol name, the value is the bundle fileName  | ||
{ target?: string; buildMode?: string; entryStrategy?: { type: EntryStrategy['type']; }; }  | (Optional) The options used to build the manifest  | ||
{ [name: string]: string; }  | (Optional) The platform used to build the manifest  | ||
string  | (Optional) The preloader bundle fileName  | ||
string  | (Optional) The Qwik loader bundle fileName  | ||
{ [symbolName: string]: QwikSymbol; }  | QRL symbols  | ||
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  | 
|---|---|---|---|
(Optional) Build  Default   | |||
boolean  | (Optional)  | ||
boolean  | (Optional) Prints verbose Qwik plugin debug logs. Default   | ||
(Optional) The Qwik entry strategy to use while building for production. During development the type is always  Default   | |||
(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.  | ||
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   | ||
(Optional) The SSR build requires the manifest generated during the client build. The  Default   | |||
(manifest: QwikManifest) => Promise<void> | void  | (Optional) The client build will create a manifest and this hook is called with the generated build data. Default   | ||
(Optional)  | |||
string  | (Optional) The root of the application, which is commonly the same directory as  Default   | ||
string  | (Optional) The source directory to find all the Qwik components. Since Qwik does not have a single input, the  Default   | ||
TransformModuleInput[] | null  | (Optional) Alternative to  Default:   | ||
(Optional) Target  Default   | |||
((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  | 
|---|---|---|---|
string  | |||
boolean  | |||
'function' | 'eventHandler'  | |||
string  | |||
string  | |||
string  | |||
[number, number]  | |||
string  | |||
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
QwikViteDevResponse
export interface QwikViteDevResponse
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
Record<string, any>  | (Optional)  | ||
() => void  | (Optional)  | 
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  | 
|---|---|---|---|
() => string | undefined  | |||
() => string | null  | |||
() => string | null  | |||
() => QwikManifest | null  | |||
() => Optimizer | null  | |||
() => NormalizedQwikPluginOptions  | |||
() => string | null  | |||
(adder: BundleGraphAdder) => void  | 
QwikVitePluginOptions
export type QwikVitePluginOptions =
  | QwikVitePluginCSROptions
  | QwikVitePluginSSROptions;
relative
relative(from: string, to: string): string;
Parameter  | Type  | Description  | 
|---|---|---|
from  | string  | |
to  | string  | 
Returns:
string
resolve
resolve(...paths: string[]): string;
Parameter  | Type  | Description  | 
|---|---|---|
paths  | string[]  | 
Returns:
string
ResolvedManifest
export interface ResolvedManifest
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
SegmentAnalysis
export interface SegmentAnalysis
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
string  | |||
boolean  | |||
'eventHandler' | 'function'  | |||
string  | |||
string  | |||
string | null  | |||
string  | |||
string  | |||
[number, number]  | |||
string  | |||
string  | |||
string | null  | 
SegmentEntryStrategy
export interface SegmentEntryStrategy
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
Record<string, string>  | (Optional)  | ||
'segment'  | 
ServerQwikManifest
The manifest values that are needed for SSR.
export type ServerQwikManifest = Pick<
  QwikManifest,
  | "manifestHash"
  | "injections"
  | "bundleGraph"
  | "bundleGraphAsset"
  | "mapping"
  | "preloader"
  | "core"
  | "qwikLoader"
>;
References: QwikManifest
SingleEntryStrategy
export interface SingleEntryStrategy
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
Record<string, string>  | (Optional)  | ||
'single'  | 
SmartEntryStrategy
export interface SmartEntryStrategy
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
Record<string, string>  | (Optional)  | ||
'smart'  | 
SourceLocation
export interface SourceLocation
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
number  | |||
number  | |||
number  | |||
number  | |||
number  | |||
number  | 
SourceMapsOption
export type SourceMapsOption = "external" | "inline" | undefined | null;
symbolMapper
This API is provided as an alpha preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
For a given symbol (QRL such as onKeydown$) the server needs to know which bundle the symbol is in.
Normally this is provided by Qwik's q-manifest . But q-manifest only exists after a full client build.
This would be a problem in dev mode. So in dev mode the symbol is mapped to the expected URL using the symbolMapper function below. For Vite the given path is fixed for a given symbol.
symbolMapper: ReturnType<typeof createSymbolMapper>;
SymbolMapper
This API is provided as an alpha preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
For a given symbol (QRL such as onKeydown$) the server needs to know which bundle the symbol is in.
Normally this is provided by Qwik's q-manifest . But q-manifest only exists after a full client build.
This would be a problem in dev mode. So in dev mode the symbol is mapped to the expected URL using the symbolMapper function below. For Vite the given path is fixed for a given symbol.
symbolMapper: ReturnType<typeof createSymbolMapper>;
SymbolMapperFn
export type SymbolMapperFn = (
  symbolName: string,
  mapper: SymbolMapper | undefined,
  parent?: string,
) => readonly [symbol: string, chunk: string] | undefined;
References: SymbolMapper
SystemEnvironment
export type SystemEnvironment =
  | "node"
  | "deno"
  | "bun"
  | "webworker"
  | "browsermain"
  | "unknown";
transformFs
Transforms the directory from the file system.
transformFs(opts: TransformFsOptions): Promise<TransformOutput>;
Parameter  | Type  | Description  | 
|---|---|---|
opts  | 
Returns:
Promise<TransformOutput>
TransformFsOptions
export interface TransformFsOptions extends TransformOptions
Extends: TransformOptions
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
string[]  | 
transformFsSync
Transforms the directory from the file system.
transformFsSync(opts: TransformFsOptions): TransformOutput;
Parameter  | Type  | Description  | 
|---|---|---|
opts  | 
Returns:
TransformModule
export interface TransformModule
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
string  | |||
boolean  | |||
string | null  | |||
string | null  | |||
string  | |||
SegmentAnalysis | null  | 
TransformModuleInput
export interface TransformModuleInput
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
string  | |||
string  | (Optional)  | ||
string  | 
transformModules
Transforms the input code string, does not access the file system.
transformModules(opts: TransformModulesOptions): Promise<TransformOutput>;
Parameter  | Type  | Description  | 
|---|---|---|
opts  | 
Returns:
Promise<TransformOutput>
TransformModulesOptions
export interface TransformModulesOptions extends TransformOptions
Extends: TransformOptions
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
transformModulesSync
Transforms the input code string, does not access the file system.
transformModulesSync(opts: TransformModulesOptions): TransformOutput;
Parameter  | Type  | Description  | 
|---|---|---|
opts  | 
Returns:
TransformOptions
export interface TransformOptions
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
(Optional)  | |||
boolean  | (Optional)  | ||
boolean  | (Optional)  | ||
(Optional)  | |||
EmitMode  | (Optional)  | ||
boolean  | (Optional)  | ||
string[]  | (Optional)  | ||
string  | (Optional)  | ||
string  | (Optional)  | ||
boolean  | (Optional)  | ||
string  | |||
string[]  | (Optional)  | ||
boolean  | (Optional)  | ||
string[]  | (Optional)  | ||
boolean  | (Optional)  | ||
boolean  | (Optional)  | 
TransformOutput
export interface TransformOutput
Property  | Modifiers  | Type  | Description  | 
|---|---|---|---|
boolean  | |||
boolean  | |||
TranspileOption
export type TranspileOption = boolean | undefined | null;
valibot
versions
versions: {
  qwik: string;
}