Created
March 4, 2017 22:22
-
-
Save sskoopa/8b4d5249e3f6669590b33d9e608cc691 to your computer and use it in GitHub Desktop.
polyfill for require.ensure on NodeJS when using webpack 1 for code-splitting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// polyfill for webpacks' require.ensure() | |
// credit: https://github.com/webpack/webpack/issues/183#issuecomment-169186696 | |
// | |
let proto = Object.getPrototypeOf(require) | |
!proto.hasOwnProperty('ensure') && Object.defineProperties(proto, { | |
'ensure': { | |
value: function ensure (modules, callback) { | |
callback(this) | |
}, | |
writable: false | |
}, | |
'include': { | |
value: function include () { }, | |
writable: false | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment