API › @builder.io/qwik/optimizer
basename
basename(path: string, ext?: string): string;
參數
類型
說明
path
string
ext
string
(可選)
string
ComponentEntryStrategy
export interface ComponentEntryStrategy
屬性
修飾符
類型
說明
Record<string, string>
(可選)
'component'
createOptimizer
createOptimizer: (optimizerOptions?: OptimizerOptions) => Promise<Optimizer>;
參數
類型
說明
optimizerOptions
(可選)
Promise<Optimizer>
Diagnostic
export interface Diagnostic
屬性
修飾符
類型
說明
string | null
string
string
string
string[] | null
DiagnosticCategory
export type DiagnosticCategory = "error" | "warning" | "sourceError";
dirname
dirname(path: string): string;
參數
類型
說明
path
string
string
EntryStrategy
export type EntryStrategy =
| InlineEntryStrategy
| HoistEntryStrategy
| SingleEntryStrategy
| HookEntryStrategy
| ComponentEntryStrategy
| SmartEntryStrategy;
參考: InlineEntryStrategy, SingleEntryStrategy, HookEntryStrategy, ComponentEntryStrategy, SmartEntryStrategy
extname
extname(path: string): string;
參數
類型
說明
path
string
string
format
format(pathObject: {
root: string;
dir: string;
base: string;
ext: string;
name: string;
}): string;
參數
類型
說明
pathObject
{ root: string; dir: string; base: string; ext: string; name: string; }
string
GlobalInjections
export interface GlobalInjections
屬性
修飾符
類型
說明
{ [key: string]: string; }
(可選)
'head' | 'body'
string
HookAnalysis
export interface HookAnalysis
屬性
修飾符
類型
說明
string
boolean
'event' | 'function'
string
string
string | null
string
string
[number, number]
string
string
string | null
HookEntryStrategy
export interface HookEntryStrategy
屬性
修飾符
類型
說明
Record<string, string>
(可選)
'hook'
InlineEntryStrategy
export interface InlineEntryStrategy
屬性
修飾符
類型
說明
'inline'
InsightManifest
export interface InsightManifest
屬性
修飾符
類型
說明
Record<string, string>
{ route: string; symbols: string[]; }[]
'smart'
isAbsolute
isAbsolute(path: string): boolean;
參數
類型
說明
path
string
boolean
join
join(...paths: string[]): string;
參數
類型
說明
paths
string[]
string
MinifyMode
export type MinifyMode = "simplify" | "none";
normalize
normalize(path: string): string;
參數
類型
說明
path
string
string
Optimizer
export interface Optimizer
屬性
修飾符
類型
說明
優化器系統的使用。這可以透過自訂檔案系統更新。
方法
說明
從檔案系統轉換目錄。
從檔案系統轉換目錄。
轉換輸入的程式碼字串,不訪問檔案系統。
轉換輸入的程式碼字串,不訪問檔案系統。
優化器選項
export interface OptimizerOptions
屬性
修飾符
類型
說明
任何
(可選)
數字
(可選) 如果全域樣式小於此值,則將其內嵌
boolean
(可選) 啟用來源映射
(可選)
優化器系統
export interface OptimizerSystem
屬性
修飾符
類型
說明
() => 字串
(path: 字串) => Promise<任何>
(rootDir: 字串) => Promise<轉換模組輸入[]>
(可選)
string
(path: 字串) => Promise<任何>
解析
parse(path: string): {
root: string;
dir: string;
base: string;
ext: string;
name: string;
};
參數
類型
說明
path
string
{ root: string; dir: string; base: string; ext: string; name: string; }
路徑
export interface Path
屬性
修飾符
類型
說明
唯讀
string
唯讀
唯讀
string
唯讀
空
方法
說明
Qwik 建置模式
export type QwikBuildMode = "production" | "development";
Qwik 建置目標
export type QwikBuildTarget = "client" | "ssr" | "lib" | "test";
Qwik 套件
export interface QwikBundle
屬性
修飾符
類型
說明
string[]
(可選)
string[]
(可選)
string[]
(可選)
數字
string[]
(可選)
Qwik 資訊清單
建置的詮釋資料。其中一個用途是儲存 QRL 符號的位置。
export interface QwikManifest
屬性
修飾符
類型
說明
{ [fileName: 字串]: Qwik 套件; }
所有程式碼套件,用於了解匯入圖
全域注入[]
(可選) 要注入文件標頭的 CSS 等
string
資訊清單的內容雜湊,如果這改變了,表示程式碼也改變了
{ [symbolName: 字串]: 字串; }
QRL 的位置
{ target?: 字串; buildMode?: 字串; entryStrategy?: { [key: 字串]: 任何; }; }
(可選)
{ [name: 字串]: 字串; }
(可選)
{ [symbolName: 字串]: Qwik 符號; }
QRL 符號
string
qwikRollup
export declare function qwikRollup(
qwikRollupOpts?: QwikRollupPluginOptions,
): any;
參數
類型
說明
qwikRollupOpts
(可選)
任何
QwikRollupPluginOptions
export interface QwikRollupPluginOptions
屬性
修飾符
類型
說明
(可選) 建置 production
或 development
。
預設 development
boolean
(可選)
boolean
(可選) 印出詳細的 Qwik 外掛偵錯日誌。
預設 false
(可選) 在建置生產環境時要使用的 Qwik 進入策略。在開發過程中,類型始終為 hook
。
預設 { type: "smart" }
)
boolean
(可選) 對 ssr 建置或開發伺服器的原始檔執行 eslint。這可能會降低大型專案的啟動速度。預設為 true
(可選) SSR 建置需要在用戶端建置期間產生的資訊清單。可以使用 manifestInput
選項手動提供資訊清單。
預設 undefined
(manifest: Qwik 資訊清單) => Promise<void> | void
(可選) 用戶端建置將建立一個資訊清單,並使用產生的建置資料呼叫此鉤子。
預設 undefined
(可選)
string
(可選)應用程式的根目錄,通常與 package.json
和 rollup.config.js
位於相同目錄。
預設值 process.cwd()
string
(可選)用於尋找所有 Qwik 組件的原始碼目錄。由於 Qwik 沒有單一輸入,因此使用 srcDir
遞迴尋找 Qwik 檔案。
預設值 src
TransformModuleInput[] | null
(可選)srcDir
的替代方案,其中 srcInputs
能夠手動提供檔案。此選項適用於沒有檔案系統的環境,例如 webworker。
預設值:null
(可選)目標 client
或 ssr
。
預設值 client
((transformedModules: TransformModule[]) => Promise<void> | void) | null
(可選)在構建後呼叫的鉤子,提供在捆綁之前使用的所有已轉換模組。
QwikSymbol
export interface QwikSymbol
屬性
修飾符
類型
說明
string
boolean
'function' | 'event'
string
string
string
[number, number]
string
string | null
qwikVite
export declare function qwikVite(qwikViteOpts?: QwikVitePluginOptions): any;
參數
類型
說明
qwikViteOpts
(可選)
任何
QwikViteDevResponse
export interface QwikViteDevResponse
屬性
修飾符
類型
說明
Record<string, any>
(可選)
() => void
(可選)
QwikVitePlugin
export interface QwikVitePlugin
屬性
修飾符
類型
說明
'vite-plugin-qwik'
QwikVitePluginApi
export interface QwikVitePluginApi
屬性
修飾符
類型
說明
() => 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;
參數
類型
說明
from
string
to
string
string
resolve
resolve(...paths: string[]): string;
參數
類型
說明
paths
string[]
string
ResolvedManifest
export interface ResolvedManifest
屬性
修飾符
類型
說明
SingleEntryStrategy
export interface SingleEntryStrategy
屬性
修飾符
類型
說明
Record<string, string>
(可選)
'single'
SmartEntryStrategy
export interface SmartEntryStrategy
屬性
修飾符
類型
說明
Record<string, string>
(可選)
'smart'
SourceLocation
export interface SourceLocation
屬性
修飾符
類型
說明
數字
數字
數字
數字
數字
數字
SourceMapsOption
export type SourceMapsOption = "external" | "inline" | undefined | null;
symbolMapper
此 API 作為 Alpha 預覽版提供給開發人員,可能會根據我們收到的回饋而變更。請勿在生產環境中使用此 API。
對於給定的符號(QRL,例如 onKeydown$
),伺服器需要知道符號所在的捆綁包。
通常這是由 Qwik 的 q-manifest
提供的。但 q-manifest
僅在完整的客戶端構建後才存在。
這在開發模式中會是個問題。因此,在開發模式中,符號會使用下面的 symbolMapper 函數映射到預期的 URL。對於 Vite,給定符號的路徑是固定的。
symbolMapper: ReturnType<typeof createSymbolMapper>;
SymbolMapper
此 API 作為 Alpha 預覽版提供給開發人員,可能會根據我們收到的回饋而變更。請勿在生產環境中使用此 API。
對於給定的符號(QRL,例如 onKeydown$
),伺服器需要知道符號所在的捆綁包。
通常這是由 Qwik 的 q-manifest
提供的。但 q-manifest
僅在完整的客戶端構建後才存在。
這在開發模式中會是個問題。因此,在開發模式中,符號會使用下面的 symbolMapper 函數映射到預期的 URL。對於 Vite,給定符號的路徑是固定的。
symbolMapper: ReturnType<typeof createSymbolMapper>;
SymbolMapperFn
export type SymbolMapperFn = (
symbolName: string,
mapper: SymbolMapper | undefined,
parent?: string,
) => readonly [symbol: string, chunk: string] | undefined;
參考: SymbolMapper
系統環境
export type SystemEnvironment =
| "node"
| "deno"
| "bun"
| "webworker"
| "browsermain"
| "unknown";
transformFs
從檔案系統轉換目錄。
transformFs(opts: TransformFsOptions): Promise<TransformOutput>;
參數
類型
說明
選項
Promise<TransformOutput>
TransformFs 選項
export interface TransformFsOptions extends TransformOptions
擴展: Transform 選項
屬性
修飾符
類型
說明
string[]
transformFsSync
從檔案系統轉換目錄。
transformFsSync(opts: TransformFsOptions): TransformOutput;
參數
類型
說明
選項
Transform 模組
export interface TransformModule
屬性
修飾符
類型
說明
string
鉤子分析 | null
boolean
string | null
string | null
string
Transform 模組輸入
export interface TransformModuleInput
屬性
修飾符
類型
說明
string
string
transformModules
轉換輸入的程式碼字串,不訪問檔案系統。
transformModules(opts: TransformModulesOptions): Promise<TransformOutput>;
參數
類型
說明
選項
Promise<TransformOutput>
TransformModules 選項
export interface TransformModulesOptions extends TransformOptions
擴展: Transform 選項
屬性
修飾符
類型
說明
transformModulesSync
轉換輸入的程式碼字串,不訪問檔案系統。
transformModulesSync(opts: TransformModulesOptions): TransformOutput;
參數
類型
說明
選項
Transform 選項
export interface TransformOptions
屬性
修飾符
類型
說明
(可選)
boolean
(可選)
boolean
(可選)
(可選)
發射模式
(可選)
boolean
(可選)
string[]
(可選)
string
(可選)
string
(可選)
boolean
(可選)
string
string[]
(可選)
boolean
(可選)
string[]
(可選)
boolean
(可選)
boolean
(可選)
Transform 輸出
export interface TransformOutput
屬性
修飾符
類型
說明
診斷[]
boolean
boolean
轉譯選項
export type TranspileOption = boolean | undefined | null;
版本
versions: {
qwik: string;
}