Module becomes `undefined` after refresh due to cyclic dependencies
See original GitHub issueI’m experiencing a bug where upon changing a file, one of my modules becomes undefined
(causing part of the page to disappear).
I’ve mostly reduced my repro case. It seems related to cyclic dependencies. Repro steps:
-
Run
yarn
andyarn start
, then visit http://localhost:7002/. You’ll see the text “Hello: 100”. -
If you edit the “Hello” (in App.js), it updates properly.
-
If you edit the “100” (in SurveyOverview.js), the 100 disappears until next page reload.
This is because the DashboardPage import in routes.js becomes undefined (as you can see from the console logs). If you check the same import a tick later, it is correctly populated.
Not sure whether the bug is in react-refresh-webpack-plugin, react-refresh, or webpack.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:7 (4 by maintainers)
Top Results From Across the Web
node.js - Imported module is undefined when there's a circular ...
Imported module is undefined when there's a circular dependency between the modules when one module is in the parent directory of the other...
Read more >How to solve this basic ES6-module circular dependency ...
For reference, I'm trying this in Meteor, in which case the first module to be evaluated is module B, but that means that...
Read more >Webpack 5 Module Federation: A game-changer in JavaScript ...
A scalable solution to sharing code between independent applications has never been convenient, and near impossible at scale.
Read more >typeerror class extends value undefined is not a constructor or ...
If anyone else sees this error, the first thing to look for is circular dependencies. Import file A into B, B into some...
Read more >Circular Dependency - A progressive Node.js framework
A circular dependency occurs when two classes depend on each other. For example, class A needs class B, and class B also needs...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Timer I think you’re the better judge of that! But it does appear that you successfully copied my code into a test case. 😅 Does the fact that it passes CI mean that this works correctly in @next/react-refresh-utils already?
Closing as it is marked as
won't fix
in upstream.