next.js: Next 12.2 ReferenceError: exports is not defined
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Next 12.2(-12.2.2)
Describe the Bug
I’m no longer able to import code with exports
properly in Next 12.2
Expected Behavior
Next should properly bundle these files
Link to reproduction
https://github.com/hanford/12.2-exports
To Reproduce
Pull reproduction repo and try running on Next 12.2.0
, you’ll see the following error:
You can check out the working
branch, which just has Next 12.1.6
, after installing the older version the code will run without error.
–
Happy to provide more information if it’s helpful!
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 9
- Comments: 16 (9 by maintainers)
Commits related to this issue
- feat(next-swc/auto-cjs): Detect `__esModule` (#38181) ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contribut... — committed to vercel/next.js by kdy1 2 years ago
- deps(tngvi): updated next to v12.2.3-canary.5 since it resolves https://github.com/vercel/next.js/issues/38117. — committed to engagementlab/el-next by johnnycrich 2 years ago
We’re running into the same thing. It was working before on version 12.1.6.
Can confirm that this was working before 12.2, we use next-transpile-modules to bring in mixed modules and they worked just fine up until 12.2
add .babelrc without changing any configuration
{ "presets": ["next/babel"], "plugins": [] }
Nope, you can use patch-package if you want using this patch (
patches/next+12.2.0.patch
)Woot, excited for the next canary! 🖤