-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Missing subfolder & files path completions with wildcard exports
#48652
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Related: #47952 |
Hi @andrewbranch just saw that #47952 has been merged into main, I gave a try to On the same topic, is it necessary to change the project config ( If that's helpful I have a public repo where a dependency maintained by my team is using |
At first I thought maybe this is intentional, sure it is not conforming the behaviour of Node being able to import from the file, But following the Twitter thread, ending up here, I'm also kind of relieved it's considered a bug, as it makes developing in a mono repo rather tedious (can't just add a file and be done with it, must add it to exports too). Pre Node16 moduleResolution, we would use "paths": {
"@abc/client/*": [
"./_src/*"
],
"@abc/types/*": [
"../types/_src/*"
],
"@abc/prelude/*": [
"../prelude/_src/*"
],
"@abc/prelude": [
"../prelude/_src"
]
} but with Node16 resolution this will cause auto imports to add Until you replace package.json "exports": {
"./*": {
"import": {
"types": "./dist/*.d.ts",
"default": "./dist/*.js"
},
"require": {
"types": "./dist/*.d.ts",
"default": "./_cjs/*.cjs"
}
}
} again with explicit exports. Also, while using wildcard exports and those tsconfig.json paths entries with Node16 resolution, exposes another problem I run into which is:
Which again seems to get fixed once you drop the wildcard exports and use explicit ones instead. |
@andrewbranch is fixing this similar to the work done in #47952 (for the wildcard part)? I am aware that the code paths are different but just wondering how hard this would be to fix and if you have some pointers where the code handling the autocompletion for the language server lives in. My team at Salesforce is maintaining a package with ~400 entries without main entry points and this issue gets in the way of discoverability for our customers that consume the package. No pressure intended just wondering how hard it would be to fix this and if I could be of any help |
This is on my list to investigate for 4.8. I believe the fix should be pretty similar to #47952, but I suspect that subtle differences in the resolution algorithm could prevent much of the code from being shared. Also be aware that even after this ships, nobody will benefit from it who isn’t using |
Thx a lot @andrewbranch! I believe that there's no plan of switching the |
Correct. |
edit: see @andrewbranch comments below For anyone stumbling into this (correct me if I am wrong), a temporary workaround is to let your consumers know they should explicitly tell the language server how to resolve those imports by configuring There's an example for a JS repository there: https://github.com/salesforce/utam-js-recipes/blob/main/jsconfig.json#L5-L10. This boils down to: "compilerOptions": {
"baseUrl": ".",
"paths": {
"salesforce-pageobjects/*": ["node_modules/salesforce-pageobjects/dist/*"]
}
} Note: that |
What runtime and/or bundler are your users expected to be running? I don’t think using |
Runtime is node.js (v14 & v16), this repo just demonstrates how to consume and use the package we published ( Without configuring I am following this as some customers installed our package as a If that's easier to explain I am also in SF and my DM is open on Twitter (@anchnk) |
If your users are on Node 14/16, they should try to use I could also maybe recommend that you add |
Thanks a lot, @andrewbranch, and you are right, sorry my comment was confusing: it's indeed meant as a temporary workaround until this issue is closed. We advised our customers to switch to |
Bug Report
Sub folders and files of a folder listed in
exports
do not resolve in VS Code's autocomplete.Also, the modules aren't displayed with a subfolder icon. The files should be displayed with a file icon, but they're not displayed at all.
For this example, I'm using a library named
sandstone
and atests
folder. I'm trying to importsandstone
submodules fromtests
.Expected paths & icons:

Actual paths & icons:

When reaching a submodule (submodules have several .ts files), it gets even weirder. Expected paths:

Actual paths:

You can see the submodule appears as a submodule of itself.
Despite autocompletion not working, the code runs fine. However, auto imports don't work either. Live demo (ignore the Copilot suggestions):
imports_work.mp4
🔎 Search Terms
typescript, exports, field, package.json, exports map, autocompletion, paths, import, auto import, icons, 4.7 beta
🕗 Version & Regression Information
💻 Code
Sandstone's
package.json
:Tests'
tsconfig.json
:🙁 Actual behavior
Only the hardcoded submodules appear in the autocompletion. The submodule appears as a submodule of itself.
🙂 Expected behavior
Since there is a wildcard export, all submodules of submodules & all files should appear in the autocompletion. The submodule shouldn't appear as a submodule of itself.
The text was updated successfully, but these errors were encountered: