mrcrowl / vuex-typex

Typescript builder for strongly-typed access to Vuex Store modules
MIT License
193 stars 22 forks source link

Script can't be run on IE11 #22

Closed biohazard999 closed 5 years ago

biohazard999 commented 5 years ago

I've tried a lot to solve that problem but I simply can't get it to work, I'm not sure if it is an issue in vue-typex or I am just too stupid to figure out whats going on.

If I use vuex-typex with IE11 it blows up with the issue described here

SCRIPT5022: Vuex handler functions must not be anonymous. Possible causes: fat-arrow functions, uglify.  To fix, pass a unique name as a second parameter after your callback.

I've prepared a repro here. Any help would be awesome. Thanks

rugia813 commented 5 years ago

in navigation.ts, if you assign a name for the functions for mutations or actions, it should work in ie11.

change

  commitOpenState: b.commit(setOpenState),

  dispatchToggleNavigation: b.dispatch(toggleNavigation),
  dispatchCloseNavigation: b.dispatch(closeNavigation),

to

  commitOpenState: b.commit(setOpenState, 'commitOpenState'),

  dispatchToggleNavigation: b.dispatch(toggleNavigation, 'dispatchToggleNavigation'),
  dispatchCloseNavigation: b.dispatch(closeNavigation, 'dispatchCloseNavigation'),
biohazard999 commented 5 years ago

@rugia813 Thanks! That did the trick. For minification in production i use:

module.exports = {
  // Fix Vuex-typescript in prod: https://github.com/istrib/vuex-typescript/issues/13#issuecomment-409869231
//and Fix vuex-typex in prod https://github.com/mrcrowl/vuex-typex/issues/22
  configureWebpack: (config) => {
    if (process.env.NODE_ENV === 'production') {
      config.optimization.minimizer[0].options.terserOptions = Object.assign(
        {},
        config.optimization.minimizer[0].options.terserOptions,
        {
          ecma: 5,
          compress: {
            keep_fnames: true,
          },
          warnings: false,
          mangle: {
            keep_fnames: true,
          },
        },
      );
    }
  },
}
mrcrowl commented 5 years ago

Yes, terser is the way to go for minification.