Using browserslist-stats.json with pnpm and vscode-stylelint
I'm creating a package that we're planning to use across multiple repositories with a stylelint configuration. A part of it is testing for the browser features support using browserslist with GA data extracted to a JSON file. Some of our projects use yarn and there is one using pnpm where this become a bit weird.
We store our browserslist config in a separate package (package-name) and we use the following line. browserslist-stats.json is located in the same package and in the same folder but we still have to refer to it through a package name.
"last 3 versions and not dead and > 0.5% in package-name stats"When we run stylelint as an npm script – it all works flawlessly, but whenever I'm saving the files in vscode and stylelint plugin is trying to do the same it fails trying to import the stats file. (MODULE_NOT_FOUND)
Trying to log the path in the node.js loadStat function gives me the correct import path but I've noticed that this error happens only when require.resolve there is using { paths: ['.'] } option. Looking through the project history, I've noticed that it's been added there since the moment this feature was implemented so I'm not sure if there was any specific reason behind it:
https://github.com/browserslist/browserslist/commit/b6438bcb61cf6954ef51dc473421654da457df4c
Source: browserslist/browserslist