Like promise-loader, but with lazy promises (no invocation required).
Promise
is expected to be available in the global scope.
const _file = require('lazy-promise!./file.js')
// file will not be loaded until `.then()` is invoked
setTimeout(() => _file.then((file) => ...), 1000)
// or in ES2017
async function someHandler() {
const file = await _file
}
Optionally specify a name for your chunk...
const load = require("lazy-promise?editor!./editor.js")
Why bother? For APIs that expect promises before the chunk is to be loaded. That's why.
For example, say you have an API that accepts both functions, and promises that return functions, and these functions should not be invoked until some later time.
With the regular 'ol promise-loader, there is no way to programatically tell which is which.