8000 avoid webpack shimming setImmediate · ormazza/vue@cbc3f90 · GitHub
[go: up one dir, main page]

Skip to content

Commit cbc3f90

Browse files
committed
avoid webpack shimming setImmediate
1 parent 93c1a50 commit cbc3f90

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/util/env.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,14 @@ export const nextTick = (function () {
8383
counter = (counter + 1) % 2
8484
textNode.data = counter
8585
}
86-
} else if (typeof setImmediate === 'function') {
87-
timerFunc = setImmediate
8886
} else {
89-
timerFunc = setTimeout
87+
// webpack attempts to inject a shim for setImmediate
88+
// if it is used as a global, so we have to work around that to
89+
// avoid bundling unnecessary code.
90+
const context = inBrowser
91+
? window
92+
: typeof global !== 'undefined' ? global : {}
93+
timerFunc = context.setImmediate || setTimeout
9094
}
9195
return function (cb, ctx) {
9296
var func = ctx

0 commit comments

Comments
 (0)
0