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

The 2.4 release breaks cypress in many repos #638

Closed
skjnldsv opened this issue Aug 27, 2023 · 5 comments
Closed

The 2.4 release breaks cypress in many repos #638

skjnldsv opened this issue Aug 27, 2023 · 5 comments

Comments

@skjnldsv
Copy link
Contributor

          The 2.4 release breaks cypress in many repos for some reason.

https://github.com/nextcloud/viewer/actions/runs/5989883555/job/16246600700
https://github.com/nextcloud/photos/actions/runs/5798646767/job/15717925031

Originally posted by @skjnldsv in #627 (comment)

@susnux
Copy link
Contributor

susnux commented Aug 29, 2023

It provides correct exports, I guess the tests using imports but run as CJS instead of ESM?
In this case the using projects probably missing the jest transform for @nextcloud/axios.

(Its a pitty jest still does not support it oom)

@skjnldsv
Copy link
Contributor Author

skjnldsv commented Sep 6, 2023

In this case the using projects probably missing the jest transform for @nextcloud/axios.

Nope, Viewer doesn't even have jest 🙈

EDIT: it does have the dependency installed for some reason, and removing it makes it work.
But we are not using jest 🤔

EDIT2: nope, still fails, so the 2.4 release does have something weird in it 🤔

@feefladder
Copy link

feefladder commented Oct 11, 2023

Posting here since I think it is related:
I had an issue when developing my app.
I wanted to have an axios instance that makes external calls to another website, as well as the @nextcloud/axios instance provided by this library. This lead to an error that sometimes showed up and sometimes did not, depending on the order of installation:

  • Works:
    1. comment out the import axios from "axios" and all external-axios related code
    2. Build using npm run watch (using Vite)
    3. un-comment all external-axios related code
  • Error:
    1. un-comment all external-axios related code
    2. un-comment all @nextcloud/axios related code
    3. build using npm run dev/npm run build

So far so not-good, but how to solve this?
Well, it turns out @nextcloud/axios is built to include the line const axios = require("axios"), which leads to this issue. Indeed, by going into node_modules/@nextcloud/axios/index.cjs and changing to const axios=require("axios").default solves this issue.
image

EDIT: So running make/npm run build twice will result in the error. Then adding .default and running npm run build once will solve it again

@feefladder
Copy link

Alternatively,and I'm sure there is a better way:
in package.json, remove all references to the cjs file:

"main": "dist/index.es.mjs",
  "types": "dist/index.d.ts",
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "import": "./dist/index.es.mjs",
      "default": "./dist/index.es.mjs"
    }
  },

icewind1991 added a commit to nextcloud-libraries/notify_push-client that referenced this issue Jan 8, 2024
@susnux
Copy link
Contributor

susnux commented Aug 13, 2024

I did not see any app with that issue anymore. So seems that all apps have found a solution.

@susnux susnux closed this as not planned Won't fix, can't repro, duplicate, stale Aug 13, 2024
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

No branches or pull requests

3 participants