-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
accept require() with non string literal input #113
Comments
Thanks for this issue. I agree that this is a good escape hatch to have, and that it would let more real-world code be bundled with esbuild. That code may crash at run time if the files aren't there or if the bundle is used in the browser, but at least the bundling process would succeed. This could be useful in cases like this or in cases where the crash may not matter (e.g. it's in code that is never called). I'm not quite sure what the best way of adding this is yet. Rollup just passes this straight through without a warning, which seems somewhat dangerous. But it might be the simplest way to solve this. I'll have to think more about this. |
thank for taking the time to answer, let me know if I can help in any way :) |
This is the only issue preventing esbuild from being able to build our medium-large production codebase, due to a couple of dependencies using require in this way (which is out of our control). I would also be happy to help on this if needed 👍 |
As of version 0.5.3, using require() with non string literal input is now a warning instead of an error. Hopefully this unblocks some use cases for esbuild that were previously blocked. |
Has there been any workaround proposed for this? |
Nevermind, still figuring this out. |
I'm trying to build an CLI and i request a glob pattern to find all the files and then require them to exec the code.
when i try to build with esbuild, i get this error :
The argument to require() must be a string literal
From other issues, I've seen that you want to analyze the dependencies and that's why esbuild requires string literal.
but in my case i need to require dynamically, is there a way to do this or esbuild won't work for CLI that use require to load files based on a pattern?
this is currently what i do:
The text was updated successfully, but these errors were encountered: