andywer / andywer/threads.js

yarn v3 PNP

Offen
#423 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
TypeScript
Sterne
3.5k
Forks
173
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

It appears that using Yarn v3's PNP functionality causes the Worker to not load the actual file. If `nodeLinker` is set to `node-modules` in `.yarnrc.yml`, it works as expected.

This is the error I'm receiving
> Timeout: Did not receive an init message from worker after 10000ms. Make sure the worker calls expose().

The best I can tell, it's due to using `require` within the `resolveScriptPath` function. It might be worthwhile to look into [createRequire function](https://nodejs.org/api/module.html#module_module_createrequire_filename) as described in yarn's [rule book](https://yarnpkg.com/advanced/rulebook#packages-should-only-ever-require-what-they-formally-list-in-their-dependencies) on the topic
> If your package is something that automatically loads plugins (for example eslint), peer dependencies obviously aren't an option as you can't reasonably list all plugins. Instead, you should use the [createRequire function](https://nodejs.org/api/module.html#module_module_createrequire_filename) (or its [polyfill](https://github.com/nuxt-contrib/create-require)) to load plugins on behalf of the configuration file that lists the plugins to load - be it the package.json or a custom one like the .eslintrc.js file.

I haven't had a chance to debug it further, so I'm speculating the createRequire function will resolve the issue.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.