-
Notifications
You must be signed in to change notification settings - Fork 309
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
esbuild/vite: ReferenceError: module is not defined #832
Comments
Looks like there's an issue with Looks like webpack supports createRequire https://webpack.js.org/configuration/externals/#externalstypenode-commonjs while rollupjs does not support nodejs rollup/rollup#4597 yet does support deno https://rollupjs.org/tools/#deno esbuild makes Edit: I'm looking more into solutions. There is the deasync library, which would enable synchronous imports from cjs modules. If this library were written in esm with a cjs shim, then we can use that approach. If we don't want something like deasync as a dependency, we could create a cjs api shim. There may be a clever way to utilize the Proxy object, perhaps by enqueueing synchronous calls & importing the ESM in one of the async functions. A cjs shim approach will fix the ESM issues for all bundlers with some added complexity in the cjs shim itself. ---- Edit 2 A simpler solution would be adding a separate exports to support both the |
For now, esbuild/vite projects can use |
Thanks for raising this @btakita We're currently doing a rewrite of this library to ESM for v4 which should resolve this issue. For now, in the current v3 version I suggest using the workaround you've described (to load the cjs version using
That's odd, because most of the reports with the |
We've released v4 Beta which should have full support for ESM (and CJS) For bundling v3 within esbuild/vite projects we recommend using the workaround described in #832 (comment) Closing this thread in favour of #859 |
Checklist
Description
When importing 'auth0' in Vite, the following error occurs:
Reproduction
auth0
import { ManagementClient } from 'auth0'
Additional context
Vite requires valid esm modules, meaning commonjs modules cannot be imported.
The following must be used with nodejs for this to be valid ESM.
Note that webpack & rollup imports are not valid esm but a temporary hybrid.
node-auth0 version
v3.4.0
Node.js version
20.1.0
The text was updated successfully, but these errors were encountered: