I’m implementing split points using commonJS however I can’t see a way to handle failed chunk requests. I also haven’t seen anything in the commonJS async proposal mentioning error handling. I have however seen implementations doing this:
require.ensure(['foo'], function(err) {
if (err) {
// error
return;
}
// success
var foo = require('foo');
});
Although I’m not sure if the spec requires the first argument to be require
?
I think the same goes for AMD as I can’t see anything in the spec re: error handling but almost all implementations do this:
require(['foo'], function(foo) {
// success
}, function() {
// error
});
In terms of implementation for webpack I imagine it could easily be handled by binding to the script tags ‘error’ event?
The webpack 2 API returns a Promise: