The current shim webpack uses for nextTick and setImmediate uses setTimeout(task, 0)
but there are better alternatives. See https://github.com/calvinmetcalf/immediate.
1 thought on “web: inefficient shims for nextTick & setImmediate”
Comments are closed.
Hang on; no, this is backwards.
setImmediate
should use the macrotask queue, which it does via the setimmediate shim, which is imported bytimers-browserify
, which webpack correctly uses. Note that this is still faster thansetTimeout(func, 0)
. The OP was incorrect in saying that webpack usessetTimeout
forsetImmediate
shimming; the current behavior is correct.process.nextTick
should use the microtask queue, (note this changed in Node 0.9 from macro -> micro), and is incorrectly shimmed bynode-process
to usesetTimeout
, when it should use something like next-tick which usesMutationObserver
when available. This is the bug.