neutrino icon indicating copy to clipboard operation
neutrino copied to clipboard

Implement Yarn 2 support

Open constgen opened this issue 4 years ago • 10 comments

Resolves https://github.com/neutrinojs/neutrino/issues/1277

  • [x] Bump minimal Jest version to support Plug and Play
  • [x] Add PnP middleware
  • [x] Make sure all resolves are PnP compatible
  • [x] Use PnP middleware in all presets
  • [x] Adopt all ESLint presets as there are known problems with ESLint sharable configs and PnP

constgen avatar Oct 03 '20 22:10 constgen

I can see in the build logs that the job published packages to NPM. But why? It even didn't pass the code formatting check. And this is only Pull Request.

constgen avatar Oct 03 '20 22:10 constgen

I can see in the build logs that the job published packages to NPM. But why?

It's not a real NPM server - see: https://github.com/neutrinojs/neutrino/blob/master/scripts/test-create-project-ci.sh

edmorley avatar Oct 12 '20 08:10 edmorley

Here are my thoughts. I have my personal set of Neutrino middlewares and presets for React, ESLint and other. I reuse couple of Neutrino core middlewares, but most are custom. I faced really a lot of problems with Yarn 2. Especially with ESlint. I resolved them. Some solutions were really hacky. So I decided to integrate my experience to the Neutrino core.

Lets discuss your points

  • PnP will be supported in Webpack 5. This is true. Until this moment configuration need to use PnPPlugin. Some projects need this already today. Internally the plugin checks the PnP environment (Yarn documented how to do this) and enables necessary functionality on demand. Speaking simply it has no effect on NPM and PNPM projects. I also thought about conditionally enabling it but realized that it is easier to inspect Webpack Config when it is always included. This is how CRA and Storybook do - they always include PnPPlugin to configuration.
  • I will document the integration of Jest and PnP. But please recommend me where to write "PnP" section
  • I thought that Neutrino goal is to hide the config complexity from the consumer. That's why I decided that react and vue presets should support this out of the box without thinking how to enable this. And according to the first point it should not affect the build process on NPM. Again, CRA does this. Also it is little easier to upgrade to Webpack 5 later. You will not need to edit .neutrinorc.js

constgen avatar Oct 12 '20 10:10 constgen

Please, look at the new section in the documentation https://github.com/constgen/neutrino-dev/tree/pnp/packages/eslint#utility-functions

constgen avatar Nov 03 '20 16:11 constgen

I think everything related to Yarn 2 is resolved. The only left are tests. And I think there is a separate problem. I feel like tests can affect each other and they are not isolated. Seems like they may have a shared neutrino config and all Webpack plugins are applied across test. Is it possible? Because currently just commenting one test can make other tests red or green.

constgen avatar Nov 16 '20 19:11 constgen

@edmorley in Webpack 5 only pnp-webpack-plugin will be not necessary. All other fixes to ESLint, Jest and etc. will be highly required. Their issues still remain. So with pnp-webpack-plugin or without it we need this PR any way. But without pnp-webpack-plugin it will be hard to automate testing in Yarn 2. In my opinion it affects only several presets and it will be really easy to remove it in Neutrino 10 without affecting anything.

constgen avatar Dec 01 '20 21:12 constgen

@edmorley @eliperelman can you look at final version of this PR?

constgen avatar Mar 08 '21 21:03 constgen

@constgen Thank you for working on this :-) Before it can be merged (and so before spending time on review), we need to have CI passing, which is blocked on Travis CI credits running out, due to Travis CI's new policy (that is, there are no more free credits). The best way to resolve this would be to migrate to another provider -- I would recommend Circle CI. I don't have time to work on such a migration, but would be happy to review a PR that did so.

edmorley avatar Mar 08 '21 21:03 edmorley

Is GitHub Actions is an option? I tried it recently for one of my projects as a replacement for Travis. Have to say that it also has free plan limits but it worked well for me

constgen avatar Mar 09 '21 13:03 constgen

Yeah that works too :-)

edmorley avatar Mar 09 '21 13:03 edmorley

Closing since unfortunately this project is no longer maintained. See: https://github.com/neutrinojs/neutrino/issues/1707 https://github.com/neutrinojs/webpack-chain/issues/358

edmorley avatar Feb 03 '24 19:02 edmorley