tada5hi / typeorm-extension

This library provides utitlites to create & drop the database, seed the database and apply URL query parameter(s).
https://typeorm-extension.tada5hi.net
MIT License
214 stars 34 forks source link

Bug: factory not found on runtime #1019

Open simon-tannai opened 3 months ago

simon-tannai commented 3 months ago

Versions

Reproduction

Additional Details Commands: ```JSON { "cli": "node ./dist/apps/cli/main", "cli:dev": "ts-node ./apps/cli/src/main" } ``` Datasource: ```typescript private readonly options: DataSourceOptions & SeederOptions = { ...databaseConfig, factories: [join(__dirname, '..', '..', '..', '..', 'apps', 'my-app', 'src', '**', '*.factory{.ts,.js}')], seeds: [MainSeeder], } ```

Steps to reproduce

I'm using nest-commander to create a CLI application to seed a database into a production-like environment.

In dev' env', the seeding is working well. But in production-like env' (after TS build), it's not working.

It looks typeorm-extension is not working without ts-node ?

What is Expected?

Running seeds into production-like environment without ts-node.

What is actually happening?

Error: No seeder factory is registered for the entity: MyEntity
simon-tannai commented 3 months ago

In the other hand, it's working well when I'm importing manually all the entities and factories:

  private readonly options: DataSourceOptions & SeederOptions = {
    ...databaseConfig,
    entities: [
      MyFirstEntity,
      [...]
      MySecondEntity,
    ],
    factories: [
      MyFirstFactory,
      [...]
      MySecondFactory,
    ],
    seeds: [MainSeeder],
  }
IB3N commented 3 months ago

+1

tada5hi commented 3 months ago

Can you please provide a repository for reproduction.