nx-tools
nx-tools copied to clipboard
[@nx-tools/nx-prisma] Seed command can only be run using ts-node
When using the prisma-seed
executor ts-node
is the default and non overridable tool used to run the seeding.
To leverage other tools e.g. scw
to run the seeding a config option should be introduced.
My proposal would be to use ts-node
by default and call the option scriptExecutor
.
I can create a pull request if you agree! 🎉
our problem is we have a seed.ts but it can't import from @my-lib because ts-node doesn't understand the paths from tsconfig.
workaround is to import directly
// eslint-disable-next-line @nx/enforce-module-boundaries import { machineConfigs } from '../../../../../libs/donovan/src/lib/consts/machines'; // todo custom executor // import { machineConfigs } from '@thred/donovan'; // todo custom executor that understands paths
perhaps seeding should be done from a custom application that has a main.ts file thats its own seeder, easy way for an extra entrypoint into the libs that are needed for seeding
our problem is we have a seed.ts but it can't import from @my-lib because ts-node doesn't understand the paths from tsconfig.
This can be solved by using the tsconfig-paths:
// tsconfig.json
{
"ts-node": {
// Do not forget to `npm i -D tsconfig-paths`
"require": ["tsconfig-paths/register"]
}
}
Documentation about this can be found at: https://typestrong.org/ts-node/docs/paths/