next.js
next.js copied to clipboard
Cannot use import alias if route path starts with period
Link to the code that reproduces this issue
https://github.com/jdhenry08/next-route-broken-imports
To Reproduce
- View src/app/.well-known/route.ts
- Change "../../constants" import to "~/constants" or "src/constants"
Current vs. Expected behavior
Importing the constants file from either of those two paths should work, since they're aliased in tsconfig.json, but the red squiggly remains :(
Provide environment information
Node: 20.9.0
npm: 9.8.1
Yarn: 1.22.19
pnpm: 8.10.2
Relevant Packages:
next: 14.2.5 // Latest available version is detected (14.2.5).
eslint-config-next: N/A
react: 18.3.1
react-dom: 18.3.1
typescript: N/A
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
Other (Deployed)
Additional context
No response
This is due to tsconfig ignoring hidden files (anything that starts with a dot).
You can get around this by adding the folder to the include path in tsconfig.json:
"include": [
"src/app/.well-known/**/*"
]
Ah, yup - that did the trick!
Might I suggest that the documentation for setting up the Vercel toolbar/feature flags be updated to mention something along these lines, given that it uses a similar route? Not sure what the right repo is to make that suggestion.