API › @qwik.dev/qwik/optimizer
basename
basename(path: string, ext?: string): string;
Parameter | Type | Description |
|---|---|---|
path | string | |
ext | string | (Optional) |
Returns:
string
blockSSR
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 |
|---|---|---|---|
manual? | Record<string, string> | (Optional) | |
type | 'component' |
createOptimizer
createOptimizer: (optimizerOptions?: OptimizerOptions) => Promise<Optimizer>;
Parameter | Type | Description |
|---|---|---|
optimizerOptions | (Optional) |
Returns:
Promise<Optimizer>
Diagnostic
export interface Diagnostic
Property | Modifiers | Type | Description |
|---|---|---|---|
category | |||
code | string | null | ||
file | string | ||
highlights | SourceLocation[] | null | ||
message | string | ||
scope | string | ||
suggestions | string[] | null |
DiagnosticCategory
export type DiagnosticCategory = "error" | "warning" | "sourceError";
dirname
dirname(path: string): string;
Parameter | Type | Description |
|---|---|---|
path | string |
Returns:
string
each
EmitMode
export type EmitMode = "dev" | "prod" | "lib" | "hmr";
EntryStrategy
export type EntryStrategy =
| InlineEntryStrategy
| HoistEntryStrategy
| SingleEntryStrategy
| HookEntryStrategy
| SegmentEntryStrategy
| ComponentEntryStrategy
| SmartEntryStrategy;
References: InlineEntryStrategy, HoistEntryStrategy, SingleEntryStrategy, HookEntryStrategy, SegmentEntryStrategy, ComponentEntryStrategy, SmartEntryStrategy
errorBoundary
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 |
|---|---|---|
blockSSR |
| Enable the |
each |
| Enable the Each keyed-list primitive |
errorBoundary |
| Enable the ErrorBoundary primitive |
insights |
| Enable the ability to use the Qwik Insights vite plugin and |
noSPA |
| Disable SPA navigation handler in Qwik Router |
show |
| Enable the Show conditional primitive |
suspense |
| Enable the Suspense fallback primitive |
valibot |
| 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 |
|---|---|---|---|
attributes? | { [key: string]: string; } | (Optional) | |
location | 'head' | 'body' | ||
tag | string |
HoistEntryStrategy
export interface HoistEntryStrategy
Property | Modifiers | Type | Description |
|---|---|---|---|
type | 'hoist' |
HookEntryStrategy
Warning: This API is now obsolete.
Use SegmentStrategy instead
export interface HookEntryStrategy
Property | Modifiers | Type | Description |
|---|---|---|---|
manual? | Record<string, string> | (Optional) | |
type | 'hook' |
InlineEntryStrategy
export interface InlineEntryStrategy
Property | Modifiers | Type | Description |
|---|---|---|---|
type | 'inline' |
insights
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 |
|---|---|---|---|
sys | Optimizer system use. This can be updated with a custom file system. |
Method | Description |
|---|---|
Transforms the input code string, does not access the file system. |
OptimizerOptions
export interface OptimizerOptions
Property | Modifiers | Type | Description |
|---|---|---|---|
_optimizer? | unknown | (Optional) | |
binding? | any | (Optional) | |
inlineStylesUpToBytes? | number | (Optional) Inline the global styles if they're smaller than this | |
sourcemap? | boolean | (Optional) Enable sourcemaps | |
sys? | (Optional) | ||
tsOptimizer? | boolean | (Optional) Use the TypeScript optimizer ( Default |
OptimizerSystem
export interface OptimizerSystem
Property | Modifiers | Type | Description |
|---|---|---|---|
cwd | () => string | ||
dynamicImport | (path: string) => Promise<any> | ||
env | |||
getInputFiles? | (rootDir: string) => Promise<TransformModuleInput[]> | (Optional) | |
os | string | ||
path | |||
strictDynamicImport | (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 |
|---|---|---|---|
delimiter |
| string | |
posix |
| ||
sep |
| string | |
win32 |
| null |
Method | Description |
|---|---|
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 |
qwikRolldown
export declare function qwikRolldown(
qwikRolldownOpts?: QwikRolldownPluginOptions,
): any;
Parameter | Type | Description |
|---|---|---|
qwikRolldownOpts | (Optional) |
Returns:
any
QwikRolldownPluginOptions
export interface QwikRolldownPluginOptions
Property | Modifiers | Type | Description |
|---|---|---|---|
buildMode? | (Optional) Build Default | ||
csr? | boolean | (Optional) | |
debug? | boolean | (Optional) Prints verbose Qwik plugin debug logs. Default | |
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? | (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. |
qwikRollup
Warning: This API is now obsolete.
Use
qwikRolldown.
Renamed to qwikRolldown.
qwikRollup: typeof qwikRolldown;
QwikRollupPluginOptions
Warning: This API is now obsolete.
Use
QwikRolldownPluginOptions.
Renamed to QwikRolldownPluginOptions.
export type QwikRollupPluginOptions = QwikRolldownPluginOptions;
References: QwikRolldownPluginOptions
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/Rolldown 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 |
|---|---|---|---|
getClientOutDir | () => string | null | ||
getClientPublicOutDir | () => string | null | ||
getManifest | () => QwikManifest | null | ||
getOptimizer | () => Optimizer | null | ||
getOptions | () => NormalizedQwikPluginOptions | ||
getRootDir | () => string | null | ||
onSegment | (callback: SegmentCallback) => void | Register a callback that fires for each segment emitted during transform. | |
registerBundleGraphAdder | (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 |
|---|---|---|---|
bundleGraph? | (Optional) | ||
injections? | (Optional) | ||
manifest | |||
mapper |
SegmentAnalysis
export interface SegmentAnalysis
Property | Modifiers | Type | Description |
|---|---|---|---|
canonicalFilename | string | ||
captureNames? | string[] | (Optional) The transformed names of scoped variables, if any | |
captures | boolean | ||
ctxKind | 'eventHandler' | 'function' | ||
ctxName | string | ||
displayName | string | ||
entry | string | null | ||
extension | string | ||
hash | string | ||
loc | [number, number] | ||
name | string | ||
origin | string | ||
paramNames? | string[] | (Optional) The parameter names if it's a function with parameters | |
parent | string | null |
SegmentEntryStrategy
export interface SegmentEntryStrategy
Property | Modifiers | Type | Description |
|---|---|---|---|
manual? | Record<string, string> | (Optional) | |
type | '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
show
SingleEntryStrategy
export interface SingleEntryStrategy
Property | Modifiers | Type | Description |
|---|---|---|---|
manual? | Record<string, string> | (Optional) | |
type | 'single' |
SmartEntryStrategy
export interface SmartEntryStrategy
Property | Modifiers | Type | Description |
|---|---|---|---|
manual? | Record<string, string> | (Optional) | |
type | 'smart' |
SourceLocation
export interface SourceLocation
Property | Modifiers | Type | Description |
|---|---|---|---|
endCol | number | ||
endLine | number | ||
hi | number | ||
lo | number | ||
startCol | number | ||
startLine | number |
suspense
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
SystemEnvironment
export type SystemEnvironment =
| "node"
| "deno"
| "bun"
| "webworker"
| "browsermain"
| "unknown";
TransformModule
export interface TransformModule
Property | Modifiers | Type | Description |
|---|---|---|---|
code | string | ||
imports? | string[] | (Optional) | |
isEntry | boolean | ||
map | string | null | ||
origPath | string | null | ||
path | string | ||
segment | SegmentAnalysis | null |
TransformModuleInput
export interface TransformModuleInput
Property | Modifiers | Type | Description |
|---|---|---|---|
code | string | ||
devPath? | string | (Optional) | |
path | 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 |
|---|---|---|---|
input |
TransformOptions
export interface TransformOptions
Property | Modifiers | Type | Description |
|---|---|---|---|
entryStrategy? | (Optional) | ||
explicitExtensions? | boolean | (Optional) | |
isServer? | boolean | (Optional) | |
minify? | (Optional) | ||
mode? | (Optional) | ||
preserveFilenames? | boolean | (Optional) | |
regCtxName? | string[] | (Optional) | |
rootDir? | string | (Optional) | |
scope? | string | (Optional) | |
sourceMaps? | boolean | (Optional) | |
srcDir | string | ||
stripCtxName? | string[] | (Optional) | |
stripEventHandlers? | boolean | (Optional) | |
stripExports? | string[] | (Optional) | |
transpileJsx? | boolean | (Optional) | |
transpileTs? | boolean | (Optional) |
TransformOutput
export interface TransformOutput
Property | Modifiers | Type | Description |
|---|---|---|---|
diagnostics | |||
isJsx | boolean | ||
isTypeScript | boolean | ||
modules |