-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
Svelte Monorepo auto import broken in svelte files. #2705
Comments
Did you open both projects in separate vscode windows? We currently only watch files matching the include pattern in your tsconfig.json and the directory where you open the editor. If I open one editor, I see the same behaviour in ts/svelte files. If you have imported the file at least once, the update will be reflected. If you haven't imported the file, both ts/svelte don't suggest auto-import from the file. |
No, I had it open either at broken_svelte-no-import or working_ts-monorepo |
I am unsure I understand the problem since I saw the same behaviour in broken_svelte-no-import and working_ts-monorepo. Can you explain in more detail what exactly the difference is? I did see the comment in the files, but a lot of them don't work in the ts file or even working_ts-monorepo either, so I don't know what exactly the difference is. |
Ah. I know why I can't reproduce the difference. I disabled the typescript.preferences.includePackageJsonAutoImports config probably to test out its behaviour when investigating another issue. The problem has something to do with this package.json auto import. We were using a port of TypeScript's package.json auto import, but TypeScript added a new feature to collect auto-import from the package.json wildcard entry. The port doesn't have this feature yet. Were you also having problems with existing files in the package not being updated? I am not sure what this comment meant.
|
Yeah basically lets say I apply that in package export. I have an issue that when I want to import the file it sometimes is not hot reloaded by ts server, it's flaky. But if you generally know of any other way on how to do the following I would be grateful: |
Would you like me to record a video of what's happening vs expected? |
Yeah. Please. There seem to be two problems here, but I don't understand what the second one is. I only understand the problem with the never-imported module, but it shouldn't work even if you restart the editor. Also, does go-to-definition on the import for the shared libary take you to the source file? Or a file path with node_modules in it? |
@jasonlyu123 sorry for the delay, was sick in bed. Working ts example: Kooha-2025-03-13-11-26-33.webmBroken svelte example: Kooha-2025-03-13-11-28-30.webmMy end goal is that I can create a file in repo 1 and just import it in repo 2 without having to build anything / restart vscode (with import support) |
Ah, and regarding definitions, it appears as if it refferences it directly (the file) Kooha-2025-03-13-11-32-35.webmAnother thing is, that I would like to have the option to not only import ts files, but svelte files as well. (basically that the ts-exports repo has svelte components I can import in my svelte vite / svelte kit app |
I understand this part. What I want to know is this
|
Oh, basically when I tried in a different repo a version with build and a single file as exports, it basically only scanned what the file exports on vscode load, and then let's say I rename a function, cahnge the output from number to boolean and rebuild the package, vscode intellense still would see the old package instead of the new one. |
@jasonlyu123 Do you happen to know of a different way on archieving what I want? |
One workaround is to add the share package to the include of the tsconfig.app.json of your svelte app and add an alias to the {
"compilerOptions": {
..
"paths": {
"ts-export/*": ["../ts-export/*"]
}
}
"include": [
...
"../ts-export/src/**/*.ts"
]
} |
@jasonlyu123 Sadly that does not with svelte components cross repos. Example. copy the svelte vite folder, call it something like 2 and try ts files. They Work. App.svelte also seems to work. But I added as a Test a "Gaga.svelte" with a div element as content. And I fialed to import that in svelte-vite even after the ts config + adding it to package.json |
It only shows up in "svelte-vite" if I import my new Gaga.svelte into App.svelte in "svelte-vite-2" |
The include config I listed is just an example. If you want Svelte and js files, you can add the corresponding pattern to the include config. Have you added svelte files to the include config? I tried, and it works with new files. |
Oh, yeah that worked. Thank you <3 |
Describe the bug
Basically svelte only import ts and svelte functions once on vscode load and you have to reload vscode to get new imports or changed imports (e.g. you modify types of a function and you need to reload so it's reflected)
This neither works with build or no build.
No build has an additional issue that you can auto import in ts files, not in svelte files. and that if you import it once in a ts file then you can import it via relative path.
Reproduction
Made a custom repo
https://github.com/Autumnlight02/monorepo-issues
Expected behaviour
It just imports them simila rto how ts works
System Info
vscodium: 1.97.2
Extensions: prettier, pretty typescript errors, svetle for vscode, grammarly, indent-rainbow, vue - official, symbols (/ icon themes), mdx support
Which package is the issue about?
No response
Additional Information, eg. Screenshots
Either Svelte for vscode or general language server issues
The text was updated successfully, but these errors were encountered: