aurelia / new

The Aurelia 2 scaffolding repo used by our tools to setup new projects.
MIT License
35 stars 18 forks source link

Support Yarn backward compatibility mode (node-modules) for Yarn version 2.x or higher #86

Closed nenadvicentic closed 1 year ago

nenadvicentic commented 1 year ago

This pull request addresses issue #85.

When development machine has yarn version 2.x or higher installed (current version at the moment is 3.x), after developer chooses to install npm dependencies using yarn, yarn works in Plug'n'Play mode. This means that no node_modules folder in created and all npm packages are stored in .yarn folder unpacked, in original zip format.

  1. This means that command npm start written in "Getting started" tip does not work. yarn start is printed now, when yarn was picked as package manager.
  2. When using Visual Studio Code, for it's TypeScript language service to work Yarn's Editor SDKs extension is needed, to make TypeScript language service (local to the folder) aware of module resolution strategy.
  3. For Parcel not to throw errors, two dev-dependencies had to be added to project's package.json: "@aurelia/runtime-html", "@aurelia/router" for direct-routing template and "@parcel/config-default".

Now parcel starts/builds project without throwing errors.

UPDATE: It turned out to be a problem to make Yarn's new PnP mode work seamlessly with different IDEs and bundlers. Switching Yarn 2+ to backward compatibility mode with nodeLinker: node-modules option, to force it to create node_modules folder seems like more stable and simpler option at the moment.

3cp commented 1 year ago

Thx very much for working on this! The parcel deps issue is bit strange. Probably parcel+yarn-pnp issue. I will test more and get back to you.

3cp commented 1 year ago

Unfortunately yarn pnp loose mode didn't help on the parcel issue :-(

nenadvicentic commented 1 year ago

@3cp After thinking a bit longer about this, I reworked the branch from scratch:

  1. Instead of trying to make everything work with Yarn's PnP, I switched it to backward compatible mode with nodeLinker: node-modules option in .yarnrc.yml file. Now Yarn 2+ created node_modules folder as well.
  2. As discussed before "Get Started" displays name of correct package manager. Unit tests are all there.
  3. I added strict-peer-dependencies=false option for pnpm in .npmrc file. To avoid installation of packages breaking due to missing peer dependency.
3cp commented 1 year ago

Thank you!