Using lazy-loaded components in the context fails to render.
Describe the bug
In the console, you can see the mounted message of the ButtonDemo component, but the ButtonDemo component itself failed to render. Meanwhile, there are no warnings or error messages in the console regarding the rendering failure of the component.
If you only start the development server without building, the ButtonDemo component can be rendered normally.
Your Example Website or App
https://github.com/thep0y/solid-context-demo
Steps to Reproduce the Bug or Issue
bun run build
cd example
bun run build
bun run preview
Expected behavior
The ButtonDemo component renders normally.
Screenshots or Videos
No response
Platform
- OS: [Windows]
- Browser: [Chrome]
- Version: [135.0.7049.115]
Additional context
No response
Any way to get a more minimal reproduction? This requires tracing through multiple projects to figure out where the bug is.
I made a quick playground to show Context working in a lazy component.. unless you mean in a different way? https://playground.solidjs.com/anonymous/2d6654f8-d1ee-4a7c-a079-b200b23c73d1
Maybe use something like this or a basic Stackblitz as a base.
I need to try.
The current reproduction steps are based on the project I wrote, and a lot of irrelevant components have already been removed.
In the reproduced component library packages, there are currently only two components. After bundling them, there might be two issues when importing the components button and toast in the example:
- If
useToastis used inButtonDemoto get the context, it will definitely throw an errorcannot find a ToastContext. - If
useToastis not used inButtonDemoto get the context,ButtonDemowill not be added to the DOM node, but its structure can still be printed in the console.
The most critical issue is that everything works fine in the development environment, but the above two problems only occur in the production environment.