From 0b74c124bf8deb1a8da8ce07e348f261081189bb Mon Sep 17 00:00:00 2001 From: Monroe Ekilah Date: Mon, 23 Oct 2023 21:58:55 -0700 Subject: [PATCH 1/3] add support for disabling the plugin via TS_PLUGIN_CSS_MODULES_DISALBED --- README.md | 4 ++++ src/index.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 59d0190..6714c8b 100644 --- a/README.md +++ b/README.md @@ -282,6 +282,10 @@ If you're not using Visual Studio Code or are having trouble with the above meth You can include these logs with any issues you open for this project. +### Disabling the plugin + +If your project uses the plugin but you are experiencing issues with it, you can disable it for yourself by defining the environment variable `TS_PLUGIN_CSS_MODULES_DISALBED`. + ## About this project This project was inspired by a Create React App [issue](https://github.com/facebook/create-react-app/issues/5677) diff --git a/src/index.ts b/src/index.ts index fd9f3e1..ec53ef1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,6 +26,10 @@ const init: tsModule.server.PluginModuleFactory = ({ typescript: ts }) => { function create( info: tsModule.server.PluginCreateInfo, ): tsModule.LanguageService { + if (process.env.TS_PLUGIN_CSS_MODULES_DISALBED !== undefined) { + return info.languageService; + } + const logger = createLogger(info); const directory = info.project.getCurrentDirectory(); const compilerOptions = info.project.getCompilerOptions(); From 232ed21249eaabc04139f86ba30a28884ef4688c Mon Sep 17 00:00:00 2001 From: Brody McKee Date: Sun, 11 Feb 2024 18:56:54 +1100 Subject: [PATCH 2/3] fix spelling and move bail out up --- README.md | 2 +- src/index.ts | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6714c8b..39e30e2 100644 --- a/README.md +++ b/README.md @@ -284,7 +284,7 @@ You can include these logs with any issues you open for this project. ### Disabling the plugin -If your project uses the plugin but you are experiencing issues with it, you can disable it for yourself by defining the environment variable `TS_PLUGIN_CSS_MODULES_DISALBED`. +If your project uses this plugin, but you need to disable it in a specific scenario, providing the `DISABLE_TS_PLUGIN_CSS_MODULES` environment variable will cause the plugin to return before it initializes - effectively disabling it. ## About this project diff --git a/src/index.ts b/src/index.ts index ec53ef1..403b863 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,15 +21,17 @@ const getPostCssConfigPlugins = (directory: string) => { }; const init: tsModule.server.PluginModuleFactory = ({ typescript: ts }) => { + if (process.env.DISABLE_TS_PLUGIN_CSS_MODULES !== undefined) { + return { + create: (info: tsModule.server.PluginCreateInfo) => info.languageService, + }; + } + let _isCSS: isCSSFn; function create( info: tsModule.server.PluginCreateInfo, ): tsModule.LanguageService { - if (process.env.TS_PLUGIN_CSS_MODULES_DISALBED !== undefined) { - return info.languageService; - } - const logger = createLogger(info); const directory = info.project.getCurrentDirectory(); const compilerOptions = info.project.getCompilerOptions(); From ecda3ad40ec83fe346682e4e6425dfd86b6de092 Mon Sep 17 00:00:00 2001 From: Brody McKee Date: Sun, 11 Feb 2024 19:00:09 +1100 Subject: [PATCH 3/3] Update docs --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 39e30e2..5e71fd8 100644 --- a/README.md +++ b/README.md @@ -284,7 +284,9 @@ You can include these logs with any issues you open for this project. ### Disabling the plugin -If your project uses this plugin, but you need to disable it in a specific scenario, providing the `DISABLE_TS_PLUGIN_CSS_MODULES` environment variable will cause the plugin to return before it initializes - effectively disabling it. +If you need to temporarily disable this plugin, or disable it for a single user, you can do that by setting the `DISABLE_TS_PLUGIN_CSS_MODULES` environment variable to any value, and then restarting your IDE. + +Note that this doesn't actually disable the plugin, but causes it to bail out early. See PR #244 for more information. ## About this project