auth0.js: Upgrading to 9.7.2 causes test breakages
I upgraded from auth0-js 9.5.1 to ^9.7.2 and am now seeing the following error when running my jest tests:
/Users/[my-user]/[my-repo]/node_modules/auth0-js/src/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import Authentication from './authentication'
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 21 (11 by maintainers)
Commits related to this issue
- Migrate to ES modules (#774) In order to be able to properly do tree-shaking, we need to start using ES modules (`import` / `export`) instead of CommonJS modules (`require`). This PR is a find/replac... — committed to auth0/auth0.js by luisrudge 6 years ago
- Fix npm module export (#808) - Remove rollup-plugin-uglify because it doesn't support minifying ES6+. Using rollup-plugin-terser instead - Don't generate prod files when in dev mode - instead of us... — committed to auth0/auth0.js by luisrudge 6 years ago
Thanks! That’s very helpful. I’ll dig through this today and I hope to have a patch by tomorrow.
9.7.0 should’ve been a major version bump, as any application participating in SSR is now broken. Alternatively, you should retain backwards compatibility by shipping both CommonJs and ESM versions of Auth0.
I just got bit by this in a Next.js application.
Great to hear, @lucascrespo! Looking forward to a fix. 😄
Apps will look at the
main
field when running via Node (SSR, or tests – like this issue) and thebrowser
ormodule
field when being consumed by webpack (normal bundle application).General rule of thumb is as follows:
esnext
: uncompiled sources, whatmain
is currently set tobrowser
: compiled down to minimum supported browser version (and no ES Modules)module
: compiled down to minimum supported browser version, except that ES Modules remain in placemain
: compiled down to minimum supported Node versionMost people opt for
module
andmain
, there’s not much value in shippingbrowser
noresnext
.Here’s a really simple repro case: