title |
---|
\@qwik.dev/qwik/optimizer API Reference |
API › @qwik.dev/qwik/optimizer
basename(path: string, ext?: string): string;
Parameter |
Type |
Description |
---|---|---|
path |
string | |
ext |
string |
(Optional) |
string
export interface ComponentEntryStrategy
Property |
Modifiers |
Type |
Description |
---|---|---|---|
Record<string, string> |
(Optional) | ||
'component' |
createOptimizer: (optimizerOptions?: OptimizerOptions) => Promise<Optimizer>;
Parameter |
Type |
Description |
---|---|---|
optimizerOptions |
(Optional) |
Promise<Optimizer>
export interface Diagnostic
Property |
Modifiers |
Type |
Description |
---|---|---|---|
string | null | |||
string | |||
SourceLocation[] | null | |||
string | |||
string | |||
string[] | null |
export type DiagnosticCategory = "error" | "warning" | "sourceError";
dirname(path: string): string;
Parameter |
Type |
Description |
---|---|---|
path |
string |
string
export type EntryStrategy =
| InlineEntryStrategy
| HoistEntryStrategy
| SingleEntryStrategy
| HookEntryStrategy
| SegmentEntryStrategy
| ComponentEntryStrategy
| SmartEntryStrategy;
References: InlineEntryStrategy, SingleEntryStrategy, SegmentEntryStrategy, ComponentEntryStrategy, SmartEntryStrategy
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 |
---|---|---|
insights |
|
Enable the ability to use the Qwik Insights vite plugin and component |
noSPA |
|
Disable SPA navigation handler in Qwik Router |
preventNavigate |
|
Enable the usePreventNavigate hook |
valibot |
|
Enable the Valibot form validation |
webWorker |
|
Enable worker$ |
extname(path: string): string;
Parameter |
Type |
Description |
---|---|---|
path |
string |
string
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; } |
string
export interface GlobalInjections
Property |
Modifiers |
Type |
Description |
---|---|---|---|
{ [key: string]: string; } |
(Optional) | ||
'head' | 'body' | |||
string |
export interface InlineEntryStrategy
Property |
Modifiers |
Type |
Description |
---|---|---|---|
'inline' |
export interface InsightManifest
Property |
Modifiers |
Type |
Description |
---|---|---|---|
Record<string, string> | |||
{ route: string; symbols: string[]; }[] | |||
'smart' |
isAbsolute(path: string): boolean;
Parameter |
Type |
Description |
---|---|---|
path |
string |
boolean
join(...paths: string[]): string;
Parameter |
Type |
Description |
---|---|---|
paths |
string[] |
string
export type MinifyMode = "simplify" | "none";
normalize(path: string): string;
Parameter |
Type |
Description |
---|---|---|
path |
string |
string
export interface Optimizer
Property |
Modifiers |
Type |
Description |
---|---|---|---|
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. |
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) |
export interface OptimizerSystem
Property |
Modifiers |
Type |
Description |
---|---|---|---|
() => string | |||
(path: string) => Promise<any> | |||
(rootDir: string) => Promise<TransformModuleInput[]> |
(Optional) | ||
string | |||
(path: string) => Promise<any> |
parse(path: string): {
root: string;
dir: string;
base: string;
ext: string;
name: string;
};
Parameter |
Type |
Description |
---|---|---|
path |
string |
{ root: string; dir: string; base: string; ext: string; name: string; }
export interface Path
Property |
Modifiers |
Type |
Description |
---|---|---|---|
|
string | ||
| |||
|
string | ||
|
null |
Method |
Description |
---|---|
export type QwikBuildMode = "production" | "development";
export type QwikBuildTarget = "client" | "ssr" | "lib" | "test";
export interface QwikBundle
Property |
Modifiers |
Type |
Description |
---|---|---|---|
string[] |
(Optional) | ||
string[] |
(Optional) | ||
boolean |
(Optional) Not precise, but an indication of whether this import may be a task | ||
string[] |
(Optional) | ||
number | |||
string[] |
(Optional) |
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]: QwikBundle; } |
All code bundles, used to know the import graph | ||
(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 | ||
{ target?: string; buildMode?: string; entryStrategy?: { [key: string]: any; }; } |
(Optional) | ||
{ [name: string]: string; } |
(Optional) | ||
{ [symbolName: string]: QwikSymbol; } |
QRL symbols | ||
string |
export declare function qwikRollup(
qwikRollupOpts?: QwikRollupPluginOptions,
): any;
Parameter |
Type |
Description |
---|---|---|
qwikRollupOpts |
(Optional) |
any
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. |
export interface QwikSymbol
Property |
Modifiers |
Type |
Description |
---|---|---|---|
string | |||
boolean | |||
'function' | 'event' | |||
string | |||
string | |||
string | |||
[number, number] | |||
string | |||
string | null |
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) |
any
export interface QwikViteDevResponse
Property |
Modifiers |
Type |
Description |
---|---|---|---|
Record<string, any> |
(Optional) | ||
() => void |
(Optional) |
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
export interface QwikVitePluginApi
Property |
Modifiers |
Type |
Description |
---|---|---|---|
() => string | undefined | |||
() => string | null | |||
() => string | null | |||
(clientOutDir?: string | null) => Promise<InsightManifest | null> | |||
() => QwikManifest | null | |||
() => Optimizer | null | |||
() => NormalizedQwikPluginOptions | |||
() => string | null |
export type QwikVitePluginOptions =
| QwikVitePluginCSROptions
| QwikVitePluginSSROptions;
relative(from: string, to: string): string;
Parameter |
Type |
Description |
---|---|---|
from |
string | |
to |
string |
string
resolve(...paths: string[]): string;
Parameter |
Type |
Description |
---|---|---|
paths |
string[] |
string
export interface ResolvedManifest
Property |
Modifiers |
Type |
Description |
---|---|---|---|
export interface SegmentAnalysis
Property |
Modifiers |
Type |
Description |
---|---|---|---|
string | |||
boolean | |||
'event' | 'function' | |||
string | |||
string | |||
string | null | |||
string | |||
string | |||
[number, number] | |||
string | |||
string | |||
string | null |
export interface SegmentEntryStrategy
Property |
Modifiers |
Type |
Description |
---|---|---|---|
Record<string, string> |
(Optional) | ||
'segment' |
export interface SingleEntryStrategy
Property |
Modifiers |
Type |
Description |
---|---|---|---|
Record<string, string> |
(Optional) | ||
'single' |
export interface SmartEntryStrategy
Property |
Modifiers |
Type |
Description |
---|---|---|---|
Record<string, string> |
(Optional) | ||
'smart' |
export interface SourceLocation
Property |
Modifiers |
Type |
Description |
---|---|---|---|
number | |||
number | |||
number | |||
number | |||
number | |||
number |
export type SourceMapsOption = "external" | "inline" | undefined | null;
This API is provided as a beta 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>;
This API is provided as a beta 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>;
export type SymbolMapperFn = (
symbolName: string,
mapper: SymbolMapper | undefined,
parent?: string,
) => readonly [symbol: string, chunk: string] | undefined;
References: SymbolMapper
export type SystemEnvironment =
| "node"
| "deno"
| "bun"
| "webworker"
| "browsermain"
| "unknown";
export interface TransformModule
Property |
Modifiers |
Type |
Description |
---|---|---|---|
string | |||
boolean | |||
string | null | |||
string | null | |||
string | |||
SegmentAnalysis | null |
export interface TransformModuleInput
Property |
Modifiers |
Type |
Description |
---|---|---|---|
string | |||
string |
(Optional) | ||
string |
Transforms the input code string, does not access the file system.
transformModules(opts: TransformModulesOptions): Promise<TransformOutput>;
Parameter |
Type |
Description |
---|---|---|
opts |
Promise<TransformOutput>
export interface TransformModulesOptions extends TransformOptions
Extends: TransformOptions
Property |
Modifiers |
Type |
Description |
---|---|---|---|
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) |
export interface TransformOutput
Property |
Modifiers |
Type |
Description |
---|---|---|---|
boolean | |||
boolean | |||
export type TranspileOption = boolean | undefined | null;
versions: {
qwik: string;
}