vuetify-module icon indicating copy to clipboard operation
vuetify-module copied to clipboard

Some polyfill is not added when the tree shaking is disabled

Open kimamula opened this issue 5 years ago • 4 comments

Module version

Describe the bug

When the tree shaking is disabled (i.e., process.env.NODE_ENV !== 'production' or treeShake is set to false), some polyfill is not added to the bundle, resulting in TypeError: Object doesn't support property or method 'cbrt' error in IE11 (The error message indicates that the polyfill for Math.cbrt() is not added but I'm not sure if there are any other missing polyfills).

To Reproduce

Steps to reproduce the behavior:

  1. Clone https://github.com/kimamula/nuxt-vuetify-treeshake-false
  2. yarn && yarn dev
  3. Access http://localhost:3000/ with IE11

Expected behavior

All required polyfills are added to the bundle.

kimamula avatar Oct 07 '20 12:10 kimamula

The reason why polyfills are added correctly when tree shaking is enabled is that vuetify/lib is pushed to build.transpile here.

When I added the following in nuxt.config.js in https://github.com/kimamula/nuxt-vuetify-treeshake-false, I confirmed that polyfills are added correctly and the app worked on IE11.

build: {
  transpile: ['vuetify']
}

However, when I tried the same setting with my real app, it did not work because of this error. I'm sorry but I haven't succeeded to create a simple reproduction for this problem.

kimamula avatar Oct 07 '20 12:10 kimamula

@kimamula Try adding 'vuetify/lib' to transpile array, instead of just 'vuetify'.

disjointed avatar Oct 13 '20 10:10 disjointed

Also, I've noticed this problem only happens when using "Universal" mode in Nuxt. "SPA" mode works just fine, with or without treeShake.

disjointed avatar Oct 13 '20 10:10 disjointed

@disjointed Thanks for your comments.

@kimamula Try adding 'vuetify/lib' to transpile array, instead of just 'vuetify'.

I forgot to mention that I had already confirmed that did not work, i.e., that resulted in TypeError: Object doesn't support property or method 'cbrt' error in IE11.

Also, I've noticed this problem only happens when using "Universal" mode in Nuxt. "SPA" mode works just fine, with or without treeShake.

I observed the same problem when using "SPA" mode as well.

I confirmed these behaviors using https://github.com/kimamula/nuxt-vuetify-treeshake-false. If you could share your app you confirmed the behaviors with, that would be really helpful.

kimamula avatar Oct 13 '20 11:10 kimamula