Automatically load plugins from package.json#3624
Conversation
|
Unexpected error: |
|
I can reproduce the error locally but only with |
| find-up "^2.0.0" | ||
| read-pkg "^2.0.0" | ||
|
|
||
| read-pkg-up@^3.0.0: |
There was a problem hiding this comment.
Upgraded yarn - problem went away. Hopefully the last time 😭
| } | ||
|
|
||
| const plugins = loadPlugins(); | ||
| const plugins = loadPlugins(opts); |
There was a problem hiding this comment.
This opts is not the same options (i.e. the context) we're passing around in other places. This is type {showUnreleased: boolean}.
This must have gotten mixed up when I fixed merge conflicts of the PR
There was a problem hiding this comment.
Kind of - in https://github.com/prettier/prettier/pull/3536/files#diff-7ac67a485f01c26ab36e763ce88748a5 I switched it to use options but it wasn't required. Added plugins to the options that can be passed here.
|
More insights into the Jest crash: |
|
Not really sure how to diagnose this further. I'll try attaching a profiler to it soon. |
|
Maybe a leak in |
|
This is crazy - If I comment out |
|
Bisecting down the require tree, isolated it to |
| "<rootDir>/src/deprecated.js" | ||
| ], | ||
| moduleNameMapper: { | ||
| "graceful-fs": "<rootDir>/tests_config/fs.js" |
There was a problem hiding this comment.
If this works, maybe add a comment explaining why we do this?
There was a problem hiding this comment.
Yeah, I want to test it out in CI, and maybe do the same thing with the Rollup builds.
There was a problem hiding this comment.
Actually not in the rollup build - see jestjs/jest#2179 (comment)
There was a problem hiding this comment.
This fixes the dev build, but the production build is still broken (because graceful-fs will be bundled in). Should I remap graceful-fs for the Rollup build too?
There was a problem hiding this comment.
Maybe we could put it in third-party.js?
There was a problem hiding this comment.
I don't think so because we're not requiring it, load-json-file is
| replace({ | ||
| "#!/usr/bin/env node": "", | ||
| // See comment in jest.config.js | ||
| "require('graceful-fs')": "require('fs')" |
There was a problem hiding this comment.
I tried doing this with rollup-plugin-alias, but couldn't get it working.
|
Build is green - ready for review 😄 |
| opts = Object.assign( | ||
| { | ||
| plugins: [], | ||
| pluginsLoaded: false, |
There was a problem hiding this comment.
We should write some docs for these options.
There was a problem hiding this comment.
It's still somewhat intentionally undocumented as it is unreleased.
There was a problem hiding this comment.
@azz You could write it up in an HTML comment, then remove the <!-- and --> when the update is released.
|
It seems this PR introduced an |


Automatically loads plugins with the name
@prettier/plugin-*orprettier-plugin-*from the nearest package.json up the file system tree.