Nuxt.js: Coffeescript Vuex silently stop working on 2.5.1

Created on 30 Mar 2019  路  10Comments  路  Source: nuxt/nuxt.js

Version

v2.5.1

Reproduction link

https://github.com/nuxt/nuxt.js/tree/dev/examples/coffeescript

Steps to reproduce

Build project with "nuxt": "2.5.1"

What is expected ?

Vuex that works with Coffeescript, just like on 2.4.5

What is actually happening?

Nothing.

This bug report is available on Nuxt community (#c8960)
bug-report good first issue pending

Most helpful comment

I have a workaround that I published to my CoffeesScript Nuxt module package: https://github.com/BKWLD/nuxt-coffeescript-module/commit/143656e53ffba7b9c2c334a85a0ba8e7f648965b. This fixes this VueX issue for me but doesn't fix the issue with CoffeeScript local modules #5087

All 10 comments

I would also note that if I enable module store in the coffeescript example by adding a file /store/module.coffee

export state = ->
  message: 'Hello CoffeeScript Module Store!'

and try to reference it in pages/index.vue

export default
  components: { Logo }
  computed:
    message: -> @$store.state.module.message

with Nuxt 2.5.1+ I get

ERROR  [Vue warn]: Error in render: "TypeError: Cannot read property 'message' of undefined"

It appears to have broken a little earlier than reported above, I see it broken in 2.5.0. And is still an issue in 2.6.3.

I've been digging into the code and I'm not use exactly where it broke, but I've found changing resolveFiles() to this:

  async resolveFiles(dir, cwd = this.options.srcDir) {
    const extensions = this.supportedExtensions.concat(this.nuxt.options.extensions)
    return this.ignore.filter(await glob(`${dir}/**/*.{${extensions.join(',')}}`, {
      cwd,
      ignore: this.options.ignore
    }))
  }

fixes the issue; the coffeescript store module gets found. What I'm doing is concat-ing the this.nuxt.options.extensions onto the this.supportedExtensions array, which is the only list of extensions currently being considered when resolving store modules.

The above is a clunky solve not worthy of a PR, but should point out the problem is that this.nuxt.options.extensions isn't taken into account when Nuxt looks for store modules. However, this is the practice described in the coffeescript example.

I have a workaround that I published to my CoffeesScript Nuxt module package: https://github.com/BKWLD/nuxt-coffeescript-module/commit/143656e53ffba7b9c2c334a85a0ba8e7f648965b. This fixes this VueX issue for me but doesn't fix the issue with CoffeeScript local modules #5087

@weotch
oh, that's really nice, thanks! I'll try when I get back to the Nuxt

WORKS PERFECTLY FINE !
with 2.6.3

definitely need to add this two lines of code into master branch as fast as possible!

workaround is working like a charm too!

Feel free to create a PR for the example to make it work too, or even to the core :relaxed:

I wasn't sure if my workaround _should_ be the right solve for this ... like, ideally, I feel like Nuxt should use the this.nuxt.options.extensions for the builder.supportedExtensions as well. It wasn't clear to me where the most elegant way to implement this into the core should be, though.

@manniL hey did you fixed coffeescript linter issue of your CI ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bimohxh picture bimohxh  路  3Comments

pehbehbeh picture pehbehbeh  路  3Comments

mattdharmon picture mattdharmon  路  3Comments

nassimbenkirane picture nassimbenkirane  路  3Comments

lazycrazy picture lazycrazy  路  3Comments