---
title: \@qwik.dev/qwik/optimizer API Reference
---

# [API](/api) &rsaquo; @qwik.dev/qwik/optimizer

<h2 id="experimentalfeatures-blockssr">blockSSR</h2>

<h2 id="bundlegraphadder">BundleGraphAdder</h2>

A function that returns a map of bundle names to their dependencies.

```typescript
export type BundleGraphAdder = (manifest: QwikManifest) => Record<
  string,
  {
    imports?: string[];
    dynamicImports?: string[];
  }
>;
```

**References:** [QwikManifest](#qwikmanifest)

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/plugins/bundle-graph.ts)

<h2 id="experimentalfeatures-each">each</h2>

<h2 id="experimentalfeatures">ExperimentalFeatures</h2>

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.

```typescript
export declare enum ExperimentalFeatures
```

<table><thead><tr><th>

Member

</th><th>

Value

</th><th>

Description

</th></tr></thead>
<tbody><tr><td>

blockSSR

</td><td>

`"blockSSR"`

</td><td>

Enable the `blockSSR: false` route loader option

</td></tr>
<tr><td>

each

</td><td>

`"each"`

</td><td>

Enable the Each keyed-list primitive

</td></tr>
<tr><td>

insights

</td><td>

`"insights"`

</td><td>

Enable the ability to use the Qwik Insights vite plugin and `<Insights/>` component

</td></tr>
<tr><td>

noSPA

</td><td>

`"noSPA"`

</td><td>

Disable SPA navigation handler in Qwik Router

</td></tr>
<tr><td>

show

</td><td>

`"show"`

</td><td>

Enable the Show conditional primitive

</td></tr>
<tr><td>

suspense

</td><td>

`"suspense"`

</td><td>

Enable the Suspense fallback primitive

</td></tr>
<tr><td>

valibot

</td><td>

`"valibot"`

</td><td>

Enable the Valibot form validation

</td></tr>
</tbody></table>

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/plugins/plugin.ts)

<h2 id="globalinjections">GlobalInjections</h2>

```typescript
export interface GlobalInjections
```

<table><thead><tr><th>

Property

</th><th>

Modifiers

</th><th>

Type

</th><th>

Description

</th></tr></thead>
<tbody><tr><td>

attributes?

</td><td>

</td><td>

\{ [key: string]: string; }

</td><td>

_(Optional)_

</td></tr>
<tr><td>

location

</td><td>

</td><td>

'head' \| 'body'

</td><td>

</td></tr>
<tr><td>

tag

</td><td>

</td><td>

string

</td><td>

</td></tr>
</tbody></table>

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/types.ts)

<h2 id="experimentalfeatures-insights">insights</h2>

<h2 id="experimentalfeatures-nospa">noSPA</h2>

<h2 id="qwikasset">QwikAsset</h2>

```typescript
export interface QwikAsset
```

<table><thead><tr><th>

Property

</th><th>

Modifiers

</th><th>

Type

</th><th>

Description

</th></tr></thead>
<tbody><tr><td>

name

</td><td>

</td><td>

string \| undefined

</td><td>

Name of the asset

</td></tr>
<tr><td>

size

</td><td>

</td><td>

number

</td><td>

Size of the asset

</td></tr>
</tbody></table>

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/types.ts)

<h2 id="qwikbuildmode">QwikBuildMode</h2>

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

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/plugins/plugin.ts)

<h2 id="qwikbuildtarget">QwikBuildTarget</h2>

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

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/plugins/plugin.ts)

<h2 id="qwikbundle">QwikBundle</h2>

```typescript
export interface QwikBundle
```

<table><thead><tr><th>

Property

</th><th>

Modifiers

</th><th>

Type

</th><th>

Description

</th></tr></thead>
<tbody><tr><td>

dynamicImports?

</td><td>

</td><td>

string[]

</td><td>

_(Optional)_ Dynamic imports

</td></tr>
<tr><td>

imports?

</td><td>

</td><td>

string[]

</td><td>

_(Optional)_ Direct imports

</td></tr>
<tr><td>

interactivity?

</td><td>

</td><td>

number

</td><td>

_(Optional)_ Interactivity score of the bundle

</td></tr>
<tr><td>

origins?

</td><td>

</td><td>

string[]

</td><td>

