require() returns a Promise?!? #37520
Replies: 4 comments 20 replies
-
Well, require doesn't really exist on client side, so I guess some other library is taking over the require global definition, and replacing it with an asynchronous version. At first I thought it'd be related to browserify, butI tried to reproduce, but I get no promise, only the module. How does your package.json look like? Perhaps you are importing some scripts? polyfills? Or maybe you are doing something funny to the webpack config? |
Beta Was this translation helpful? Give feedback.
-
I'm facing a quite similar issue where I conditionally require a package (for ssr), where require returns a promise. Any solutions? |
Beta Was this translation helpful? Give feedback.
-
I just had the same issue. it seemed to not work on the server side, and work only on the client side, which is super effing weird. |
Beta Was this translation helpful? Give feedback.
-
I'm running into the same issue in my project, but the problem is when I'm trying to define a circular reference in my GraphQL schema
WTF !? anyone have any tips? Context is that |
Beta Was this translation helpful? Give feedback.
-
I have code where a call to
require()
returns a Promise. WTF? require calls are supposed to be synchronous, not return promises! This not only happens in client code, but also in getStaticProps on the server. Even when the path is completely static and known and resolvable at build time. When I replace therequire()
call with an import declaration it works.The returned value has this shape:
The stuff is there, correct, but wrapped in a promise.
Minimal project to reproduce issue, see this comment: #37520 (reply in thread)
Beta Was this translation helpful? Give feedback.
All reactions