Skip to content

Commit 2969214

Browse files
committed
build(headless): fix large bundle size
1 parent 76c442a commit 2969214

File tree

6 files changed

+202
-98
lines changed

6 files changed

+202
-98
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
},
2424
"packageManager": "[email protected]",
2525
"devDependencies": {
26-
"@builder.io/qwik": "^1.2.12",
27-
"@builder.io/qwik-city": "^1.2.12",
26+
"@builder.io/qwik": "^1.2.17",
27+
"@builder.io/qwik-city": "^1.2.17",
2828
"@commitlint/cli": "^17.7.1",
2929
"@commitlint/config-angular": "^17.7.0",
3030
"@commitlint/config-conventional": "^17.7.0",
@@ -82,7 +82,7 @@
8282
"eslint": "^8.48.0",
8383
"eslint-config-prettier": "^8",
8484
"eslint-plugin-cypress": "^2.14.0",
85-
"eslint-plugin-qwik": "^1.2.12",
85+
"eslint-plugin-qwik": "^1.2.17",
8686
"eslint-plugin-storybook": "^0.6.13",
8787
"focus-trap": "7.5.3",
8888
"husky": "^8.0.3",

packages/kit-headless/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@
2222
"private": false,
2323
"scripts": {},
2424
"peerDependencies": {
25-
"@builder.io/qwik": ">1.2.11"
25+
"@builder.io/qwik": ">=1.2.17"
2626
},
2727
"dependencies": {
28-
"@floating-ui/dom": "1.0.10",
28+
"@qwik-ui/utils": "workspace:*",
29+
"@floating-ui/dom": "^1.0.10",
30+
"focus-trap": "^7.5.3",
31+
"body-scroll-lock": "^4.0.0-beta.0",
2932
"country-list-json": "^1.1.0",
3033
"libphonenumber-js": "^1.10.43"
3134
}

packages/kit-headless/vite.config.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/// <reference types="vitest" />
2-
32
import { qwikVite } from '@builder.io/qwik/optimizer';
43
import { dirname, join } from 'path';
54
import { qwikNxVite } from 'qwik-nx/plugins';
@@ -8,6 +7,11 @@ import { defineConfig } from 'vite';
87
import dts from 'vite-plugin-dts';
98
import { viteStaticCopy } from 'vite-plugin-static-copy';
109
import tsconfigPaths from 'vite-tsconfig-paths';
10+
import pkg from './package.json';
11+
12+
const { dependencies = {}, peerDependencies = {} } = pkg as any;
13+
const makeRegex = (dep: any) => new RegExp(`^${dep}(/.*)?$`);
14+
const excludeAll = (obj: any) => Object.keys(obj).map(makeRegex);
1115

1216
export default defineConfig({
1317
plugins: [
@@ -57,6 +61,11 @@ export default defineConfig({
5761
formats: ['es', 'cjs'],
5862
},
5963
rollupOptions: {
64+
external: [
65+
/^node:.*/,
66+
...excludeAll(dependencies),
67+
...excludeAll(peerDependencies),
68+
],
6069
output: {
6170
preserveModules: true,
6271
preserveModulesRoot: 'packages/kit-headless/src',

packages/utils/package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@qwik-ui/utils",
3-
"version": "0.0.0",
3+
"version": "0.0.1",
44
"description": "Qwik UI Utils",
55
"publishConfig": {
66
"access": "public"
@@ -9,7 +9,13 @@
99
"tailwind-merge": "^1.14.0"
1010
},
1111
"type": "module",
12-
"main": "./index.js",
13-
"module": "./index.mjs",
12+
"exports": {
13+
".": {
14+
"import": "./index.js",
15+
"require": "./index.cjs"
16+
}
17+
},
18+
"main": "./index.cjs",
19+
"module": "./index.js",
1420
"typings": "./index.d.ts"
1521
}

packages/utils/vite.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/// <reference types="vitest" />
22
import { defineConfig } from 'vite';
33

4-
import viteTsConfigPaths from 'vite-tsconfig-paths';
5-
import dts from 'vite-plugin-dts';
64
import * as path from 'path';
5+
import dts from 'vite-plugin-dts';
6+
import viteTsConfigPaths from 'vite-tsconfig-paths';
77

88
export default defineConfig({
9-
cacheDir: '../../node_modules/.vite/cva',
9+
cacheDir: '../../node_modules/.vite/utils',
1010

1111
plugins: [
1212
dts({
@@ -35,7 +35,7 @@ export default defineConfig({
3535
lib: {
3636
// Could also be a dictionary or array of multiple entry points.
3737
entry: 'src/index.ts',
38-
name: 'cva',
38+
name: 'utils',
3939
fileName: 'index',
4040
// Change this to the formats you want to support.
4141
// Don't forget to update your package.json as well.

0 commit comments

Comments
 (0)