prettier-plugin-svelte icon indicating copy to clipboard operation
prettier-plugin-svelte copied to clipboard

not working with pnp - plug n play - yarn 3.2.1

Open akkumar opened this issue 3 years ago • 2 comments

Steps to reproduce:

Create a new project with the following versions in devDependencies

  "devDependencies": {

    "prettier": "^2.7.1",
    "prettier-plugin-svelte": "^2.7.0",

}

yarn version

$ yarn --version
3.2.1

prettier format:

  "scripts": {
    "format": "prettier --write --plugin-search-dir=. .",
}

When we run format

$  yarn format
__tests__/ContextTest.test.ts 312ms
.eslintrc.cjs 40ms
jest.config.cjs 6ms
LICENSE.md 34ms
package.json 4ms
README.md 29ms
src/lib/index.js 4ms
svelte.config.js 5ms
tsconfig.json 2ms
  • the svelte files are not listed in the set of files being formatted as shown by the output above.

One of the important distinction being PnP modules I guess.

I dont know if that is related because node_modules is not generated by yarn (but only a couple of files are generated as below. )

        .pnp.cjs
        .pnp.loader.mjs

There is some reading here at yarnpkg - https://yarnpkg.com/features/pnp .

Not sure if the plugin depends on it by any chance.

akkumar avatar Jun 18 '22 17:06 akkumar

To add further - adding the following line to .yarnrc.yml indeed works.

nodeLinker: node-modules

This seems to be a specific issue with modern yarn ( not classic ) .

$ yarn --version
3.2.1

Having said that - without nodeLinker: node_modules this plugin does not seem to discover or act on svelte files. With pnp - plug n play that is.

Keeping this bug open still as someone with a better idea of internals of PnP / this plugin can comment on it better.

Meanwhile - if you are an user looking for a fix - you can modify .yarnrc.yml as above to move ahead.

akkumar avatar Jun 18 '22 17:06 akkumar