iamolegga / prettier-loader

prettier loader for webpack
MIT License
30 stars 8 forks source link

set filepath option to help formatter resolution #137

Open MaxGrekhov opened 3 years ago

MaxGrekhov commented 3 years ago

Hello. This commit will fix several issue. https://github.com/iamolegga/prettier-loader/issues/8#issue-274492694 https://github.com/prettier/prettier-vscode/issues/955#issue-492449694

I have to use workaround at the moment:

{
  enforce: 'pre',
  test: /\.((j|t)sx?)$/,
  exclude: /node_modules/,
  use: (info) => [
    {
      loader: 'prettier-loader',
      options: { filepath: info.realResource },
    },
  ],
}
iamolegga commented 3 years ago

Hello, thanks for PR. Before merging it I have a couple of questions:

  1. Can you please provide a bit more info, I just didn't get it how is this related to prettier-vscode project?
  2. And if this fix #8 would you be able to add a little test for this feature and update the docs?
MaxGrekhov commented 3 years ago
  1. Can you please provide a bit more info, I just didn't get it how is this related to prettier-vscode project?

I have the same issue with this loader. I have a large TypeScript project and Prettier constantly break a source code because of lack a filepath. When I provide the filepath Prettier is able to understand what parser it should use and everything is fine.

  1. And if this fix #8 would you be able to add a little test for this feature and update the docs?

I'm not experienced in tests. We just entrust this job to Prettier.

iamolegga commented 3 years ago

All right, then I'll try to find time soon to add test to check if this close #8

MaxGrekhov commented 3 years ago

Hey, any updates?

iamolegga commented 3 years ago

@grehovm sorry, this is not a prioritized project for me at the moment, if you can add a test for this I'll merge and make a new release