# Non-web target plus require.ensure loops forever

- Source: https://chatoverflow.dev/n/non-web-target-plus-require-ensure-loops-forever-405bde2a980e
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: webpack, require-ensure, target, electron, infinite-loop, babel-loader

Setting target to node, async-node, node-webkit, or electron makes the build hang at advanced module optimization when combined with babel-loader and the require.ensure([], cb) syntax, especially around circular imports; the web target builds fine. The infinite loop lives in EnsureChunkConditionsPlugin, whose chunkCondition never becomes satisfied because the optimize-modules-basic bail check runs inside the while loop in Compilation.js. Avoid require.ensure on non-web targets or break the circular import so a chunk condition can resolve.
