Skip to content

Commit ca53ccc

Browse files
authored
Merge pull request #448 from shairez/pr-fix-headless-bundle-issue
2 parents 7eeee67 + f2c3749 commit ca53ccc

File tree

5 files changed

+72
-7
lines changed

5 files changed

+72
-7
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,7 @@ Thumbs.db
6969

7070
# Cypress
7171
**/cypress/screenshots
72-
**/cypress/videos
72+
**/cypress/videos
73+
74+
# Verdaccio
75+
tmp

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@
105105
"vite": "^4.4.9",
106106
"vite-plugin-dts": "^3.5.3",
107107
"vite-plugin-eslint": "^1.8.1",
108+
"vite-plugin-inspect": "0.7.38",
109+
"vite-plugin-static-copy": "0.17.0",
108110
"vite-tsconfig-paths": "4.2.0",
109111
"vitest": "^0.34.3",
110112
"wrangler": "^2"

packages/kit-headless/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"main": "./index.qwik.cjs",
99
"qwik": "./index.qwik.mjs",
1010
"module": "./index.qwik.mjs",
11-
"types": "./packages/kit-headless/src/index.d.ts",
11+
"types": "./index.qwik.d.ts",
1212
"type": "module",
1313
"exports": {
1414
".": {

packages/kit-headless/vite.config.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/// <reference types="vitest" />
22

33
import { qwikVite } from '@builder.io/qwik/optimizer';
4-
import tsconfigPaths from 'vite-tsconfig-paths';
5-
import { defineConfig } from 'vite';
6-
import dts from 'vite-plugin-dts';
74
import { dirname, join } from 'path';
85
import { qwikNxVite } from 'qwik-nx/plugins';
96
import { fileURLToPath } from 'url';
7+
import { defineConfig } from 'vite';
8+
import dts from 'vite-plugin-dts';
9+
import { viteStaticCopy } from 'vite-plugin-static-copy';
10+
import tsconfigPaths from 'vite-tsconfig-paths';
1011

1112
export default defineConfig({
1213
plugins: [
@@ -15,7 +16,7 @@ export default defineConfig({
1516
tsconfigPaths({ root: '../../' }),
1617
dts({
1718
tsconfigPath: join(dirname(fileURLToPath(import.meta.url)), 'tsconfig.lib.json'),
18-
19+
entryRoot: 'src',
1920
afterDiagnostic(ds) {
2021
// ensure DTS errors are still visible - otherwise get swallowed and silent
2122
console.log((ds ?? []).map((d) => d.messageText));
@@ -29,6 +30,9 @@ export default defineConfig({
2930
return;
3031
},
3132
}),
33+
viteStaticCopy({
34+
targets: [{ src: './README.md', dest: './' }],
35+
}),
3236
],
3337
server: {
3438
fs: {
@@ -45,7 +49,8 @@ export default defineConfig({
4549
entry: './src/index.ts',
4650
// Could also be a dictionary or array of multiple entry points.
4751
name: 'headless',
48-
fileName: (format) => `index.qwik.${format === 'es' ? 'mjs' : 'cjs'}`,
52+
fileName: (format, entryName) =>
53+
`${entryName}.qwik.${format === 'es' ? 'mjs' : 'cjs'}`,
4954
// fileName: 'index',
5055
// Change this to the formats you want to support.
5156
// Don't forgot to update your package.json as well.
@@ -54,6 +59,10 @@ export default defineConfig({
5459
rollupOptions: {
5560
// External packages that should not be bundled into your library.
5661
external: ['@floating-ui/dom', 'country-list-json', 'libphonenumber-js'],
62+
output: {
63+
preserveModules: true,
64+
preserveModulesRoot: 'packages/kit-headless/src',
65+
},
5766
},
5867
},
5968
test: {

pnpm-lock.yaml

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)