Skip to content
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

Error during build - Rollup Error: could not resolve accordion-context-id from accordion-context-error #453

Closed
maiieul opened this issue Oct 4, 2023 · 4 comments

Comments

@maiieul
Copy link
Contributor

maiieul commented Oct 4, 2023

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" from "node_modules/@qwik-ui/headless/components/accordion/accordion-header.qwik.mjs"

Repro

Link: https://github.com/maiieul/qwik-ui-rollup-accordion-repro (not the most minimal but I doubt tailwind is the issue in here.. Might be worth trying without it if we don't find what's going on)

  1. npm install
  2. npm run preview
    (it's easier to read with npm)

You should get the error.

Try removing the Accordion component, and you'll still get the error (remember to re-run the preview), even though there are no Accordion components imported in the project anymore, but qwik-ui is still being used by the Separator component.

Re-add that Accordion component and try removing the Separator component. You'll still get the same accordion error (remember to re-run the preview).

Remove both components and the error is gone.

Potential reasons

Discussion with the Jack Shelton @thejackshelton makes us think it could be due to the two contexts on the Accordion component (defined in accordion-context-id.ts), or related to the big bundle issue Shai @shairez has just resolved.

@shairez
Copy link
Contributor

shairez commented Oct 5, 2023

OK I found one issue that is happenning with the TS types, they are being generated before the .qwik suffix is being added, so they are not aligned with the actual file names

But this needs further investigation

@maiieul
Copy link
Contributor Author

maiieul commented Oct 5, 2023

Yes I think the problem doesn't come from the Accordion component.

I simply copied the Accordion code into the qwik-ui-accordion-repro and it builds as expected. I also tried publishing an npm library with just the accordion (called qwik-ui-lib-test) and I can make it work too with the basic template (https://qwik.builder.io/docs/advanced/library/). You can try this out in the repro on the "no-qwik-ui" branch I just pushed.

So my guess is that the problem comes from the new viteconfig or tsconfig.

@wmertens
Copy link
Contributor

The reason is that the optimizer changes the import location when converting the component to a QRL. "./accordion-context-id.qwik.mjs" becomes "../node_modules/@qwik-ui/headless/components/accordion/accordion-context-id.qwik.mjs", and it looks like that's not the correct path relative to the module.

@gioboa
Copy link
Contributor

gioboa commented Nov 1, 2023

I believe this was resolved in QwikDev/qwik#5375 and can be closed.

@gioboa gioboa closed this as completed Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants