Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax error (class Settings { constructor() ...) #35

Closed
OleksiiBrylin opened this issue Nov 15, 2018 · 4 comments
Closed

Syntax error (class Settings { constructor() ...) #35

OleksiiBrylin opened this issue Nov 15, 2018 · 4 comments

Comments

@OleksiiBrylin
Copy link

In nuxt.config.js in the plugins array I try to add a plugin pstephan1187/vue-datatable (it uses ES6 syntax)
After this I get error in IE10, IE11 - Syntax error (class Settings { constructor() ...)

How can I transform ES6 to ES5 in plugins block?

@cretueusebiu
Copy link
Owner

You don't add the package there directly, but define a plugin file for it https://nuxtjs.org/api/configuration-plugins and should work. Also make sure to include the dist file from the package.

@OleksiiBrylin
Copy link
Author

In nuxt.config.js in the plugins array I try to add a plugin pstephan1187/vue-datatable (it uses ES6 syntax). Like this:

module.exports = { plugins: [ '~components/global', '~plugins/axios', '~plugins/datatable', ],
After this It absolutely works in Chrome but I get error in IE10, IE11 - Syntax error (class Settings { constructor() ...)

In /plugins/datatable.js I do
import Vue from 'vue'; import DatatableFactory from 'vuejs-datatable'; Vue.use(DatatableFactory);

This module doesn't use dist file when I import it from 'vuejs-datatable'.
How can I import module with transform to ES2015 from sources (not dist) folder?

@cretueusebiu
Copy link
Owner

You have to extend the build rules and tell it to also include that library. Check the Nuxt docs.

@OleksiiBrylin
Copy link
Author

You are right! Thank you a lot!

I resolved the problem nuxt.config.js

    build: {  
    extend (config, { isServer}) {  
        config.module.rules.push({  
            test: /\.js$/,
            include: [
                path.resolve(__dirname, '../node_modules/vuejs-datatable/')
            ],
            loader: 'babel-loader',
            options: this.getBabelOptions({ isServer })
        })
    },

and this path.resolve(__dirname, '../node_modules/vuejs-datatable/') should be right path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants