Require inside the vue-router using webpack2 doesnt work on Safari only, works perfectly on chrome/firefox.
The callback resolve is never call. The app is correctly initialiaze and the bundle are loaded but then nothing happen as the promise never call the callback.
I try 3 different approach and they all work for Chrome/Firefox and fail on Safari...
router.map({
'/notWorking': {
component: function (resolve) {
console.log('this call is made')
require(['home.vue'], resolve)
}
},
'/alsoNotWorking': {
component: require('home.vue')
},
'/alsoNotWorking': {
component: function (resolve) {
require.ensure(['home.vue'], (require)=>{
console.log('called')
const comp = require('home.vue')
console.log('never call!!!!')
resolve(comp)
}, "home")
}
}
}
The code call by the factory looks like that ( note bundle 2 and 4 are the correct dependencie ) :
function component(resolve) {
Promise.all/* nsure */([__webpack_require__.e(2), __webpack_require__.e(4)])
.catch(function(err) { __webpack_require__.oe(err); })
.then((function (require) {
console.log('called');
var comp = __webpack_require__(147);
console.log('never call!!!!');
resolve(comp);
}).bind(null, __webpack_require__));
}
Thanks in advance.
Webpack 2 code split needs a Promise polyfill.
Thanks,
Step to fix it :
['babel-polyfill','whatwg-fetch','entry.js']This worked perfectly for me!
Thank you very much.
Thanks a lot guys!
That worked for me too.
We had issues with vuerouter running in Safari or Firefox and this 2 packages solved the problem
Most helpful comment
Thanks,
Step to fix it :
['babel-polyfill','whatwg-fetch','entry.js']