tada5hi/typeorm-extension

Bug: Seeder Broke in version 2.5.0

singhtal opened this issue · 4 comments

Versions

  • Node: 18
  • OS: MAC OS
  • Version: Latest (was working fine with v2.4.1)

Steps to reproduce

import { DataSource } from 'typeorm';
import {createDatabase, runSeeders, SeederOptions} from 'typeorm-extension';

...
<-- fetch datasource from seeder file and pass in function like below -->

try {
  await runSeeders(datasource);
}

What is Expected?

Should seed the tables with data

What is actually happening?

TypeError: clazz.run is not a function\n at runSeeder
typeorm-extension/dist/seeder/module.js:97:18

Please note that the seeding was working fine with 2.4.1 and suddenly after the update to latest version, it has started throwing the error. I have not changed anything in the seed file.

Update - This is possibly due to this Change of Lazy transpiling of seeder (5d092ad)

Can you provide a repo/code snippet for reproduction ?

@tal1992 is your seeder class a named oder default export?

@tada5hi it looks like this -

import {Seeder} from 'typeorm-extension';
import {DataSource} from 'typeorm';
import {myEntity} from '../entity/MyEntity;
import {mySeedData} from '../data/MySeedData.seed';

export default class MySeeder implements Seeder {
  public async run(dataSource: DataSource): Promise<void> {
	// some business logic
	repository.insert(mydata);

  }
}

@tada5hi it looks like this -

import {Seeder} from 'typeorm-extension';
import {DataSource} from 'typeorm';
import {myEntity} from '../entity/MyEntity;
import {mySeedData} from '../data/MySeedData.seed';

export default class MySeeder implements Seeder {
  public async run(dataSource: DataSource): Promise<void> {
	// some business logic
	repository.insert(mydata);

  }
}

A minimal repo for repoduction would be realy great, since i unfortunately can not replicate the error 😔