fresh
fresh copied to clipboard
kebab-case files not supported for islands
I started a project using the project creation tool and included twind for styling. I generally use kebab-case
for file names to avoid case clashing.
I have ran into an issue when running the locally (haven't tried in deno deploy) where it's using the name in the code.
But it's getting Unexpected token '-'
as you can't use a dash in a variable name/import reference.
Import of island in my code:
import DarkModeButton from "../islands/dark-mode-button.tsx";
Import in rendered code:
Error in console
Uncaught SyntaxError: Unexpected token '-' (at (index):64:12)
You can even rename the counter island that comes with the project to reproduce the issue.
I have just created a PR to fix the issue I was having above. If someone could leave some feedback, that would be great.
https://github.com/denoland/fresh/pull/404
Just don't use a kebab-case. PascalCase is a generally accepted naming convention for .tsx
/.jsx
components/islands. Doing otherwise, in my opinion, should be strongly discouraged in order to preserve the convention.
I would disagree with you there as some companies have moved away from this naming convention as it can get confusing when having one convention for components (PascalCase) vs page routes (kebab-case).
This can lead some developers to using the wrong convention for some areas of the app and when asked to change it, they can run into issues similar to the one linked below. This is why it can be just easier to go with kebab-case for all filenames.
https://twitter.com/kentcdodds/status/1361536960876085248?s=20
It's true that pascal case is an extremely pervasive convention, but it also is a source of a lot of last-minute bugs because different operating systems have different case sensitivity. It's not a good convention, but even worse, there's literally no reason to ban the one that is less error-prone.
Well, yea, I guess I agree with you. This kebab-case does seem like a good naming practice.
Anyway, I think that this issues can be closed since the PR #404 about it has been merged. @lucacasonato
Is there more work to be done (are there any file-naming bugs remaining, and if so should they be raised in this issue) or should this issue be closed @lucacasonato?
@lino-levan this can be closed as the change I made to support kebab-case islands was released as part of 1.0.2