Laravel-mix: Require modules not working at v2.1

Created on 14 Mar 2018  路  11Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: 2.1.0
  • Node Version: 9.2.0
  • NPM Version: 5.6.0
  • OS: Windows 10

Description:

After upgrading to 2.1 it seems like Vue registered components are completely ignored outputing errors like "Property or method "xxx" is not defined on the instance but referenced during render". Registration is done by requiring .vue files like below from within app.js

Vue.component('login', require('./pages/Login.vue'))

Login.vue

<script>
export default {
    data() {
        return {
            model: {
                identity: '',
                password: '',
                remember: false,
            },
        };
    }
};
</script>

When registered inline it works

Vue.component('login', {
    data() {
        return {
            model: {
                identity: '',
                password: '',
                remember: false,
            },
        };
    }
})

Reverting to version 2.0 it works again.

Most helpful comment

/cc @JeffreyWay

All 11 comments

Here is the workaround

Vue.component('login', require('./pages/Login.vue').default)

Something is wrong in vue-loader configs.

@ruchern
Any way to restore old behaviour ?
How to return default by default?

https://github.com/vuejs/vue-loader/releases

I am looking through this release to see what are the breaking changes.


One of the breaking changes

esModules option has been removed. Built module is now always exposed as an ES module.

I think OP got to try using the ES6 import method

import Foo from '@/components/Foo`

Vue.component('foo', Foo)

Laravel mix need to remove this old config then

https://github.com/JeffreyWay/laravel-mix/blob/master/src/config.js#L107

And force everyone to go to ES6 modules.

/cc @JeffreyWay

Ugh, I can鈥檛 force a breaking change like that for this release. We鈥檒l have to wait for a major release.

Can someone submit a PR that changes the vue-loader requirement back to what it was before?

@JeffreyWay I can submit a PR for that, but I will have to do it on the weekends where I have some spare time for myself as per discussed in #1526

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rlewkowicz picture rlewkowicz  路  3Comments

wendt88 picture wendt88  路  3Comments

dtheb picture dtheb  路  3Comments

mstralka picture mstralka  路  3Comments

Bomavi picture Bomavi  路  3Comments