Skip to content

Instantly share code, notes, and snippets.

@sskoopa
Created March 4, 2017 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sskoopa/8b4d5249e3f6669590b33d9e608cc691 to your computer and use it in GitHub Desktop.
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
// 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