API โบ @qwik.dev/qwik/optimizer
basename
basename(path: string, ext?: string): string;
Parameter
Type
Description
path
string
ext
string
(Optional)
string
ComponentEntryStrategy
export interface ComponentEntryStrategy
Property
Modifiers
Type
Description
Record<string, string>
(Optional)
'component'
createOptimizer
createOptimizer: (optimizerOptions?: OptimizerOptions) => Promise<Optimizer>;
Parameter
Type
Description
optimizerOptions
(Optional)
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
string
EntryStrategy
export type EntryStrategy =
| InlineEntryStrategy
| HoistEntryStrategy
| SingleEntryStrategy
| HookEntryStrategy
| SegmentEntryStrategy
| ComponentEntryStrategy
| SmartEntryStrategy;
References: InlineEntryStrategy, SingleEntryStrategy, SegmentEntryStrategy, ComponentEntryStrategy, SmartEntryStrategy
ExperimentalFeatures
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
"insights"
Enable the ability to use the Qwik Insights vite plugin and component
noSPA
"noSPA"
Disable SPA navigation handler in Qwik Router
preventNavigate
"preventNavigate"
Enable the usePreventNavigate hook
valibot
"valibot"
Enable the Valibot form validation
webWorker
"webWorker"
Enable worker$
extname
extname(path: string): string;
Parameter
Type
Description
path
string
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; }
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'
InsightManifest
export interface InsightManifest
Property
Modifiers
Type
Description
Record<string, string>
{ route: string; symbols: string[]; }[]
'smart'
insights
isAbsolute
isAbsolute(path: string): boolean;
Parameter
Type
Description
path
string
boolean
join
join(...paths: string[]): string;
Parameter
Type
Description
paths
string[]
string
MinifyMode
export type MinifyMode = "simplify" | "none";
normalize
normalize(path: string): string;
Parameter
Type
Description
path
string
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
{ root: string; dir: string; base: string; ext: string; name: string; }
Path
export interface Path
Property
Modifiers
Type
Description
readonly
string
readonly
readonly
string
readonly
null
Method
Description
preventNavigate
QwikBuildMode
export type QwikBuildMode = "production" | "development";
QwikBuildTarget
export type QwikBuildTarget = "client" | "ssr" | "lib" | "test";
QwikBundle
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)
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]: 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
qwikRollup
export declare function qwikRollup(
qwikRollupOpts?: QwikRollupPluginOptions,
): any;
Parameter
Type
Description
qwikRollupOpts
(Optional)
any
QwikRollupPluginOptions
export interface QwikRollupPluginOptions
Property
Modifiers
Type
Description
(Optional) Build production
or development
.
Default development
boolean
(Optional)
boolean
(Optional) Prints verbose Qwik plugin debug logs.
Default false
(Optional) The Qwik entry strategy to use while building for production. During development the type is always segment
.
Default { type: "smart" }
)
(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 true
(Optional) The SSR build requires the manifest generated during the client build. The manifestInput
option can be used to manually provide a manifest.
Default undefined
(manifest: QwikManifest) => Promise<void> | void
(Optional) The client build will create a manifest and this hook is called with the generated build data.
Default undefined
(Optional)
string
(Optional) The root of the application, which is commonly the same directory as package.json
and rollup.config.js
.
Default process.cwd()
string
(Optional) The source directory to find all the Qwik components. Since Qwik does not have a single input, the srcDir
is used to recursively find Qwik files.
Default src
TransformModuleInput[] | null
(Optional) Alternative to srcDir
, where srcInputs
is able to provide the files manually. This option is useful for an environment without a file system, such as a webworker.
Default: null
(Optional) Target client
or ssr
.
Default client
((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' | 'event'
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)
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
(clientOutDir?: string | null) => Promise<InsightManifest | null>
() => QwikManifest | null
() => Optimizer | null
() => NormalizedQwikPluginOptions
() => string | null
QwikVitePluginOptions
export type QwikVitePluginOptions =
| QwikVitePluginCSROptions
| QwikVitePluginSSROptions;
relative
relative(from: string, to: string): string;
Parameter
Type
Description
from
string
to
string
string
resolve
resolve(...paths: string[]): string;
Parameter
Type
Description
paths
string[]
string
ResolvedManifest
export interface ResolvedManifest
Property
Modifiers
Type
Description
SegmentAnalysis
export interface SegmentAnalysis
Property
Modifiers
Type
Description
string
boolean
'event' | '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'
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 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>;
SymbolMapper
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>;
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
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
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
transformModules
Transforms the input code string, does not access the file system.
transformModules(opts: TransformModulesOptions): Promise<TransformOutput>;
Parameter
Type
Description
opts
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
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;
}