Nuxt.js: Use babel-polyfill

Created on 11 Apr 2017  路  7Comments  路  Source: nuxt/nuxt.js

As per this issue babel/babel#3825, babel-polyfill is most useful for applications, so that it can have as close as possible to a real ES6 environment, since a limitation of
babel-runtime is that it does not work with certain parts of ES6, such as certain instance methods.

Babel-preset-vue-app cannot modify the entry point, so it can not have babel-polyfill preconfigured https://github.com/vuejs/babel-preset-vue-app/issues/5.

Is there a safe way to extend the Nuxt's entry to include babel-polyfill?

Ideally, since Nuxt doesn't give access to the webpack template itself and only provides the option of extending it, it would be best to have the recommended defaults.

Perhaps it would be better to use babel-preset-vue plugin and have Nuxt setup the runtime/polyfills itself?

This question is available on Nuxt.js community (#c476)
question

Most helpful comment

Why not add to nuxt.config.js?

[...]
  build: {
    vendor: [ 'babel-polyfill', 'eventsource-polyfill' ]
    }
[...]

All 7 comments

Why not add to nuxt.config.js?

[...]
  build: {
    vendor: [ 'babel-polyfill', 'eventsource-polyfill' ]
    }
[...]

If you want to use babel-polyfill with babel-preset-vue-app, I guess you need to set useBuiltIns to true to prevent from being polyfilled twice https://github.com/vuejs/babel-preset-vue-app#usebuiltins

I was having similar problems here for IE11, I wanted to use the vendor solution for loading the polyfill, however this doesn't work properly for generated sites鈥擨 ended up adding via the vue-meta facilities

{ 
head: {
    script: [
      { src: 'polyfill.min.js' }
    ]
}}

There should be a better way to do this, no?

@xemoka Did you ever figure out a better way?

@danielpost Unfortunately the client decided to scale back the end deliverables, I haven't had a chance to revisit this again.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

msudgh picture msudgh  路  3Comments

maicong picture maicong  路  3Comments

mattdharmon picture mattdharmon  路  3Comments

VincentLoy picture VincentLoy  路  3Comments

vadimsg picture vadimsg  路  3Comments