Some polyfill is not added when the tree shaking is disabled
Module version
- [email protected]
- @nuxtjs/[email protected]
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:
- Clone https://github.com/kimamula/nuxt-vuetify-treeshake-false
yarn && yarn dev- Access http://localhost:3000/ with IE11
Expected behavior
All required polyfills are added to the bundle.
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 Try adding 'vuetify/lib' to transpile array, instead of just 'vuetify'.
Also, I've noticed this problem only happens when using "Universal" mode in Nuxt. "SPA" mode works just fine, with or without treeShake.
@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.