New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential Breaking Change in resolveConfig
#7949
Comments
@lipis Opened an issue in prettier repo to track. |
@ntotten Can you try run I didn't see this package on npm , please check if your |
Anyway we should change this line prettier/src/config/resolve-config.js Line 27 in 4ac088c
|
Hi folks, I'm the one who originally posted the downstream issue on VSCode Prettier. That config is not on npm because I didn't feel like publishing and maintaining a package just for a small lint config file. You can install it right from the git repo: https://github.com/greenelab/prettier-config-greenelab And that's an actual config I've been using, didn't create it just for the bug. Maybe the bug is even specifically related to packages installed from github repos? I can't say. |
It looks like the issue is that In
However, this does work:
I think as long as prettier returns a better error message and the breaking change is noted, this is probably okay - assuming it was deliberate. |
@ntotten I just tried that, and it worked, even in VSCode Prettier v Here is the relevant docs section that needs to be updated: |
No we didn't, I'll check it later. |
@fisker Looks like |
Ah, this is probably because the extension is webpacked. The extension handles this in our module loader: https://github.com/prettier/prettier-vscode/blob/master/src/ModuleResolver.ts#L263-L265 |
but
this work ? This also use |
@ntotten where did you put this |
@fisker Are you sure? I thought |
@thorn0 I'm sure, if it's in |
I think the reason that it seems to work when it is set to
Then the extension passes this config back to prettier and then prettier resolves the full config. However, in the case we pass just
I am not sure why the module resolution seems to work in one case but not the other though. |
Alright, I thought you put that in |
Seems cosmiconfig doesn't handle webpack: cosmiconfig/cosmiconfig#222 |
@ntotten It doesn't look like your loader overrides |
It's not about |
I guess everyone has their own |
The require is from But it doesn't look like it supports the options parameter. |
No, there is only one argument, should be two. |
@ntotten I there a way to have the original |
@thorn0 I am not entirely sure to be honest. The other thing I am a bit confused about is why this also happens when I am running the extension in debug mode - which doesn't get webpacked and should have the original |
Actually, i think we are on the wrong track. We should always be using the regular require.
That will return the default global But require.resolve.length === 1 so maybe this is actually something with vscode or electron. |
@ntotten Is there a way you can replace |
@fisker I could, but I would need some way to pass my resolver to prettier. |
It seems to be a known issue in VS Code. It is due to webpack's restriction on |
I have a fix: |
@ntotten Should we fix this on Prettier's side or in the extension (by passing a |
@thorn0 It's up to you, given that I already have to deal with this in several places in the extension, I'm fine passing in an instance of require, but it also might be cleaner just to do it in |
Okay, I'm about to submit a PR. |
It seems that 2.0 may have introduced an unintended breaking change in the
resolveConfig
function. This function is used in the Prettier VS Code extension here: https://github.com/prettier/prettier-vscode/blob/master/src/ConfigResolver.ts#L99Since upgrading to 2.0 we are now seeing errors when trying to resolve configs:
For repro steps and more details see: prettier/prettier-vscode#1289
One thing to note, is that everything behaves as expected from the CLI which is odd.
The text was updated successfully, but these errors were encountered: