nestjs-i18n icon indicating copy to clipboard operation
nestjs-i18n copied to clipboard

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

Open JuanPedroPontVerges opened this issue 1 year ago • 6 comments

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

  • [X] Follow our Code of Conduct
  • [X] Read the Contributing Guide.
  • [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • [X] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • [ ] The provided reproduction is a minimal reproducible of the bug.

JuanPedroPontVerges avatar Oct 03 '23 19:10 JuanPedroPontVerges

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

rubiin avatar Oct 04 '23 06:10 rubiin

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

anotheri avatar Jan 22 '24 14:01 anotheri

@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

rubiin avatar Jan 31 '24 13:01 rubiin

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

Setitch avatar Mar 05 '24 20:03 Setitch

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

JuanPedroPontVerges avatar Mar 06 '24 14:03 JuanPedroPontVerges

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

rubiin avatar Apr 25 '24 08:04 rubiin