How to add one-off scripts to a T3 app

I started my project with create-t3-app a long time ago. i see that they've added the new t3 env-next module for managing environment variables in a typesafe way and i decided to switch to it. However, this seems to have broken my scripts directory which can no longer run one-off db scripts because its now importing a .mjs module. What is the recommended way to run one-off typescript scripts in a ct3a project?
4 Replies
Matvey
Matvey16mo ago
it was .mjs before you can import .mjs module from typescript
Tom
TomOP16mo ago
if i have a folder at the root level named /scripts what do i need to do to get those scripts to run? I guess the big things are: 1) what do i need in terms of tsconfig? 2) what do i need in terms of package.json? 3) how should i import the .mjs file?
Matvey
Matvey16mo ago
just import it like this
import env from '../src/env.mjs';
import env from '../src/env.mjs';
use tsx to run it, it should just work
Tom
TomOP16mo ago
ill give it a shot ty
Want results from more Discord servers?
Add your server