Is there a way to watch file system events inside node_modules folder for vscode-languageclient? - visual-studio-code

Inside the extensions activate(context:ExtensionContext) function, I want to add a FileSystemWatcher. While this works for e.g
const clientOptions: LanguageClientOptions = {
documentSelector: [{scheme: 'file', language: 'plainText'}],
synchronize: {
fileEvents: vscode.workspace.createFileSystemWatcher('**/someFolder/*.txt')
}
}
If I now want to watch a file inside the node_modules folder, nothing happens.. any idea?

There's a "files.watcherExclude" setting with the following defaults:
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/*/**": true,
"**/.hg/store/**": true
}
Configure glob patterns of file paths to exclude from file watching. Patterns must match on absolute paths (i.e. prefix with ** or the full path to match properly). Changing this setting requires a restart. When you experience Code consuming lots of CPU time on startup, you can exclude large folders to reduce the initial load.
Performance-wise it's probably not advisable to remove node_modules from here either, since it can contain a lot of files. In any case, since it's a user setting, you're not in control of this as an extension author.

Related

vscode emphasises in red my project due to something inside `.terraform` folder despite explicitly telling it to ignore it

I have tried to configure every possible thing I can find in vscode to make sure that the .terraform folder gets ignored, but nothing seems to have done the trick.
Current configs:
"search.exclude": {
"**/.terraform/**": true
},
"files.watcherExclude": {
"**/.terraform/**": true
},
"files.exclude": {
"**/.terraform": true
},
The folder is indeed excluded from search and the explorer on the left, but the parent folder remains emphasised in red.
Any ideas how to get around this?

Code splitting with Rollup and Svelte changes all chunk names with new hashes even with no modifications

I'm using Svelte and Rollup with code splitting, and here are some parts of my rollup.config.js:
input: {
'boot': 'src/boot.js',
'app': 'src/app.js',
'agency': 'src/modules/agency.js',
'buyer': 'src/modules/buyer.js',
'buyer-group': 'src/modules/buyer-group.js',
'investor': 'src/modules/investor.js',
'management-unit': 'src/modules/management-unit.js',
'platform': 'src/modules/platform.js',
'supplier': 'src/modules/supplier.js',
'tables': 'src/modules/tables.js',
'pt-BR': 'src/core/locale/pt-BR.js',
'en': 'src/core/locale/en.js',
'external-svelte-package': 'node_modules/external-svelte-package/src/index.js'
},
output: {
sourcemap: false,
format: 'esm',
dir: `${baseDir}/js`,
entryFileNames: '[name]-[hash].js',
chunkFileNames: '[name].[hash].js'
},
Rollup generates chunks with names containing hashes (e.g. investor-fa42bee8.js).
If I run build script again, with no modifications in any file of the project, all the chunks are generated with new hashes, and this behavior harms client long term cache.
How can I change this behavior and grants same hash for all chunks that are not modified?
Any help will be wlcome.
Thanks in advance.
If the hashes change, something in your sources changes. Likely a plugin or a banner that contains a timestamp or something like that.

VSCode Code Spell Checker extension - Include TXT files

I'm using the VSCode Code Spell Checker, and I wish to detect typos in TXT files. But the issue is, that I want to detect it on TXT files that are being ignored for search by the VSCode.
Here is my settings.js file:
{
"cSpell.words": [
"BING",
"DOGPILE"
],
"search.exclude": {
"**/.vscode": true,
"**/dist": true,
"**/misc": true,
"**/misc/documents": true,
"**/misc/": true,
"/misc/": true,
"misc/**": true,
"**/misc/**": true,
"**/misc/documents/**": true,
"**/node_modules": true,
"**/sources": true
},
"eslint.validate": [
"javascript"
],
"http.proxy": "",
"http.proxyAuthorization": null,
"http.proxyStrictSSL": false,
"editor.renderWhitespace": "none"
}
The file that I want to detect typo located inside the misc directory, that is declared in the "search.exclude" list (I don't want search results from any files in this directory), but I DO WANT to detect typos on theses files.
If I remove all of theses and the settings.js looks like that:
{
"cSpell.words": [
"BING",
"DOGPILE"
],
"search.exclude": { },
"eslint.validate": [
"javascript"
],
"http.proxy": "",
"http.proxyAuthorization": null,
"http.proxyStrictSSL": false,
"editor.renderWhitespace": "none"
}
The TXT file typo detection works, but I get the search results that include files inside the misc directory, which is NOT what I want.
Has anyone faced this issue before and know how to solve it?
Thanks.
as it is explicitly stated in Spell Checker FAQ
What files are excluded by the spell checker?
By default the spell checker excludes the same files excluded by the VS Code search.exclude setting. See discussion: #16, #55 and #95
the correct way to address the problem exposed in the question I would say is to open an issue to the project for a new feature request to allow to override this default behavoir.
as a last resort if you absolutely need to prevent search.exclude from being added to the exclusions you could try to force the code installed on your machine and after restarting vscode you will have the spell check working also in those paths.
DISCLAIMER please note what is illustrated below is a discouraged hack mentioned in here for informational purposes only, obviously if you try this kind of workaround you must be extremely aware of what you are doing
for example:
assuming the extension was installed in ~/.vscode/extensions/streetsidesoftware.code-spell-checker-1.10.2
in the source server/config/documentSettings.js there is the function async fetchSettingsFromVSCode(uri) where it is added :
ignorePaths: ignorePaths.concat(CSpell.ExclusionHelper.extractGlobsFromExcludeFilesGlobMap(exclude)),
by changing in to
ignorePaths: ignorePaths
then quit fron vscode and when re-open it the extension no longer excludes the same files excluded by the VS Code search.exclude setting.

How to dictate a global variable in specific karma test block

I'm trying to write a test in Karma for a react/webpack application that tests conditionals depending on global variable __CLIENT__ being false or not.
How do I go about making it true for one it block, and then false for another? I tried setting global.__CLIENT__, but the console.logs from my module return true regardless of what I try to set it to in my tests.
How do I do this, hopefully in a way that keeps just one file and can be dictated in each test case. That avoids the karma.conf....
Probably won't help you now but maybe for others:
you need to create global.js file for example and within karma webpack files add it at the start of "files"
files: [
'./tests/global-variables.js',
{pattern: 'src/**/*-spec.js', watch: false}
],
And within global-variables.js:
var global = {
___CLIENT___: "some data"
}
Good luck!

Setting the --in-source-map uglify2 config option in r.js build config file

I wanted to use the --in-source-map option that is available in UglifyJS2 for consuming a source map file and outputting a new one along with the compressed js, thereby performing a multi-level source mapping. I am using r.js to do the minification of the javascript files and so I saw there was a way to define config values that will be passed on to the UglifyJS2. Here is a sample showing how it is done in the r.js build file:
uglify2: {
//Example of a specialized config. If you are fine
//with the default options, no need to specify
//any of these properties.
output: {
beautify: true
},
compress: {
sequences: false,
global_defs: {
DEBUG: false
}
},
warnings: true,
mangle: false
},
Obvously r.js has its own way of structuring the config options and I was not able to figure out how to set the --in-source-map option following this structure. I tried putting the following statement in the output element or the compress element or even outside, next to the warnings config option.
in-source-map: sample.map
I have also tried putting quotes around the file name. Unfortunately none of the methods worked. Can anyone help me figure out this problem? Can it also be the case that this option is not supported in r.js?