Skip to content
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

This call to "require" will not be bundled because the argument is not a string literal (surround with a try/catch to silence this warning) #1132

Closed
Valexr opened this issue Apr 9, 2021 · 6 comments

Comments

@Valexr
Copy link

Valexr commented Apr 9, 2021

Can't bundling mongoose module

Screenshot 2021-04-09 at 19 00 47

@ggoodman
Copy link

ggoodman commented Apr 9, 2021

Looks like a dupe of #1127.

EDIT: Looked more into this, and I don't believe it is a dupe after all. This sort of dynamic dependency resolution is really problematic for bundlers. Figuring how those dependencies during bundling is pretty tricky. It would require the bundler to be able to statically evaluate the value of global.MONGOOSE_DRIVER_PATH (in the first) and of driver (in the last 2) warnings. In many cases this will be impossible / impractical. Different bundlers have different levels of sophistication with their heuristics to solve this sort of thing.

@Valexr
Copy link
Author

Valexr commented Apr 9, 2021

Yep... seems like this... internal require(foo + 'string') not string literal in imported module don't bundling...

@evanw
Copy link
Owner

evanw commented Apr 10, 2021

Yes, it's not possible to bundle things like this. The warnings are correct. They are warnings instead of errors because your bundle could hypothetically still work if these code paths are not relied upon. But if you need this to work then you're out of luck. You'll either have to run the code unbundled or use another tool instead of esbuild.

@evanw
Copy link
Owner

evanw commented Apr 10, 2021

Closing this because this is by design.

@evanw evanw closed this as completed Apr 10, 2021
@Valexr
Copy link
Author

Valexr commented Apr 10, 2021

Ok. Tx for res @evanw 🤓

@ndr47
Copy link

ndr47 commented Jun 23, 2021

Does somebody know any workaround to bundle mongoose module with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants