API โ€บ @builder.io/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

manual?

Record<string, string>

(Optional)

type

'component'

Edit this section

createOptimizer

createOptimizer: (optimizerOptions?: OptimizerOptions) => Promise<Optimizer>;

Parameter

Type

Description

optimizerOptions

OptimizerOptions

(Optional)

Promise<Optimizer>

Edit this section

Diagnostic

export interface Diagnostic

Property

Modifiers

Type

Description

category

DiagnosticCategory

code

string | null

file

string

highlights

SourceLocation[]

message

string

scope

string

suggestions

string[] | null

Edit this section

DiagnosticCategory

export type DiagnosticCategory = "error" | "warning" | "sourceError";

Edit this section

dirname

dirname(path: string): string;

Parameter

Type

Description

path

string

string

EntryStrategy

export type EntryStrategy =
  | InlineEntryStrategy
  | HoistEntryStrategy
  | SingleEntryStrategy
  | HookEntryStrategy
  | ComponentEntryStrategy
  | SmartEntryStrategy;

References: InlineEntryStrategy, SingleEntryStrategy, HookEntryStrategy, ComponentEntryStrategy, SmartEntryStrategy

Edit this section

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

attributes?

{ [key: string]: string; }

(Optional)

location

'head' | 'body'

tag

string

Edit this section

HookAnalysis

export interface HookAnalysis

Property

Modifiers

Type

Description

canonicalFilename

string

captures

boolean

ctxKind

'event' | 'function'

ctxName

string

displayName

string

entry

string | null

extension

string

hash

string

loc

[number, number]

name

string

origin

string

parent

string | null

Edit this section

HookEntryStrategy

export interface HookEntryStrategy

Property

Modifiers

Type

Description

manual?

Record<string, string>

(Optional)

type

'hook'

Edit this section

InlineEntryStrategy

export interface InlineEntryStrategy

Property

Modifiers

Type

Description

type

'inline'

Edit this section

InsightManifest

export interface InsightManifest

Property

Modifiers

Type

Description

manual

Record<string, string>

prefetch

{ route: string; symbols: string[]; }[]

type

'smart'

Edit this section

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";

Edit this section

normalize

normalize(path: string): string;

Parameter

Type

Description

path

string

string

Optimizer

export interface Optimizer

Property

Modifiers

Type

Description

sys

OptimizerSystem

Optimizer system use. This can be updated with a custom file system.

Method

Description

transformFs(opts)

Transforms the directory from the file system.

transformFsSync(opts)

Transforms the directory from the file system.

transformModules(opts)

Transforms the input code string, does not access the file system.

transformModulesSync(opts)

Transforms the input code string, does not access the file system.

Edit this section

OptimizerOptions

export interface OptimizerOptions

Property

Modifiers

Type

Description

binding?

any

(Optional)

inlineStylesUpToBytes?

number

(Optional) Inline the global styles if they're smaller than this

sourcemap?

boolean

(Optional) Enable sourcemaps

sys?

OptimizerSystem

(Optional)

Edit this section

OptimizerSystem

export interface OptimizerSystem

Property

Modifiers

Type

Description

cwd

() => string

dynamicImport

(path: string) => Promise<any>

env

SystemEnvironment

getInputFiles?

(rootDir: string) => Promise<TransformModuleInput[]>

(Optional)

os

string

path

Path

strictDynamicImport

(path: string) => Promise<any>

Edit this section

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

delimiter

readonly

string

posix

readonly

Path

sep

readonly

string

win32

readonly

null

Method

Description

basename(path, ext)

dirname(path)

extname(path)

format(pathObject)

isAbsolute(path)

join(paths)

normalize(path)

parse(path)

relative(from, to)

resolve(paths)

Edit this section

QwikBuildMode

export type QwikBuildMode = "production" | "development";

Edit this section

QwikBuildTarget

export type QwikBuildTarget = "client" | "ssr" | "lib" | "test";

Edit this section

QwikBundle

export interface QwikBundle

Property

Modifiers

Type

Description

dynamicImports?

string[]

(Optional)

imports?

string[]

(Optional)

origins?

string[]

(Optional)

size

number

symbols?

string[]

(Optional)

Edit this section

QwikManifest

export interface QwikManifest

Property

Modifiers

Type

Description

bundles

{ [fileName: string]: QwikBundle; }

injections?

GlobalInjections[]

(Optional)

manifestHash

string

mapping

{ [symbolName: string]: string; }

options?

{ target?: string; buildMode?: string; entryStrategy?: { [key: string]: any; }; }

(Optional)

platform?

{ [name: string]: string; }

(Optional)

symbols

{ [symbolName: string]: QwikSymbol; }

version

string

Edit this section

qwikRollup

export declare function qwikRollup(
  qwikRollupOpts?: QwikRollupPluginOptions,
): any;

Parameter

Type

Description

qwikRollupOpts

QwikRollupPluginOptions

(Optional)

any

Edit this section

QwikRollupPluginOptions

export interface QwikRollupPluginOptions

Property

Modifiers

Type

Description

buildMode?

QwikBuildMode

(Optional) Build production or development.

Default development

csr?

boolean

(Optional)

debug?

boolean

(Optional) Prints verbose Qwik plugin debug logs.

Default false

entryStrategy?

EntryStrategy

(Optional) The Qwik entry strategy to use while building for production. During development the type is always hook.

Default { type: "smart" })

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 true