_(Optional)_ Source files of the bundle

</td></tr>
<tr><td>

size

</td><td>

</td><td>

number

</td><td>

Size of the bundle

</td></tr>
<tr><td>

symbols?

</td><td>

</td><td>

string[]

</td><td>

_(Optional)_ Symbols in the bundle

</td></tr>
<tr><td>

total

</td><td>

</td><td>

number

</td><td>

Total size of this bundle's static import graph

</td></tr>
</tbody></table>

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/types.ts)

<h2 id="qwikbundlegraph">QwikBundleGraph</h2>

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', ]

```typescript
export type QwikBundleGraph = Array<string | number>;
```

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/types.ts)

<h2 id="qwikmanifest">QwikManifest</h2>

The metadata of the build. One of its uses is storing where QRL symbols are located.

```typescript
export interface QwikManifest
```

<table><thead><tr><th>

Property

</th><th>

Modifiers

</th><th>

Type

</th><th>

Description

</th></tr></thead>
<tbody><tr><td>

assets?

</td><td>

</td><td>

\{ [fileName: string]: [QwikAsset](#qwikasset); }

</td><td>

_(Optional)_ All assets. The key is the fileName relative to the rootDir

</td></tr>
<tr><td>

bundleGraph?

</td><td>

</td><td>

[QwikBundleGraph](#qwikbundlegraph)

</td><td>

_(Optional)_ All bundles in a compact graph format with probabilities

</td></tr>
<tr><td>

bundleGraphAsset?

</td><td>

</td><td>

string

</td><td>

_(Optional)_ The bundle graph fileName

</td></tr>
<tr><td>

bundles

</td><td>

</td><td>

\{ [fileName: string]: [QwikBundle](#qwikbundle); }

</td><td>

All code bundles, used to know the import graph. The key is the bundle fileName relative to "build/"

</td></tr>
<tr><td>

core?

</td><td>

</td><td>

string

</td><td>

_(Optional)_ The Qwik core bundle fileName

</td></tr>
<tr><td>

injections?

</td><td>

</td><td>

[GlobalInjections](#globalinjections)[]

</td><td>

_(Optional)_ CSS etc to inject in the document head

</td></tr>
<tr><td>

manifestHash

</td><td>

</td><td>

string

</td><td>

Content hash of the manifest, if this changes, the code changed

</td></tr>
<tr><td>

mapping

</td><td>

</td><td>

\{ [symbolName: string]: string; }

</td><td>

Where QRLs are located. The key is the symbol name, the value is the bundle fileName

</td></tr>
<tr><td>

options?

</td><td>

</td><td>

\{ target?: string; buildMode?: string; entryStrategy?: \{ type: EntryStrategy['type']; }; }

</td><td>

_(Optional)_ The options used to build the manifest

</td></tr>
<tr><td>

platform?

</td><td>

</td><td>

\{ [name: string]: string; }

</td><td>

_(Optional)_ The platform used to build the manifest

</td></tr>
<tr><td>

preloader?

</td><td>

</td><td>

string

</td><td>

_(Optional)_ The preloader bundle fileName

</td></tr>
<tr><td>

qwikLoader?

</td><td>

</td><td>

string

</td><td>

_(Optional)_ The Qwik loader bundle fileName

</td></tr>
<tr><td>

symbols

</td><td>

</td><td>

\{ [symbolName: string]: [QwikSymbol](#qwiksymbol); }

</td><td>

QRL symbols

</td></tr>
<tr><td>

version

</td><td>

</td><td>

string

</td><td>

The version of the manifest

</td></tr>
</tbody></table>

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/types.ts)

<h2 id="qwikrollup">qwikRollup</h2>

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

<table><thead><tr><th>

Parameter

</th><th>

Type

</th><th>

Description

</th></tr></thead>
<tbody><tr><td>

qwikRollupOpts

</td><td>

[QwikRollupPluginOptions](#qwikrolluppluginoptions)

</td><td>

_(Optional)_

</td></tr>
</tbody></table>

**Returns:**

any

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/plugins/rollup.ts)

<h2 id="qwikrolluppluginoptions">QwikRollupPluginOptions</h2>

```typescript
export interface QwikRollupPluginOptions
```

<table><thead><tr><th>

Property

</th><th>

Modifiers

</th><th>

Type

</th><th>

Description

</th></tr></thead>
<tbody><tr><td>

buildMode?

</td><td>

</td><td>

[QwikBuildMode](#qwikbuildmode)

</td><td>

_(Optional)_ Build `production` or `development`.

Default `development`

</td></tr>
<tr><td>

csr?

</td><td>

</td><td>

boolean

</td><td>

_(Optional)_

</td></tr>
<tr><td>

debug?

</td><td>

</td><td>

boolean

</td><td>

_(Optional)_ Prints verbose Qwik plugin debug logs.

Default `false`

</td></tr>
<tr><td>

entryStrategy?

</td><td>

</td><td>

EntryStrategy

</td><td>

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

Default `{ type: "smart" }`)

</td></tr>
<tr><td>

experimental?

</td><td>

</td><td>

(keyof typeof [ExperimentalFeatures](#experimentalfeatures))[]

</td><td>

_(Optional)_ Experimental features. These can come and go in patch releases, and their API is not guaranteed to be stable between releases.

</td></tr>
<tr><td>

lint?

</td><td>

</td><td>

boolean

</td><td>

_(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`

</td></tr>
<tr><td>

manifestInput?

</td><td>

</td><td>

[QwikManifest](#qwikmanifest)

</td><td>

_(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`

</td></tr>
<tr><td>

manifestOutput?

</td><td>

</td><td>

(manifest: [QwikManifest](#qwikmanifest)) =&gt; Promise&lt;void&gt; \| void

</td><td>

_(Optional)_ The client build will create a manifest and this hook is called with the generated build data.

Default `undefined`

</td></tr>
<tr><td>

optimizerOptions?

</td><td>

</td><td>

OptimizerOptions

</td><td>

_(Optional)_

</td></tr>
<tr><td>

rootDir?

</td><td>

</td><td>

string

</td><td>

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

Default `process.cwd()`

</td></tr>
<tr><td>

srcDir?

</td><td>

</td><td>

string

</td><td>

_(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`

</td></tr>
<tr><td>

srcInputs?

</td><td>

</td><td>

TransformModuleInput[] \| null

</td><td>

_(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`

</td></tr>
<tr><td>

target?

</td><td>

</td><td>

[QwikBuildTarget](#qwikbuildtarget)

</td><td>

_(Optional)_ Target `client` or `ssr`.

Default `client`

</td></tr>
<tr><td>

transformedModuleOutput?

</td><td>

</td><td>

((transformedModules: TransformModule[]) =&gt; Promise&lt;void&gt; \| void) \| null

</td><td>

_(Optional)_ Hook that's called after the build and provides all of the transformed modules that were used before bundling.

</td></tr>
</tbody></table>

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/plugins/rollup.ts)

<h2 id="qwiksymbol">QwikSymbol</h2>

```typescript
export interface QwikSymbol
```

<table><thead><tr><th>

Property

</th><th>

Modifiers

</th><th>

Type

</th><th>

Description

</th></tr></thead>
<tbody><tr><td>

canonicalFilename

</td><td>

</td><td>

string

</td><td>

</td></tr>
<tr><td>

captureNames?

</td><td>

</td><td>

string[]

</td><td>

_(Optional)_ The transformed names of scoped variables, if any

</td></tr>
<tr><td>

captures

</td><td>

</td><td>

boolean

</td><td>

Whether the symbol captures a variable

</td></tr>
<tr><td>

ctxKind

</td><td>

</td><td>

'function' \| 'eventHandler'

</td><td>

</td></tr>
<tr><td>

ctxName

</td><td>

</td><td>

string

</td><td>

</td></tr>
<tr><td>

displayName

</td><td>

</td><td>

string

</td><td>

</td></tr>
<tr><td>

hash

</td><td>

</td><td>

string

</td><td>

</td></tr>
<tr><td>

loc

</td><td>

</td><td>

[number, number]

</td><td>

</td></tr>
<tr><td>

origin

</td><td>

</td><td>

string

</td><td>

</td></tr>
<tr><td>

paramNames?

</td><td>

</td><td>

string[]

</td><td>

_(Optional)_ The parameter names if it's a function with parameters

</td></tr>
<tr><td>

parent

</td><td>

</td><td>

string \| null

</td><td>

</td></tr>
</tbody></table>

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/types.ts)

<h2 id="qwikvite">qwikVite</h2>

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

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

<table><thead><tr><th>

Parameter

</th><th>

Type

</th><th>

Description

</th></tr></thead>
<tbody><tr><td>

qwikViteOpts

</td><td>

[QwikVitePluginOptions](#qwikvitepluginoptions)

</td><td>

_(Optional)_

</td></tr>
</tbody></table>

**Returns:**

any

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/plugins/vite.ts)

<h2 id="qwikviteplugin">QwikVitePlugin</h2>

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.

```typescript
export type QwikVitePlugin = P<QwikVitePluginApi> & {
  name: "vite-plugin-qwik";
};
```

**References:** [QwikVitePluginApi](#qwikvitepluginapi)

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/plugins/vite.ts)

<h2 id="qwikvitepluginapi">QwikVitePluginApi</h2>

```typescript
export interface QwikVitePluginApi
```

<table><thead><tr><th>

Property

</th><th>

Modifiers

</th><th>

Type

</th><th>

Description

</th></tr></thead>
<tbody><tr><td>

getClientOutDir

</td><td>

</td><td>

() =&gt; string \| null

</td><td>

</td></tr>
<tr><td>

getClientPublicOutDir

</td><td>

</td><td>

() =&gt; string \| null

</td><td>

</td></tr>
<tr><td>

getManifest

</td><td>

</td><td>

() =&gt; [QwikManifest](#qwikmanifest) \| null

</td><td>

</td></tr>
<tr><td>

getOptimizer

</td><td>

</td><td>

() =&gt; Optimizer \| null

</td><td>

</td></tr>
<tr><td>

getOptions

</td><td>

</td><td>

() =&gt; NormalizedQwikPluginOptions

</td><td>

</td></tr>
<tr><td>

getRootDir

</td><td>

</td><td>

() =&gt; string \| null

</td><td>

</td></tr>
<tr><td>

onSegment

</td><td>

</td><td>

(callback: SegmentCallback) =&gt; void

</td><td>

Register a callback that fires for each segment emitted during transform.

</td></tr>
<tr><td>

registerBundleGraphAdder

</td><td>

</td><td>

(adder: [BundleGraphAdder](#bundlegraphadder)) =&gt; void

</td><td>

</td></tr>
</tbody></table>

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/plugins/vite.ts)

<h2 id="qwikvitepluginoptions">QwikVitePluginOptions</h2>

```typescript
export type QwikVitePluginOptions =
  | QwikVitePluginCSROptions
  | QwikVitePluginSSROptions;
```

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/plugins/vite.ts)

<h2 id="resolvedmanifest">ResolvedManifest</h2>

```typescript
export interface ResolvedManifest
```

<table><thead><tr><th>

Property

</th><th>

Modifiers

</th><th>

Type

</th><th>

Description

</th></tr></thead>
<tbody><tr><td>

bundleGraph?

</td><td>

</td><td>

[QwikBundleGraph](#qwikbundlegraph)

</td><td>

_(Optional)_

</td></tr>
<tr><td>

injections?

</td><td>

</td><td>

[GlobalInjections](#globalinjections)[]

</td><td>

_(Optional)_

</td></tr>
<tr><td>

manifest

</td><td>

</td><td>

[ServerQwikManifest](#serverqwikmanifest)

</td><td>

</td></tr>
<tr><td>

mapper

</td><td>

</td><td>

[SymbolMapper](#symbolmapper)

</td><td>

</td></tr>
</tbody></table>

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/types.ts)

<h2 id="serverqwikmanifest">ServerQwikManifest</h2>

The manifest values that are needed for SSR.

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

**References:** [QwikManifest](#qwikmanifest)

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/types.ts)

<h2 id="experimentalfeatures-show">show</h2>

<h2 id="experimentalfeatures-suspense">suspense</h2>

<h2 id="symbolmapper">SymbolMapper</h2>

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

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/types.ts)

<h2 id="symbolmapperfn">SymbolMapperFn</h2>

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

**References:** [SymbolMapper](#symbolmapper)

[Edit this section](https://github.com/QwikDev/qwik/tree/main/packages/qwik-vite/src/types.ts)

<h2 id="experimentalfeatures-valibot">valibot</h2>
