Open arcanis opened 3 weeks ago
@JounQin fixing this would solve the following issues: https://github.com/microsoft/vscode-eslint/issues/1856 https://github.com/yarnpkg/berry/issues/6335
the community would be really greatful ❤️
Sorry I'm not familiar with these concepts and don't quite have enough time recently :(
If anyone can raise a PR that would be really appreciate.
@arcanis i tried to follow your suggestion and created a draft PR here https://github.com/un-ts/synckit/pull/175/files, but the prettier plugin still seems to fail in latest vscode with yarn pnp. Did I misunderstand something?
@arcanis i tried to follow your suggestion and created a draft PR here https://github.com/un-ts/synckit/pull/175/files, but the prettier plugin still seems to fail in latest vscode with yarn pnp. Did I misunderstand something?
Did you lint on typescript files? To my understanding what's been ignored is here: https://github.com/un-ts/synckit/blob/22387b45c64245e750e894197cce70714fc36e12/src/index.ts#L211-L213
@hanyufoodles see https://github.com/yarnpkg/berry/issues/6335#issuecomment-2172632114 pls, from my understanding this https://github.com/prettier/eslint-plugin-prettier/blob/de9751c85d059678904035322501bfce120f61b7/worker.js#L36 import fails because of lack of pnp loader in the context of a worker.
I also tried linting regular .js
files with my attempted patch but the issue persists :(
I'm not sure if TsRunner
is relevant in this particular case, however since it's added through --loader
arg it would probably need a similar workaround for node 20 :(
With latest vscode (1.90.2) and eslint-plugin-prettier
and synckit
packages unplugged it seems that runAsWorker
is not executed because the early return in https://github.com/un-ts/synckit/blob/main/src/index.ts#L560 kicks in, so the problem must occur earlier when starting worker thread, but i'm not able to figure it out.
With latest vscode (1.90.2) and
eslint-plugin-prettier
andsynckit
packages unplugged it seems thatrunAsWorker
is not executed because the early return in https://github.com/un-ts/synckit/blob/main/src/index.ts#L560 kicks in, so the problem must occur earlier when starting worker thread, but i'm not able to figure it out.
FWIW, your PR is working for me. Latest vscode and eslint-plugin-prettier. I cloned your forked repo, and linked synckit and voila! Eslint is working again. I'm also using latest yarn and latest yarn sdks for eslint.
@imccausl interesting! and you're also using pnp mode i suppose? I actually used pretty naive approach of directly editing the unplugged package code to verify if this works. I'll retest that tomorrow by building the code from PR and "linking" to a local synckit package. Thanks for the hint <3
@imccausl interesting! and you're also using pnp mode i suppose?
Yep. pnp mode 💯. I was also poking around at this issue and ended up basically with the same solution as you, so I was surprised to see it wasn't working for you.
I can also confirm it fixes the issues we had at work with ESLint in VSCode when using eslint-plugin-mdx
(I manually patched our local synckit
package using yarn patch
).
Note that you probably have to update both the .cjs
file (which is used by ESLint) and the .js
file (which is used by the ESM worker).
@arcanis thanks a lot for the update! not updating both cjs and esm files in the unplugged package was exactly the reason it didn't work for me!
Setting
"resolutions": {
"synckit": "file:../synckit"
}
with both files compiled makes it work for me too!
@JounQin now that we were able to confirm https://github.com/un-ts/synckit/pull/175 solves the issue with pnp loader in node 20, would you be able to review it and hopefully merge and release? Thanks a lot!
When using PnP, SyncKit automatically adds the
--loader
flag. Unfortunately, this doesn't work in Node.js, the--loader
flag is accidentally ignored for workers.Instead, I suggest you try calling
module.register
from within the worker thread itself, as an implementation detail of therunAsWorker
function.