diff --git a/.changeset/gentle-friends-occur.md b/.changeset/gentle-friends-occur.md new file mode 100644 index 00000000..83a55fd8 --- /dev/null +++ b/.changeset/gentle-friends-occur.md @@ -0,0 +1,5 @@ +--- +'@css-modules-kit/ts-plugin': minor +--- + +feat: disable ts-plugin if `cmkConfig.enabled` is `false` diff --git a/packages/ts-plugin/src/index.cts b/packages/ts-plugin/src/index.cts index e81fe467..8daf802a 100644 --- a/packages/ts-plugin/src/index.cts +++ b/packages/ts-plugin/src/index.cts @@ -40,6 +40,10 @@ const plugin = createLanguageServicePlugin((ts, info) => { } } + if (config.enabled === false) { + return { languagePlugins: [] }; + } + // tsserver should report a “Cannot find module” error for import statements in CSS Modules that // do not exist. However, if `dtsOutDir` is included in `rootDirs` and old .d.ts files remain // in `dtsOutDir`, the error will not be reported. Therefore, remove `dtsOutDir` from `rootDirs`.