Closed birkskyum closed 2 months ago
Do you have ~/
in an your deno.json
import map? Can you share your config?
I don't have a deno.json, just a package.json
Are you executing it with Deno?
Yes, with deno 2 rc.3
I guess just add a deno.json
like:
{
"imports": {
"~/": "./"
}
}
Let me know if it works.
It changes the error to a no-local module loading issue. This is just a .tsx file with exports, not some package. The code still executes fine though, with / without the .tsx extension.
Is that file URL in the error message the correct path? If not, you have to adjust the import map value accordingly, where it says "./"
.
Made a repro in here that gave some pointers to what's going on: https://github.com/birkskyum/squiggly
It's appear to be because the tsconfig.json compilerOptions.path isn't applied properly:
{
"compilerOptions": {
"paths": {
"~/*": [
"./src/*"
]
}
}
}
We don't read tsconfig.json
, change the deno.json
to:
{
"imports": {
"~/": "./src/"
}
}
That works, thanks.
Okay, I didn't realize the tsconfig.json was completely ignored - that seems like an important thing to be aware of when working with deno.
I guess that's also a pointer to how this JSX issue appear - because I have config it in tsconfig that probably will have to be moved to deno.json.
@nayeemrmn , it's really not clear anywhere that tsconfig.json isn't read by deno, so if it's the case I think it's important to educate more on. See i.e. this article: https://deno.com/blog/intro-to-tsconfig#from-js-to-ts
deno 2.0.0-rc.3
This code executes just fine, but I get this language server squiggly line that I don't know if intentional deno opinion or accidental oversight.
The ~ for relative path, can in some cases be a rather convenient alternative to the ../../../../../ .
Copied text:
Relative import path "~/components/ui/dialog" not prefixed with / or ./ or ../ hint: If you want to use a JSR or npm package, try running
deno add jsr:~/components/ui/dialog
ordeno add npm:~/components/ui/dialog
deno(import-prefix-missing)