Skip to content
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

File watching outside of the directory of tsconfig #2233

Closed
datstarkey opened this issue Dec 19, 2023 · 0 comments
Closed

File watching outside of the directory of tsconfig #2233

datstarkey opened this issue Dec 19, 2023 · 0 comments
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.

Comments

@datstarkey
Copy link

datstarkey commented Dec 19, 2023

Describe the bug

When working in a monorepo, you can use path alias and includes from the tsconfig to import svelte files from shared libraries.

This works fine until you add a new file inside a shared package, it just does not appear in the intellisense until you restart the svelte language server.

example svelte.config.js and tsconfig.json

import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';

/** @type {import('@sveltejs/kit').Config} */
const config = {
    // Consult https://kit.svelte.dev/docs/integrations#preprocessors
    // for more information about preprocessors
    preprocess: vitePreprocess(),

    kit: {
        // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
        // If your environment is not supported or you settled on a specific environment, switch out the adapter.
        // See https://kit.svelte.dev/docs/adapters for more information about adapters.
        adapter: adapter(),

        alias: {
            "$ui": "../ui/src/lib",
            "$ui/*": "../ui/src/lib/*",
        }
    }
};

export default config;

And inside the tsconfig.json it has the ui src/lib folder in includes

{
  "extends": "./.svelte-kit/tsconfig.json",
  "compilerOptions": {
    "allowJs": true,
    "checkJs": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": true,
    "moduleResolution": "bundler"
  },
  "include": [
    "./.svelte-kit/ambient.d.ts",
    "./.svelte-kit/non-ambient.d.ts",
    "./.svelte-kit/types/**/$types.d.ts",
    "./vite.config.js",
    "./vite.config.ts",
    "./src/**/*.js",
    "./src/**/*.ts",
    "./src/**/*.svelte",
    "../ui/src/**/*.js",
    "../ui/src/**/*.ts",
    "../ui/src/**/*.svelte"
  ]
}

Reproduction

https://github.com/datstarkey/svelte-monorepo-import-issue

Reproduction instructions given in readme of repo.

Expected behaviour

Any files added should appear in the auto-complete list.

I should note this does work in typescript files just fine, its only .svelte files that it doesn't work.

System Info

  • OS: Windows
  • IDE: VS Code
  • Svelte: 4
  • SvelteKit: 2

Which package is the issue about?

No response

Additional Information, eg. Screenshots

A workaround can be to package the files, but this can cause issues when working with working with tailwind in a monorepo, and slows down the developer experience.

You can also add the files to the index.ts and export, but that can be annoying during development. Vite prefers to not have barrel files aswell - https://vitejs.dev/guide/performance#avoid-barrel-files

@datstarkey datstarkey added the bug Something isn't working label Dec 19, 2023
@jasonlyu123 jasonlyu123 changed the title [VS-Code] Auto-Import outside of rootDir File watching outside of the directory of tsconfig Dec 20, 2023
dummdidumm pushed a commit that referenced this issue Jun 24, 2024
#2233 #2393

update project files(tsconfig.include) when a new client file is opened. So files included in both tsocnfig.json will be loaded into the respecting language service.
@dummdidumm dummdidumm added the Fixed Fixed in master branch. Pending production release. label Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Fixed Fixed in master branch. Pending production release.
Projects
None yet
Development

No branches or pull requests

2 participants