#Component Library Nested files

15 messages ยท Page 1 of 1 (latest)

broken lintel
#

Hello! ๐Ÿ™‚ If you create a component library using npm create qwik@latest it forces you to export all of your components on a top level. If it is a bigger library it does not seems to be a good approach. ๐Ÿ˜ฆ Is it possible to use subfolders and paths somehow?

cloud flame
#

๐Ÿ™‹๐Ÿปโ€โ™‚๏ธ

broken lintel
#

yes, this is what I mean, that I have to export everything in the src/index.ts
so I cannot import stuff like:
my-lib/some-path/some-component
and this would be really useful if I have a good amount of components

cloud flame
#

I'm not much familiar with the lib-ability of Qwik yet. I see it produces a commonjs and module files

#

pnpm run build.lib

#

looking at the .mjs file, I see it exports each component

#

I presume that your Qwik app that consumes the lib, will bundle only the exported components being used

fiery crane
#

you can actually configure whatever paths you want by changing your package.json exports field

#

but the consumer of your library will probably be using a "tree-shaking" bundler (vite etc) that will remove any other exports anyway, so it doesn't matter too much

broken lintel
#

Thank you for the answers! ๐Ÿ™‚ I know I can have multiple exports in the package.json, the question is can I have multiple output files for the build itself.

#

Or I have to create my own build, and just make sure I am building filename.qwik.js files?

karmic onyx
#

@broken lintel This is a problem we are actively trying to solve for qwik-ui as well, and it doesn't seem to be an easy one..

So far we have found a way to separate each bundles with the help of vite.config.ts, but we currently have a rollup issue in production.

Feel free to hang out on the qwikifiers discord to check up the advancement of all this.

Also there a github issue you can follow: https://github.com/qwikifiers/qwik-ui/issues/453

GitHub

Using v0.1.17, my builds and previews fail with the following error: RollupError: Could not resolve "../node_modules/@qwik-ui/headless/components/accordion/accordion-context-id.qwik.mjs" ...

#

A workaround at the moment would be to create multiple separate packages like radix/ui primitives for each component of your library