-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[π] Library mode + preserveModules -> error in consumer project: Cannot resolve symbol s_c7PiYJ1s0GU β QWIK ERROR Error: Code(31) #5473
Comments
Makes sense, can be solved by changing the names of entries to include their path. I suppose that happens in the optimizer? |
Yes, that's what we were thinking. I suppose this happens in I guess we could add a hash to the names of entries like it's done for symbols? |
I have the same issue. But it's happening after using |
@rafalfigura, for some reason, the vite config (qwik city template) crash when you install a dependency with more than 1 module export (in qwik sonner, I am exporting the styled version and the headless version). I tried to compile the website of qwik sonner, and the CI couldn't build. After a lot of hours of trying to solve the problem, I noticed that the only change I made was the custom entry points in vite config (library mode). So maybe there is something in the qwik plugin (qwik city template) or in the config that qwik uses by itself. I will take a look at this today. Hopefully, I can create a PR that solves this error. If I'm not, I think I am going to be forced to only export one file. @maiieul, which means the qwik sonner could not be used in qwik-ui because the headless version couldn't be exported |
@diecodev if you can't find a solution we could have a look sometime in June (this month is pretty busy for me). But it doesn't seem qwik-sonner is using |
this changes should fix the problem on build time. The problem was mention by @rafalfigura in QwikDev/qwik#5473
@diecodev what is the crash message? Qwik itself has a lot of exports... |
@wmertens it does not show a error by itself, in console you have a reference to a github docs line 31 that says something about the qrls. you can check the error qwik refer in here and this is the error in terminal:
@rafalfigura btw, there is a new version (the v1.0 release) of qwik-sonner where I solved this problem for the component. |
Hey guys, so the issue involves the function declaration names. In Qwik UI v0.4 we have gotten around this by providing an alias alongside preservemodules. For example exporting a function called A hacky workaround for now, but better than nothing. |
Which component is affected?
Qwik Optimizer (rust)
Describe the bug
Related to #5097, but creating another issue because the two will probably be solved independently.
In an attempt to solve the big bundle and tree-shaking issue in qwik-ui, which is also an issue for any other qwik library using the library starter, @shairez and @wmertens found that setting
build.rollupOptions.output.preserveModules
totrue
can work around the issue. But the problem is that this introduces a namespace issue in preview and production with "error code 31" and the error message "Cannot resolve symbol s_c7PiYJ1s0GU".So using
if the library has a component$ named
AccordionRoot
, and then I defineexport const AccordionRoot = component$(...)
in the local app, theAccordionRoot
component from the library will be overridden by theAccordionRoot
in the local app, leading to "Cannot resolve symbol s_c7PiYJ1s0GU... Error code (31)" types of errors when symbols cannot reach the qwik-ui's AccordionRoot code as it isn't there.We believe the code isn't there because it is the local project's AccordionRoot that is in the build output instead.
Reproduction
https://github.com/maiieul/qwik-libraryMode-and-preserveModules-namespace-issue-repro
Steps to reproduce
To see the error message:
npm i
(npm will make the debugging step easier)npm run preview
Go into src/components/accordion-root/index.tsx and change the const to
AccordionRoot2
and the error will go away.System Info
Additional Information
@shairez and I have been through a lot of steps to identify the bug, but we believe it's an optimizer issue and couldn't get further. It will probably be easier to go through this in a live session, but I wrote the steps here in case someone has to go over them later on.
To understand the error:
newOutput
,currentOuputs
, anddeps
currentOutputs[31]
, there is a key withentry_AccordionRoot.js
newOutput.modules[10]
, the path is "/qwik-ui-tabs-repro/src/entry_AccordionRoot.js", but atcurrentOutputs[31]
, there is already a key withentry_AccordionRoot.js
that has already been set at line 2020.entry_AccordionRoot.js
of the local project being overridden by the one from qwik-ui. I was expecting the opposite, so I guess that by the time this override happens, the local project entry file has already been outputted into the build folder and so Rollup, Vite, or the Plugin can't output it again.Either way, we believe the crux of the issue lies in the fact that the path is the same for both AccordionRoot components ("entry_AccordionRoot.js"). A global search makes it look like this is being set in
packages/qwik/src/optimizer/core/src/entry_strategy.rs
.The text was updated successfully, but these errors were encountered: