toonvanstrijp / nestjs-i18n

The i18n module for nestjs.
https://nestjs-i18n.com
Other
646 stars 111 forks source link

nest build command, randomly choose to build or not the i18n folder. #575

Open JuanPedroPontVerges opened 1 year ago

JuanPedroPontVerges commented 1 year ago

Describe the bug

This has been happening for a while now but didnt have time to take care. So everytime i ran nest build, it sometimes build the i18n into the dist folder, and some other, it doesnt build it, so at the time of running up the built proyect, it throws an error that it cant find the i18n folder in dist directory.

Same happens everytime i ran nest start. Sometimes it finds the i18n folder, and when it doesn't find it, i have to save any file in my proyect (so the server reloads), and after doing that, it finds the folder and logs does not throw any error

This is how my folder structure looks like: image

This is my nest-cli.json

{
  "collection": "@nestjs/schematics",
  "sourceRoot": "src",
  "compilerOptions": {
    "assets": [
      { "include": "email-templates/*", "outDir": "dist" },
      { "include": "i18n/**/*", "watchAssets": true }
    ]
  }
}

And this is how im importing the I18nModule in my app Imports

app.module.ts

@Module({
  imports: [
    I18nModule.forRoot({
      fallbackLanguage: 'es',
      loaderOptions: {
        path: path.join(__dirname, '/i18n/'),
        watch: true,
      },
      typesOutputPath: path.join(__dirname, '../src/generated/i18n.generated.ts'),
      viewEngine: 'hbs',
      resolvers: [
        new QueryResolver(['lang', 'l'])
      ],
    }),

Reproduction

Dont know how to reproduct the build command

System Info

System:
    OS: Windows 10 10.0.22000
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
    Memory: 4.04 GB / 15.92 GB
  Binaries:
    Node: 16.13.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.3.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.6.1 - ~\AppData\Local\pnpm\pnpm.EXE
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (117.0.2045.47)
    Internet Explorer: 11.0.22000.120

Used Package Manager

yarn

Validations

rubiin commented 1 year ago

For reproduction , you could share a repo with the minimal config that causes the bug

anotheri commented 8 months ago

and is there a way to trigger the types generation explicitly via nest-cli?

rubiin commented 8 months ago

@anotheri there is not AFAIK. Types are autogenerated when the app is launched once. However there is a pr to introduce a cli for this particular purpose

Setitch commented 7 months ago

It is happening often to me (it sadly looks more like nest builder problem than anything other) The easiest is to make your own script for copying other directories

JuanPedroPontVerges commented 7 months ago

@Setitch Have you come up with a script that does that? If you did, can you please share it?

rubiin commented 5 months ago

v11.0.0-beta on version 11.0.0 the runtime build is removed in favor of custom cli so you could build it ahead of run . Check this pr for usage as docs are not completed yet https://github.com/toonvanstrijp/nestjs-i18n/pull/628