Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tsx - isTsNode #107

Open
reslear opened this issue Apr 4, 2024 · 3 comments
Open

tsx - isTsNode #107

reslear opened this issue Apr 4, 2024 · 3 comments

Comments

@reslear
Copy link

reslear commented Apr 4, 2024

I've identified an issue with the isTsNode function, which seems to be dependent on another TypeScript compilation library. When running without ts-node, errors occur, especially with .tsx files.

export const isTsNode = (): boolean => {
const symbol = Symbol.for('ts-node.register.instance');
return !!(process as any)[symbol] || !!process.env.TS_NODE_DEV;

To fix this:

  1. Update isTsNode to check variables and file types, including .cts and .mts.

Temporary fix:

TS_NODE_DEV=1 dotenv -c -- pnpm tsx ./migrations/config.ts up

This ensures compatibility while we address the underlying problem.

@mycodeself
Copy link
Owner

Hey @reslear, is this not something can be solve using the glob pattern option?

@gustawdaniel
Copy link
Contributor

Can you add this trick with

TS_NODE_DEV=1

for tsx to README or add support for tsx?

Tsx becoming more and more popular, so this problem will be blocker for many devs if will remain undocumented.

https://www.npmjs.com/package/tsx

@prenaissance
Copy link

Alternatively, I use this field in the config:

globPattern: "**/*.ts"

and run the command with:

{
   "migration": "tsx --env-file=.env ./migrations/config.ts",
   "migration:up": "pnpm migration up",
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants