Disappearing button text?
I have a Button component whose text disappears - it initially renders, then goes away. The text node itself is gone from the DOM. Can't understand what's happening.
Repo #1 is a UI library package. It has a Button component:
In repo #2, I import the Button for a login page:
Anything jump out at anybody? I think I've seen this before, where testing a UI component in the same repo is fine, but when imported for use in another project, I've seen text nodes get yeeted. Thanks for taking a look.
4 Replies
anything we can look at apart from the code snippets? something we can pause and step through the debugger.
Hey @mdynnl, yes. I created stripped down repos that demonstrate the issue:
https://github.com/greg-hammond/ui-comp-test.git
exports a Button component, and has an npm package on github.
https://github.com/greg-hammond/button-consumer-test.git
is a test project that imports Button from that package.
If you clone the test project, pnpm install, pnpm dev, and browse to :3102, you will see the problem occur.
If you build that project and run from /dist (pnpm build / pnpm start), the problem does not occur.
(And: if I have the ui-comp-test
repo open, and dev link the package, the problem also does not occur).
If you're able to take a look, that would be great. Thank you!so the problem is in ui-comp-test, bundling/exports isn't correctly set up
for authoring libraries, https://github.com/solidjs-community/rollup-preset-solid is recommended over vite, the readme has instructions and info about it
solid being a compiled framework, sources need to be shipped so that they can be compiled alongside the user code
authoring side needs to setup up conditional exports with
solid
condition so that it can be consumed from consuming side, vite-plugin-solid
already handles thatI gave this a try and it didn't seem to do anything differently. Are there other vite or solid config changes needed that aren't explicitly listed here? The readme seemed to suggest that I'd be prompted for a bunch of package.json settings, but never was. I tried to manually set those, but I never saw the /dist output look like what was suggested. These are probably all really dumb questions, I just have no experience with build config or rollup. Any easy suggestions for me?