language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

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

Open MarArMar opened this issue 2 years ago • 8 comments

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

MarArMar avatar Sep 28 '23 10:09 MarArMar

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.

jasonlyu123 avatar Sep 28 '23 11:09 jasonlyu123

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

MarArMar avatar Sep 28 '23 12:09 MarArMar

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.

jasonlyu123 avatar Sep 28 '23 12:09 jasonlyu123

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

Clisong the issue

MarArMar avatar Sep 29 '23 12:09 MarArMar

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 avatar Sep 30 '23 06:09 MarArMar

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

MarArMar avatar Sep 30 '23 07:09 MarArMar

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.

jasonlyu123 avatar Sep 30 '23 08:09 jasonlyu123

Adding this to my tsconfig.json did the fix:

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

Also working for Astro + Svelte projects.

diegoulloao avatar May 29 '24 19:05 diegoulloao