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

Add support for blitz.config.ts #632

Closed
flybayer opened this issue Aug 18, 2020 · 3 comments · Fixed by blitz-js/blitz#2283
Closed

Add support for blitz.config.ts #632

flybayer opened this issue Aug 18, 2020 · 3 comments · Fixed by blitz-js/blitz#2283

Comments

@flybayer
Copy link
Member

What do you want and why?

I want to transpile our config file so that we can use Typescript with blitz.config.ts. One big reason for this is currently our built in session management is configured in this file. And for people not using prisma, they need to define their database access hooks to get/set the session in their DB. The straightforward way to do this would be import db from ./db/index.ts. But currently that doesn't work since blitz.config.js isn't transpiled.

Possible implementation(s)

I think this might be as simple as adding config to with-blitz.ts. Something like this:

"../../_blitz.config.js": "./blitz.config",

And then change our getConfig function to use _blitz.config.js.

And also change this line to use _blitz.config.js

@jamiedavenport
Copy link
Contributor

Could I work on this? 🥺

@jamiedavenport
Copy link
Contributor

I think this might be as simple as adding config to with-blitz.ts. Something like this:

If only things were that simple 😢

Looks to me as though the blitz.config.ts file would already need to be transpiled before Webpack runs, since the generated next.config.js file depends on it and Next doesn't support next.config.ts (vercel/next.js#5318)

https://github.com/blitz-js/blitz/blob/canary/packages/server/src/stages/config/index.ts#L45

So my current plan of action is to add a transpilation step using either Typescript or Babel into the config stage. Their main reason for not supporting next.config.ts is performance, is that something that we need to be worried about @flybayer @ryardley

@flybayer
Copy link
Member Author

@jamiedavenport the perf argument is pretty lame since it's one single file compared to the actual app build that's many files.

Yeah, adding this to the server config stage sounds perfect.

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