API › @qwik.dev/qwik/optimizer

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

Edit this section

enableRequestRewrite

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

enableRequestRewrite

"enableRequestRewrite"

Enable request.rewrite()

insights

"insights"

Enable the ability to use the Qwik Insights vite plugin and <Insights/> 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$

Edit this section

GlobalInjections

export interface GlobalInjections

Property

Modifiers

Type

Description

attributes?

{ [key: string]: string; }

(Optional)

location

'head' | 'body'

tag

string

Edit this section

insights

noSPA

preventNavigate

QwikAsset

export interface QwikAsset

Property

Modifiers

Type

Description

name

string | undefined

Name of the asset

size

number

Size of the asset

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

Edit this section

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

Edit this section

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?

QwikBundleGraph

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

GlobalInjections[]

(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

Edit this section

qwikRollup

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

Parameter

Type

Description

qwikRollupOpts

QwikRollupPluginOptions

(Optional)

Returns:

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 segment.

Default { type: "smart" })

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

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

Edit this section

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

QwikVitePluginOptions

(Optional)

Returns:

any

Edit this section

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

Edit this section

QwikVitePluginApi

export interface QwikVitePluginApi

Property

Modifiers

Type

Description

getAssetsDir

() => string | undefined

getClientOutDir

() => string | null

getClientPublicOutDir

() => string | null

getManifest

() => QwikManifest | null

getOptimizer

() => Optimizer | null

getOptions

() => NormalizedQwikPluginOptions

getRootDir

() => string | null

registerBundleGraphAdder

(adder: BundleGraphAdder) => void

Edit this section

QwikVitePluginOptions

export type QwikVitePluginOptions =
  | QwikVitePluginCSROptions
  | QwikVitePluginSSROptions;

Edit this section

ResolvedManifest

export interface ResolvedManifest

Property

Modifiers

Type

Description

bundleGraph?

QwikBundleGraph

(Optional)

injections?

GlobalInjections[]

(Optional)

manifest

ServerQwikManifest

mapper

SymbolMapper

Edit this section

ServerQwikManifest

The manifest values that are needed for SSR.

export type ServerQwikManifest = Pick<
  QwikManifest,
  | "manifestHash"
  | "injections"
  | "bundleGraph"
  | "bundleGraphAsset"
  | "mapping"
  | "preloader"
  | "core"
  | "qwikLoader"
>;

References: QwikManifest

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,
  parent?: string,
) => readonly [symbol: string, chunk: string] | undefined;

References: SymbolMapper

Edit this section

valibot

webWorker