-
-
Notifications
You must be signed in to change notification settings - Fork 800
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
[legacy-framework] Add support for blitz.config.ts
#1325
Conversation
A couple of things to note:
|
Size Change: +1.35 kB (0%) Total Size: 193 kB
ℹ️ View Unchanged
|
Sweet thanks for looking at this. I would recommend having a look at the workoptimizer test https://github.com/blitz-js/blitz/blob/5572c9c3239b7beb001cec1914e4b59fe5ee10c2/packages/file-pipeline/src/helpers/work-optimizer/work-optimizer.test.ts and writing one for the config stage. The other stages need to be done too but that is out of the scope of this PR. |
Not sure I understand what is going on here? Sounds to me like we probably shouldn't have to do this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet!!
First thing: we must also be able to import other .ts
files into blitz.config.ts
and have it work correctly. I don't think this will work right now with this pr, right? Because for this to work, we basically need to run webpack on the config file to bundle it, right? I should have thought about and mentioned this in slack when we were talking about just using babel.
As for where to put the built file... My first thought is to put it at .next/__blitz.config.js
because that's where we are bundling the db/index.ts
file to as .next/__db.js
. We can ensure that the .js blitz config always lives there, and then we can change @blitzjs/config
to read from there. And then also the config stage would need changed to read from there too.
packages/server/package.json
Outdated
@@ -29,6 +29,7 @@ | |||
"module": "dist/server.esm.js", | |||
"types": "dist/packages/server/src/index.d.ts", | |||
"dependencies": { | |||
"@babel/core": "7.11.6", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use a ^
range here so that we use the same version Next.js. Or, even we could maybe remove it from here since next includes it.
ncc would be the easy way to bundle |
if (isBlitzTsConfigPath(file.path)) { | ||
const res = await bundle(file.path, { | ||
quiet: true, | ||
externals: ["@blitzjs/server", "@next/bundle-analyzer"], // FIXME: Figure out why this wouldn't work? Do we need to bundle everything? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what to do here. ncc
failed to bundle these 3rd party modules, although it shouldn't have to because they're already built. ncc
doesn't seem to provide a nice way to do this (vercel/ncc#409) so I'm considering:
- Maintain this list manually, thinking that there shouldn't be a lot of 3rd party modules that the config will be expected to import (mostly just auth stuff?)
- Programmatically get all installed modules with
yarn list --json
or similar
What are your thoughts? @flybayer
@jamiedavenport sorry I haven't had time to dig into this yet. Had some other life stuff interfere this week and some high priority bugs I'm working through. I'll get back to this as soon as I can. |
@jamiedavenport yeah, so sorry. I've been focused 100% on fixing a bunch of bugs for official beta status, and new features are a bit lower priority than that. This week I'm very busy and have vacation, so hopefully I can give this full attention in first part of December. |
I need to really think through all potential edge cases and also test in multiple production deployments (Vercel and Render). |
NOTE: also need to update recipes to work with |
@jamiedavenport I'm really sorry I let this drop. I think subconsciously I knew ncc wasn't the right approach here (but at the time I didn't understand some of these tools well enough to know what else to do). I've now implemented this using esbuild in a much cleaner way: #2283 I really, really appreciate the effort you put into this. I know it's a bummer to put a lot of effort into something that doesn't even get used. So for that I'm sorry 🙏 |
blitz.config.ts
blitz.config.ts
Closes: blitz-js/legacy-framework#632
What are the changes and their implications?
Checklist