manifestInput?

QwikManifest

(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

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 undefined

optimizerOptions?

OptimizerOptions

(Optional)

rootDir?

string

(Optional) The root of the application, which is commonly the same directory as package.json and rollup.config.js.

Default process.cwd()

srcDir?

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

srcInputs?

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

target?

QwikBuildTarget

(Optional) Target client or ssr.

Default client

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.

Edit this section

QwikSymbol

export interface QwikSymbol

Property

Modifiers

Type

Description

canonicalFilename

string

captures

boolean

ctxKind

'function' | 'event'

ctxName

string

displayName

string

hash

string

loc

[number, number]

origin

string

parent

string | null

Edit this section

qwikVite

export declare function qwikVite(qwikViteOpts?: QwikVitePluginOptions): any;

Parameter

Type

Description

qwikViteOpts

QwikVitePluginOptions

(Optional)

any

Edit this section

QwikViteDevResponse

export interface QwikViteDevResponse

Property

Modifiers

Type

Description

_qwikEnvData?

Record<string, any>

(Optional)

_qwikRenderResolve?

() => void

(Optional)

Edit this section

QwikVitePlugin

export interface QwikVitePlugin

Property

Modifiers

Type

Description

api

QwikVitePluginApi

name

'vite-plugin-qwik'

Edit this section

QwikVitePluginApi

export interface QwikVitePluginApi

Property

Modifiers

Type

Description

getClientOutDir

() => string | null

getClientPublicOutDir

() => string | null

getInsightsManifest

(clientOutDir?: string | null) => Promise<InsightManifest | null>

getManifest

() => QwikManifest | null

getOptimizer

() => Optimizer | null

getOptions

() => NormalizedQwikPluginOptions

getRootDir

() => string | null

Edit this section

QwikVitePluginOptions

export type QwikVitePluginOptions =
  | QwikVitePluginCSROptions
  | QwikVitePluginSSROptions;

Edit this section

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

manifest

QwikManifest

mapper

SymbolMapper

Edit this section

SingleEntryStrategy

export interface SingleEntryStrategy

Property

Modifiers

Type

Description

manual?

Record<string, string>

(Optional)

type

'single'

Edit this section

SmartEntryStrategy

export interface SmartEntryStrategy

Property

Modifiers

Type

Description

manual?

Record<string, string>

(Optional)

type

'smart'

Edit this section

SourceLocation

export interface SourceLocation

Property

Modifiers

Type

Description

endCol

number

endLine

number

hi

number

lo

number

startCol

number

startLine

number

Edit this section

SourceMapsOption

export type SourceMapsOption = "external" | "inline" | undefined | null;

Edit this section

SymbolMapper

export type SymbolMapper = Record<
  string,
  readonly [symbol: string, chunk: string]
>;

Edit this section

SymbolMapperFn

export type SymbolMapperFn = (
  symbolName: string,
  mapper: SymbolMapper | undefined,
) => readonly [symbol: string, chunk: string] | undefined;

References: SymbolMapper

Edit this section

SystemEnvironment

export type SystemEnvironment =
  | "node"
  | "deno"
  | "bun"
  | "webworker"
  | "browsermain"
  | "unknown";

Edit this section

transformFs

Transforms the directory from the file system.

transformFs(opts: TransformFsOptions): Promise<TransformOutput>;

Parameter

Type

Description

opts

TransformFsOptions

Promise<TransformOutput>

TransformFsOptions

export interface TransformFsOptions extends TransformOptions

Extends: TransformOptions

Property

Modifiers

Type

Description

vendorRoots

string[]

Edit this section

transformFsSync

Transforms the directory from the file system.

transformFsSync(opts: TransformFsOptions): TransformOutput;

Parameter

Type

Description

opts

TransformFsOptions

TransformOutput

TransformModule

export interface TransformModule

Property

Modifiers

Type

Description

code

string

hook

HookAnalysis | null

isEntry

boolean

map

string | null

origPath

string | null

path

string

Edit this section

TransformModuleInput

export interface TransformModuleInput

Property

Modifiers

Type

Description

code

string

path

string

Edit this section

transformModules

Transforms the input code string, does not access the file system.

transformModules(opts: TransformModulesOptions): Promise<TransformOutput>;

Parameter

Type

Description

opts

TransformModulesOptions

Promise<TransformOutput>

TransformModulesOptions

export interface TransformModulesOptions extends TransformOptions

Extends: TransformOptions

Property

Modifiers

Type

Description

input

TransformModuleInput[]

Edit this section

transformModulesSync

Transforms the input code string, does not access the file system.

transformModulesSync(opts: TransformModulesOptions): TransformOutput;

Parameter

Type

Description

opts

TransformModulesOptions

TransformOutput

TransformOptions

export interface TransformOptions

Property

Modifiers

Type

Description

entryStrategy?

EntryStrategy

(Optional)

explicitExtensions?

boolean

(Optional)

isServer?

boolean

(Optional)

minify?

MinifyMode

(Optional)

mode?

EmitMode

(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)

Edit this section

TransformOutput

export interface TransformOutput

Property

Modifiers

Type

Description

diagnostics

Diagnostic[]

isJsx

boolean

isTypeScript

boolean

modules

TransformModule[]

Edit this section

TranspileOption

export type TranspileOption = boolean | undefined | null;

Edit this section

versions

versions: {
  qwik: string;
}

Edit this section