sveltejs / language-tools

The Svelte Language Server, and official extensions which use it
MIT License
1.22k stars 195 forks source link

"Svelte language sever detected a large amount of files" on Svelte build : allow an option to disable #2171

Open MarArMar opened 1 year ago

MarArMar commented 1 year ago

Description

If I build a sveltekit project in VSCode , I get a notification :

"Svelte language sever detected a large amount of files"

I believe this makes access difficult for the build as well as somethimes I have ssues with reading files with the build & have to re launch a build :

Error: EPERM: operation not permitted, stat '... .svelte-kit\types\src\routes\$types.d.ts'

This is a random error & I have no idea how to prevent it & just relauch the build & sometimes it works

Oten does not work the 1st time I launch it

Proposed solution

Please allow an option to disable, like a list of ignored paths

Alternatives

No response

Additional Information, eg. Screenshots

No response

jasonlyu123 commented 1 year ago

Have you tried following what the message told you?

Svelte language server detected a large amount of JS/Svelte files. To enable project-wide JavaScript/TypeScript language features for Svelte files, exclude large folders in the tsconfig.json or jsconfig.json with source files that you do not work on.

If so, please mention that you tried and what is the content of your tsconfig.

MarArMar commented 1 year ago

Never saw the full message bc it was in a small Notification

Ok I added this into the tsconfig

"exclude": [ "../node_modules/", "/node_modules/", "./[!ambient.d.ts]", "/.svelte-kit/", "../.svelte-kit/**", "../src/service-worker.js", "../src/service-worker.ts", "../src/service-worker.d.ts",

"../dist/**",
"../build/**",
"../.svelte-kit/**",
"../.svelte/**",
"../.vercel_build_output/**",
"../.vercel/**",
"../coverage/**",
"**/_/**"

]

Will update if problem appears again

jasonlyu123 commented 1 year ago

The exclude doesn't look right. The relative pattern should be relative to the tsconfig.json. So most of them should be ./ instead of ../. Do you override the include as well? You also excluded the generated types. You might need to reference what SvelteKit generated and change it accordingly.

MarArMar commented 1 year ago

Ok I did not see the problem anyymore with the new ts confign

Clisong the issue

MarArMar commented 1 year ago

Ok reopend issue as it happened again

This is the contents of the tsconfig.json

{
  "extends": "./.svelte-kit/tsconfig.json",
  "compilerOptions": {
    "allowJs": true,
    "checkJs": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": true,
    "paths": {
      "$src/*": ["./src/*"],
      "$lib": ["./src/lib"],
      "$lib/*": ["./src/lib/*"],
      "$components": ["./src/lib/components/*"],
      "$components/*": ["./src/lib/components/*"]
    }
  },
  // To maybe avoid https://github.com/sveltejs/language-tools/issues/2171
  // "Svelte language sever detected a large amount of files" on Svelte build
  "exclude": [
    "./node_modules/**",
    "./.svelte-kit/**",
    "./dist/**",
    "./build/**",
    "./.svelte/**",
    "./.vercel_build_output/**",
    "./.vercel/**",
    "./coverage/**",
    "**/_/**"
  ]
}
MarArMar commented 1 year ago

Now trying with this in root tsconfig.json as I am using a monorepo

  "exclude": [
    "**/node_modules/**",
    "**/.svelte-kit/**",
    "**/dist/**",
    "**/build/**",
    "**/.svelte/**",
    "**/.vercel_build_output/**",
    "**/.vercel/**",
    "**/coverage/**",
    "**/_/**"
  ]

Maybe the extension is using the root tsconfig.json & not the project tsconfig.json

jasonlyu123 commented 1 year ago

Please provide a reproduction repository. There isn't enough information for me to tell what the problem is. Also, take a look at the documentation on "include" and "exclude" for the tsconfig. https://www.typescriptlang.org/tsconfig#include. It might help you debug what the problem is.

diegoulloao commented 4 months ago

Adding this to my tsconfig.json did the fix:

{
  "compilerOptions": {},
  "include": ["src/**/*", "tests/**/*"]
}

Also working for Astro + Svelte projects.