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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[馃悶] using menu.md and having a route named menu causes an error #4504

Closed
ulic75 opened this issue Jun 15, 2023 · 4 comments 路 Fixed by #4564
Closed

[馃悶] using menu.md and having a route named menu causes an error #4504

ulic75 opened this issue Jun 15, 2023 · 4 comments 路 Fixed by #4564
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working

Comments

@ulic75
Copy link
Contributor

ulic75 commented Jun 15, 2023

Which component is affected?

Qwik Runtime

Describe the bug

If I'm using a menu.md file for creating a menu using useContext and I also have a route named menu then I receive the following error when trying to run with preview and during a build.

Identifier 'Menu' has already been declared (Note that you need plugins to import files that are not JavaScript)

Reproduction

https://stackblitz.com/edit/qwik-starter-kd1pse

Steps to reproduce

npm run preview

System Info

Stackblitz

Additional Information

No response

@ulic75 ulic75 added TYPE: bug Something isn't working STATUS-1: needs triage New issue which needs to be triaged labels Jun 15, 2023
@stackblitz
Copy link

stackblitz bot commented Jun 15, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@hbendev
Copy link
Contributor

hbendev commented Jun 21, 2023

A possible quick solution would be appending "Markdown" to the generated import statements. I'd be happy to make the changes with tests if this seems a reasonable solution.

import * as Menu from "/home/hbendev/Projects/qwik-starter-kd1pse/src/routes/menu/index";
import * as MenuMarkdown from "/home/hbendev/Projects/qwik-starter-kd1pse/src/routes/menu.md";

@ulic75
Copy link
Contributor Author

ulic75 commented Jun 21, 2023

My workaround for now was move the "routes/menu/" route into a grouped layout, "routes/(dummy}/menu/".

@hbendev
Copy link
Contributor

hbendev commented Jun 21, 2023

Well, that works, but sounds very hacky, and not developer friendly.

On the other hand, my proposed solution isn't perfect either. No matter what we append to variable name, this conflict can arise (even in nested routes):

import * as DemoFlowerMenuMarkdown from "/home/hbendev/Projects/qwik-starter-kd1pse/src/routes/demo/flower/menu/markdown.tsx";
import * as DemoFlowerMenuMarkdown from "/home/hbendev/Projects/qwik-starter-kd1pse/src/routes/demo/flower/menu.md";

We'd have to make them all unique. But for this, createFileId should be modified. My idea is to either add

  1. a required 'type' parameter, that can either be 'menu', 'route', 'plugins' etc.
  2. an optional parameter that would be pushed to the current id.

hbendev added a commit to hbendev/qwik that referenced this issue Jun 22, 2023
by appending type to the id generated from the path - except for menus and layouts, because they
already contain their type based on the file names

fix QwikDev#4504
manucorporat pushed a commit that referenced this issue Jun 22, 2023
by appending type to the id generated from the path - except for menus and layouts, because they
already contain their type based on the file names

fix #4504
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants