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

Yarn 3 does not work with type=module and cypress.config.js #25959

Open
lmiller1990 opened this issue Feb 27, 2023 · 6 comments
Open

Yarn 3 does not work with type=module and cypress.config.js #25959

lmiller1990 opened this issue Feb 27, 2023 · 6 comments
Labels
E2E Issue related to end-to-end testing package manager: yarn Issues relating to yarn Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team.

Comments

@lmiller1990
Copy link
Contributor

lmiller1990 commented Feb 27, 2023

Ref: #22747 -> #22747 (comment)

Repro: yarn3typemodule.zip

Workaround: change cypress.config.js to be named cypress.config.mjs. This should fix the issue. This means anything imported in cypress.config.mjs will need the mjs extension, and you will also need the full extension in the import. Eg:

import { defineConfig } from "cypress";
import { foo } from './foo.mjs' // mjs extension

export default defineConfig({
   e2e: {
      setupNodeEvents(on, config) {
        blah() // can call it here
        return config
      },
   },
})
@JessicaSachs
Copy link
Contributor

+1 but more importantly for pnpm. Should probably prioritize pnpm based on npm trends.
image

https://npmtrends.com/pnpm-vs-yarn

@MikeMcC399
Copy link
Contributor

This also has implications for documentation.

Currently there is an implicit assumption that either npm or Yarn Classic is being used as package manager. Yarn Modern (version 2 and later) in npmLinker: node-modules mode behaves much like Yarn Classic. Once Yarn Modern Plug'n'Play is used, then the documented instructions get into problems.

pnpm doesn't get much of a mention in the documentation either.

@nagash77 nagash77 added Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team. E2E Issue related to end-to-end testing labels Jul 25, 2023
@lmiller1990
Copy link
Contributor Author

pnpm is basically a drop in replacement, I don't think it has any issues, does it?

Yarn 3 PnP is a huge problem since we are not a standard module, we are entire native electron app, and Yarn tampers with assumptions we really should be able to make about the underlying Node.js engine. I would like to support Yarn 3 better, but we can never really be "zero installs", since our postinstall hook grabs a binary, and I don't think this is something that could be zipped up and stuck inside a git repo like Yarn 3 does with all the modules (this is my understanding of PnP, anyway - no installs since your modules are all committed in a zip file).

@MikeMcC399
Copy link
Contributor

@lmiller1990

pnpm is basically a drop in replacement, I don't think it has any issues, does it?

Since my previous post, pnpm has been added to the Getting Started > Installing Cypress documentation.

It works and it is not specifically relevant to this issue about Yarn 3.

@MikeMcC399
Copy link
Contributor

@lmiller1990

Yarn Modern Plug'n'Play has as an option: zero installs. Don't equate pnp with zero installs though, and I would recommend taking zero installs out of the consideration in the first instance.

In .yarnrc.yml for Yarn Modern, there are three different modes of nodeLinker:

  • pnp (default, unless it's a upgrade from Yarn Classic)
  • node-modules (default for upgrade from Yarn Classic - compatible with npm and causes no problems for Cypress)
  • pnpm (looks like it ought to be identical to the separate pnpm npm module, however it isn't. It doesn't work at all in github-action for instance)

I don't know the solution to this for Cypress!

@kubijo
Copy link

kubijo commented Aug 31, 2023

ce we are not a standard module, we are entire native electron app, and Yarn tampers with assumptions we really should be able to make about the underlying Node.js engine. I would like to support Yarn 3 better, but we can never really be "zero installs", since our postinstall hook grabs a binary, and I don't think this is something that could be

Just my two cents to this… I'm using yarn@4 with both PnP & zero-install "enabled" + the enableScripts: false configuration.
The last one helps by preventing unplug on many dependencies… since the existence of post-install script is one thing that triggers the unplug heuristic....

The only thing that I had to do to make cypress work again was to add yarn run cypress install before the startup scripts (since it now doesn't run automatically).


All that is just to illustrate a use case and possibly give a hint to others — nothing to do on your side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E Issue related to end-to-end testing package manager: yarn Issues relating to yarn Triaged Issue has been routed to backlog. This is not a commitment to have it prioritized by the team.
Projects
None yet
Development

No branches or pull requests

5 participants