-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Error "require is not defined" when running bundled files #506
Comments
This happens because esbuild supports CommonJS modules, so Some ideas for what to do here:
The |
I eventually worked around this, but i think i found another bug. I will try the solutions provided. Thanks! |
Closing. Sounds like this was resolved. |
I'm using esbuild to bundle the files in a folder. One of those files is a jquery plugin, that will check for the exports object, and if the exports object is defined, then will call the
require
method. Something like this:Now, esbuild bundles that file like this:
So the exports object is passed in to the module, and the module then tries to call
require()
, which throws an error because i'm not using requireJs on this project. Something like this:If i manually set the exports object to false on the output file, the bundled code works as expected, without throwing an error.
So, how can override this exports object for every build i make, or can i have an option to set the value of the exports object?
Data
main.js
imports.js
The text was updated successfully, but these errors were encountered: