-
Notifications
You must be signed in to change notification settings - Fork 194
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
TypeError: Cannot read property 'exports' of undefined with experiments.topLevelAwait
enabled
#432
Comments
experiments.topLevelAwait
enabled
I don't know how reliable this can prove to be, but changing: react-refresh-webpack-plugin/lib/utils/makeRefreshRuntimeModule.js Lines 38 to 40 in a88fd0f
to: '} finally {',
' Promise.resolve().then(() => {',
webpack.Template.indent(`${refreshGlobal}.cleanup(options.id);`),
' });',
'}', fixed the crash. However, for some reason, I'm now getting:
|
Hey, thanks for testing out Top Level Await. Unfortunately to support this feature properly basically the whole runtime needs to be re-written/extended to support full asynchronous behaviour and probably wouldn't land soon (at least not in A very brief explanation on why this is hard
Edit: If you don't mind, can you try the branch here: #435? |
I tested it on 0.5.0-rc.2 and it's not working for me. I enabled top level await and included one module using it. Then, I did a simple text change in one of my other, synchronous JSX files.
Logs looked correct, but the component wasn't actually updated. Tried editing this file again, and:
and it got stuck on this message. Removing top level await support makes the update work again just fine. |
@wojtekmaj Is it possible to provide a reproducible example? |
Sure! Sorry for the delay. Reducing my repo to repro repo was quite a task. |
Is TLA support stable? I used /* provided dependency */ var __react_refresh_utils__ = __webpack_require__("../../node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js");
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_crypto__WEBPACK_IMPORTED_MODULE_4__]);
_crypto__WEBPACK_IMPORTED_MODULE_4__ = (__webpack_async_dependencies__.then ? await __webpack_async_dependencies__ : __webpack_async_dependencies__)[0];
__webpack_require__.$Refresh$.runtime = /*#__PURE__*/ (....); where you can see |
|
Oh, crypto is not the Node |
When launching the app with @pmmmwh/react-refresh-webpack-plugin, it crashed for me. Interestingly, this happened when I enabled
experiments.topLevelAwait
in Webpack and introduced one module which uses top level await. Enabling this option and NOT adding this one module does NOT cause the app to crash.I found out that getModuleExports was called with
moduleId
beingundefined
. Thisundefined
came from:where the entire
$Refresh$
object looks like so:And here's the same object before this
topLevelAwait
change:I figured out it must be caused by:
__webpack_require__.$Refresh$.setup()
not being called for some reason__webpack_require__.$Refresh$.cleanup()
being called too early for some reasonAnd it looks like the latter is the cause. I have seen
.cleanup()
being executed beforegetModuleExports
.I suppose this has something to do with
AsyncModuleRuntimeModule
using Promises.The text was updated successfully, but these errors were encountered: