Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Yarn 2 section to FAQ #1027

Merged
merged 2 commits into from
Apr 16, 2021
Merged

Add Yarn 2 section to FAQ #1027

merged 2 commits into from
Apr 16, 2021

Conversation

Rich-Harris
Copy link
Member

#993.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpx changeset and following the prompts

@TrySound
Copy link

Yarn 3 fixes the problem
https://github.com/yarnpkg/berry/blob/master/CHANGELOG.md#300-rc1

@@ -13,3 +13,7 @@ Put the code to query your database in [endpoints](../docs#routing-endpoints) -
### How do I use Axios?

You probably don't need it. We'd generally recommend you just use `fetch` instead. If you insist, you're probably better off using the ESM drop-in replacement `redaxios` [until axios utilizes ESM](https://github.com/axios/axios/issues/1879). Finally, if you still want to use Axios itself, try putting it in `optimizeDeps.include`.

### Does it work with Yarn 2?
Copy link

@merceyz merceyz Apr 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Does it work with Yarn 2?
### Does it work with Yarn PnP?

Yarn 1 and pnpm support PnP


### Does it work with Yarn 2?

Sort of. The Plug'n'Play feature, aka 'pnp', is broken (it deviates from the Node module resolution algorithm, and doesn't work with native JavaScript modules which SvelteKit — along with an [increasing number of packages](https://blog.sindresorhus.com/get-ready-for-esm-aa53530b3f77) — uses). You can use `nodeLinker: 'node-modules'` in your [`.yarnrc.yml`](https://yarnpkg.com/configuration/yarnrc#nodeLinker) file to disable pnp, but it's probably easier to just use npm or [pnpm](https://pnpm.io/), which is similarly fast and efficient but without the compatibility headaches.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Sort of. The Plug'n'Play feature, aka 'pnp', is broken (it deviates from the Node module resolution algorithm, and doesn't work with native JavaScript modules which SvelteKit — along with an [increasing number of packages](https://blog.sindresorhus.com/get-ready-for-esm-aa53530b3f77) — uses). You can use `nodeLinker: 'node-modules'` in your [`.yarnrc.yml`](https://yarnpkg.com/configuration/yarnrc#nodeLinker) file to disable pnp, but it's probably easier to just use npm or [pnpm](https://pnpm.io/), which is similarly fast and efficient but without the compatibility headaches.
Sort of. The Plug'n'Play feature, aka 'pnp', [doesn't work with native JavaScript modules yet](https://github.com/yarnpkg/berry/issues/638) which SvelteKit — along with an [increasing number of packages](https://blog.sindresorhus.com/get-ready-for-esm-aa53530b3f77) — uses). You can use `nodeLinker: 'node-modules'` in your [`.yarnrc.yml`](https://yarnpkg.com/configuration/yarnrc#nodeLinker) file for Yarn 2+ to use the `node_modules` layout instead.

@Rich-Harris
Copy link
Member Author

Yarn 3 fixes the problem

A Yarn maintainer confirmed that this isn't the case, at least not yet.

@merceyz thank you for the review. We stand by the wording here though — PnP is broken if the threshold is parity with Node's default behaviour, for the two reasons given. It's true that it's possible to disable PnP, but as long as it's the default it will continue to cause confusion in the JS ecosystem. As maintainers who have been affected by that confusion we feel that the recommendation to use alternative package managers is justified.

@Rich-Harris Rich-Harris merged commit eacd330 into master Apr 16, 2021
@Rich-Harris Rich-Harris deleted the yarn-faq branch April 16, 2021 21:53
@avarun42
Copy link
Contributor

avarun42 commented Mar 4, 2022

Is this still true after PRs yarnpkg/berry#2161 and yarnpkg/berry#3667 got merged? From a cursory glance it seems like PnP supports ES Modules now — can anyone confirm if that means Yarn 3.1+ work with SvelteKit? @Rich-Harris

@dummdidumm
Copy link
Member

We don't use yarn, but you are welcome to try it out and report back if it works now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants