Skip to content

Commit b00c52a

Browse files
committed
fix(qc): better zod bundling
1 parent 17a72c6 commit b00c52a

File tree

9 files changed

+20
-8
lines changed

9 files changed

+20
-8
lines changed

.changeset/dirty-tools-travel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@builder.io/qwik-city': patch
3+
---
4+
5+
fix: `zod` is now imported as `import * as z from 'zod'`, which vastly improves bundling. The Insights app client code reduced by 12kB.

packages/docs/src/routes/docs/labs/typed-routes/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ The initialization process will create some important files for you.
117117

118118
### Declare Route Details
119119
```typescript title="/src/routes/pokemon/[pokemonId]/routeInfo.ts"
120-
import { z } from "zod";
120+
import * as z from "zod";
121121

122122
export const Route = {
123123
name: "PokemonDetail",

packages/insights/src/routes/app/[publicApiKey]/app.form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { z } from 'zod';
1+
import * as z from 'zod';
22

33
export const ApplicationForm = z.object({
44
name: z.string().min(1, 'Application name is required.'),

packages/insights/src/types/q-manifest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { z } from 'zod';
1+
import * as z from 'zod';
22

33
export const QManifestSymbol = z.object({
44
origin: z.string(),

packages/qwik-city/src/buildtime/vite/plugin.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,14 @@ function qwikCityPlugin(userOpts?: QwikCityVitePluginOptions): any {
7070
},
7171
ssr: {
7272
external: ['node:async_hooks'],
73-
noExternal: [QWIK_CITY, QWIK_CITY_PLAN_ID, QWIK_CITY_ENTRIES_ID, QWIK_CITY_SW_REGISTER],
73+
noExternal: [
74+
QWIK_CITY,
75+
QWIK_CITY_PLAN_ID,
76+
QWIK_CITY_ENTRIES_ID,
77+
QWIK_CITY_SW_REGISTER,
78+
// We've had reports of bundling issues with zod
79+
'zod',
80+
],
7481
},
7582
};
7683
return updatedViteConfig;

packages/qwik-city/src/runtime/src/server-functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from '@builder.io/qwik';
1515

1616
import * as v from 'valibot';
17-
import { z } from 'zod';
17+
import * as z from 'zod';
1818
import type { RequestEventLoader } from '../../middleware/request-handler/types';
1919
import { QACTION_KEY, QDATA_KEY, QFN_KEY } from './constants';
2020
import { RouteStateContext } from './contexts';

packages/qwik-city/src/runtime/src/server-functions.unit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expectTypeOf, test } from 'vitest';
2-
import { z } from 'zod';
2+
import * as z from 'zod';
33
import { server$ } from './server-functions';
44
import type { RequestEventBase, ValidatorErrorType } from './types';
55

packages/qwik-labs/src/insights/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { component$, sync$ } from '@builder.io/qwik';
2-
import { z } from 'zod';
2+
import * as z from 'zod';
33

44
export interface InsightsPayload {
55
/** Qwik version */

starters/apps/qwikcity-test/src/routes/(common)/(auth)/sign-in/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
zod$,
1212
} from "@builder.io/qwik-city";
1313
import { isUserAuthenticated, signIn } from "../../../../auth/auth";
14-
import { z } from "zod";
14+
import * as z from "zod";
1515

1616
export const onGet: RequestHandler = async ({ redirect, cookie }) => {
1717
if (await isUserAuthenticated(cookie)) {

0 commit comments

Comments
 (0)