Vue-loader: vuerouter + webpack2 not working on safari

Created on 17 Jun 2016  路  4Comments  路  Source: vuejs/vue-loader

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.

Most helpful comment

Thanks,

Step to fix it :

  • install babel-polyfill & whatwg-fetch
  • in webpack config : entry: ['babel-polyfill','whatwg-fetch','entry.js']

All 4 comments

Webpack 2 code split needs a Promise polyfill.

Thanks,

Step to fix it :

  • install babel-polyfill & whatwg-fetch
  • in webpack config : entry: ['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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrisvfritz picture chrisvfritz  路  4Comments

birdgg picture birdgg  路  3Comments

sdvcrx picture sdvcrx  路  3Comments

amorphine picture amorphine  路  3Comments

C0deZLee picture C0deZLee  路  3Comments