Typescript: Nuxt typescript. Ignore vuex *.ts files on store folder

Created on 10 Nov 2019  路  5Comments  路  Source: nuxt/typescript

Version

v2.10.2

Reproduction link

https://github.com/loha/nuxt_2.10.2_vuex_bug

Steps to reproduce

  1. Clone github repository: https://github.com/loha/nuxt_2.10.2_vuex_bug;
  2. yarn install or npm isntall;
  3. yarn run dev or npm run dev.

What is expected ?

Nuxt correctly working with *.ts and *.js files in /store folder. Vuex work correctly. Project work like in https://github.com/nuxt-community/typescript-template.

What is actually happening?

If add in nuxt typescript project backend framework like koa.js of express.js nuxt ignore *.ts files in /store folder. Sometimes ignore *.js files too. For example, took the project https://github.com/nuxt-community/typescript-template and added the framework koa.js.

Additional comments?

OS: Ubuntu 16.04 LTS
Node.js: v12.13.0

This bug report is available on Nuxt community (#c10012)
bug transfered build

Most helpful comment

Try adding this to your nuxt.config:

  build: {
    additionalExtensions: ['ts', 'tsx'],
  },

All 5 comments

Try adding this to your nuxt.config:

  build: {
    additionalExtensions: ['ts', 'tsx'],
  },

I have the same problem. In addition to build.additionalExtensions, I also had to set extensions. Without it, the .ts suffix wouldn't get removed from the module name.

{
  extensions: ['ts', 'tsx'],
  build: {
    additionalExtensions: ['ts', 'tsx']
  }
}

Could this be made default, please? Also, is the difference between the two settings documented somewhere? Why are there two anyway?

@nuxt/typescript-build should be registering these options in nuxt.config (reference).

@kevinmarrec Does this raise an issue with @nuxt/typescript-build, or is this a peculiarity with programmatic use of Nuxt?

@danielroe Thank you very much for your reply. Indeed, when adding additionalExtensions: ['ts', 'tsx'] , everything works. It would be nice if the Nuxt developers fixed it and that would be the default. When using the package @nuxt/typescript of an earlier version Nuxt(2.8.1), such problems do not arise.

@loha Having looked at your project, it is also fixed by changing the server code to:

  // The next line needs to be run in dev as well as production.
  await nuxt.ready()
  if (config.dev) {
    const builder = new Builder(nuxt)
    await builder.build()
  }

I think it would be worth having some documentation on this and will prepare a PR.

Was this page helpful?
0 / 5 - 0 ratings