Path based Code navigation to /index.js seems broken
See original GitHub issue- VSCode Version: 1.42.1
- OS Version: Mac OS
Steps to Reproduce: Code navigation seems broken when you import by path and the file is actually in an index.js file. There are a couple of scenarios relevant to developing in react-native
- import from another package in a monorepo
import SomeComponent from 'common-lib/Router
, when the file ispackages/common-lib/src/Router/index.js
- import in the same package
import SomeComponent from 'modules/Router
, when the file issrc/modules/Router/index.js
import SomeComponent from 'modules/Router
, when the file is not actually index.jssrc/modules/Router/index.ios.js
andsrc/modules/Router/index.android.js
In general, what works is loading a file name by name (not an index.js file) What doesn’t work is loading a file by path that is actually an index.js, index.native.js, index.ios.js, index.android.js etc file
My code structure is
root
packages
mobile
server
src
server
shared
common-lib
There is some history here that is not ideal. But ok.
packages/server jsconfig.json
{
"compilerOptions": {
"target": "es2017",
"allowSyntheticDefaultImports": false,
"baseUrl": ".",
"paths": {
"common-lib/*": ["../common-lib/*"],
"mobile/*": ["../mobile/*"],
"modules/*": ["./src/shared/modules/*"],
"components/*": ["./src/shared/components/*"],
"router/*": ["./src/shared/router/*"],
"server/*": ["./src/server*"],
"App": ["./src/App"]
}
},
"exclude": ["node_modules", "../../node_modules", "build"]
}
Does this issue occur when all extensions are disabled?: Yes
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
4 Reasons Why Your Source Maps are Broken - Sentry Blog
Just like sourceMappingURL , if this value is a relative path, it is relative to the path location of the bundled JavaScript file....
Read more >24 - Stack Overflow
I was installing a react startup app and added Webpack, but it says Can't resolve './src/index.js' . Browser Shows My app gives this...
Read more >Code-Splitting - React
If you're using Create React App, Next.js, Gatsby, or a similar tool, ... The best way to introduce code-splitting into your app is...
Read more >z-index - CSS: Cascading Style Sheets - MDN Web Docs
The z-index CSS property sets the z-order of a positioned element and its descendants or flex items. Overlapping elements with a larger ...
Read more >Next.js 13: Working with the new app directory - LogRocket Blog
The UI for a particular route is defined with a page.jsx file inside of the folder. Therefore, a folder structure that looks like...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s Node.js “feature” to check
folder/index.js
iffolder
referenced, using"moduleResolution": "node"
should enable this behavior in TS.However this won’t help with e.g.
index.android.js
but I doubt that since this should be handled by tooling, maybevscode-react-native
might handle these specific cases.I think so yeah, it could recommend making a jsconfig with
target: node
?Perhaps something like?