nx-tools icon indicating copy to clipboard operation
nx-tools copied to clipboard

[@nx-tools/nx-prisma] Seed command can only be run using ts-node

Open kschroeder-of opened this issue 1 year ago • 2 comments

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! 🎉

kschroeder-of avatar Aug 29 '23 15:08 kschroeder-of

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.

robert-king avatar Nov 06 '23 02:11 robert-king

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

robert-king avatar Dec 07 '23 00:12 robert-king

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/

Lehoczky-peakfs avatar Apr 09 '24 19:04 Lehoczky-peakfs