pmndrs / zustand

🐻 Bear necessities for state management in React
https://zustand-demo.pmnd.rs/
MIT License
46.25k stars 1.42k forks source link

Issue with Bitbucket Pipelines with Next.js 12, Zustand, and Cypress #1002

Closed FlorianWoelki closed 2 years ago

FlorianWoelki commented 2 years ago

Currently, I am using Next.js 12.0.1, Zustand 3.7.5, and Cypress for end-to-end testing. Everything works fine locally. However, when I try the same thing to do in Bitbucket pipelines, it seems that it is an issue related to #665, #962 or https://github.com/vercel/next.js/issues/30750

I've tried several things like using other node images or disabling esmExternals in the next config.

I get the following error:

$ cypress run --config video=false
$ next dev
ready - started server on 0.0.0.0:3000, url: http://localhost:3000/
info  - Loaded env from /opt/atlassian/pipelines/agent/build/.env.development
[STARTED] Task without title.
(node:72) ExperimentalWarning: The ESM module loader is experimental.
wait  - compiling...
event - compiled client and server successfully in 5.9s (341 modules)
[305:0612/191621.252637:ERROR:cert_verify_proc_builtin.cc(681)] CertVerifyProcBuiltin for [redirector.gvt1.com](http://redirector.gvt1.com/) failed:
----- Certificate i=0 (OU=Cypress Proxy Server Certificate,O=Cypress Proxy CA,L=Internet,ST=Internet,C=Internet,[CN=redirector.gvt1.com](http://cn%3Dredirector.gvt1.com/)) -----
ERROR: No matching issuer found
Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry
[305:0612/191621.940217:ERROR:cert_verify_proc_builtin.cc(681)] CertVerifyProcBuiltin for [r2---sn-p5qddn76.gvt1.com](http://r2---sn-p5qddn76.gvt1.com/) failed:
----- Certificate i=0 (OU=Cypress Proxy Server Certificate,O=Cypress Proxy CA,L=Internet,ST=Internet,C=Internet,[CN=r2---sn-p5qddn76.gvt1.com](http://cn%3Dr2---sn-p5qddn76.gvt1.com/)) -----
ERROR: No matching issuer found
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating
  Authentication
    anonymous user
wait  - compiling /auth (client and server)...
wait  - compiling...
event - compiled client and server successfully in 6.4s (1945 modules)
wait  - compiling /_error (client and server)...
wait  - compiling...
event - compiled client and server successfully in 1090 ms (1946 modules)
file:///opt/atlassian/pipelines/agent/build/node_modules/zustand/esm/index.mjs:1
import { useReducer, useRef, useDebugValue, useEffect, useLayoutEffect } from 'react';
                     ^^^^^^
SyntaxError: The requested module 'react' is expected to be of type CommonJS, which does not support named exports. CommonJS modules can be imported by importing the default export.
For example:
import pkg from 'react';
const { useReducer, useRef, useDebugValue, useEffect, useLayoutEffect } = pkg;
    at ModuleJob._instantiate (internal/modules/esm/module_job.js:97:21)
    at async ModuleJob.run (internal/modules/esm/module_job.js:136:20)
    at async Loader.import (internal/modules/esm/loader.js:179:24)
file:///opt/atlassian/pipelines/agent/build/node_modules/zustand/esm/index.mjs:1

In addition, I do not really get why node complains that ESM module loader is experimental because I am on node version >16. Is the new Next.js compiler working fine with Zustand?

harshmaisheri commented 1 year ago

Facing same issue. Did you found any solutions?