Coder Social home page Coder Social logo

Comments (21)

ofhouse avatar ofhouse commented on July 19, 2024 1

Hi, thanks for reaching out!

Blitz.js is on my ToDo-list of things to try out.
I don't know how much of the build process Blitz.js is customizing.

We use a customized version of the tool that Vercel is using for its own deployments, so when it works on Vercel the chances are not too bad that it also works with this module.

But you can go ahead and try it out by yourself.
I will definitely try it out in a few weeks and maybe add an example project to the repo then.

from terraform-aws-next-js.

lcswillems avatar lcswillems commented on July 19, 2024

Thank you for your answer!

To compile a Blitz.js project, I have to execute blitz build. I believe the build output is then a normal Next.js build output. How could I use your tool then?

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on July 19, 2024

The underlying builder overrides the build command.
I did not wrote the builder by myself, but a comment here indicates that Blitz was already taken into consideration:
https://github.com/dealmore/vercel/blob/5dbf567e23bb21803e2dede7948226d50628de03/packages/now-next/src/index.ts#L146

What happens when you run npx tf-next build in your Blitz project?
This should only add a .next-tf with the build output to your project, so no deployment happens when you execute the command.

from terraform-aws-next-js.

lcswillems avatar lcswillems commented on July 19, 2024

Thank you for your answer! I missed it.

So I tried npx tf-next build and it gives me this:

$ blitz build && node extension/build.js
You are using beta software - if you have any problems, please open an issue here:
      https://github.com/blitz-js/blitz/issues/new/choose

◢ CompilingError [NextConfigSupportError]: Blitz does not support next.config.js. Please rename your next.config.js to blitz.config.js
    at createStageConfig (/tmp/tmp-2670-Yl5ZrCXKDZQ9/node_modules/@blitzjs/server/dist/server.cjs.development.js:1955:15)
    at /tmp/tmp-2670-Yl5ZrCXKDZQ9/node_modules/@blitzjs/file-pipeline/dist/file-pipeline.cjs.development.js:1756:12
    at Array.map (<anonymous>)
    at createPipeline (/tmp/tmp-2670-Yl5ZrCXKDZQ9/node_modules/@blitzjs/file-pipeline/dist/file-pipeline.cjs.development.js:1755:34)
    at /tmp/tmp-2670-Yl5ZrCXKDZQ9/node_modules/@blitzjs/file-pipeline/dist/file-pipeline.cjs.development.js:1841:43
    at new Promise (<anonymous>)
    at _callee$ (/tmp/tmp-2670-Yl5ZrCXKDZQ9/node_modules/@blitzjs/file-pipeline/dist/file-pipeline.cjs.development.js:1832:20)
    at tryCatch (/tmp/tmp-2670-Yl5ZrCXKDZQ9/node_modules/@blitzjs/file-pipeline/dist/file-pipeline.cjs.development.js:150:19)
    at Generator.invoke [as _invoke] (/tmp/tmp-2670-Yl5ZrCXKDZQ9/node_modules/@blitzjs/file-pipeline/dist/file-pipeline.cjs.development.js:367:24)
    at Generator.next (/tmp/tmp-2670-Yl5ZrCXKDZQ9/node_modules/@blitzjs/file-pipeline/dist/file-pipeline.cjs.development.js:203:23)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Build failed:
NowBuildError: Command "yarn run build" exited with 1
    at ChildProcess.<anonymous> (/home/lcswillems/.npm/_npx/2670/lib/node_modules/tf-next/node_modules/@vercel/build-utils/dist/index.js:29311:20)
    at ChildProcess.emit (events.js:314:20)
    at ChildProcess.EventEmitter.emit (domain.js:483:12)
    at maybeClose (internal/child_process.js:1022:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5) {
  hideStackTrace: true,
  code: 'BUILD_UTILS_SPAWN_1',
  link: undefined,
  action: undefined
}

It seems the blitz.config.js file I have in my repository is taken into account. How could I fix it?

Maybe there is this error because your repo is 138 commits behind Vercel's repo? I have checked their code and it seems quite different. For example, the now-next package you sent me the code from doesn't exist anymore.

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on July 19, 2024

Yeah, as you have already seen in #36 Vercel stopped developing the now-next package in the public.
It still exists and is used by Vercel internally but we have no longer access to the latest updates 🤷

We will eventually fork it and integrate it into the repo but it's not the top priority at the moment.
I am actually not sure how long a better Blitz.js integration would last, since the project recently announced that they will use a fork of Next.js in the future: blitz-js/blitz#1990

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on July 19, 2024

However Vercel is currently using now-next (now renamed as @vercel/next) for building Blitz.js so I guess they applied some fixes to make it work with a newer version:
https://github.com/vercel/vercel/blob/7275878b2bd1ecbaca6e2b6264fc71017eb78924/packages/frameworks/src/frameworks.ts#L32

from terraform-aws-next-js.

lcswillems avatar lcswillems commented on July 19, 2024

Thank you for all these details!

from terraform-aws-next-js.

flybayer avatar flybayer commented on July 19, 2024

Hey, creator of Blitz here. We have forked next.js and are working on integrating the fork into Blitz. So some things will change about the build. There will no longer be an intermediary .blitz/build folder. But it will compile to the same .next format as it does now, and same as next.js.

from terraform-aws-next-js.

lcswillems avatar lcswillems commented on July 19, 2024

That is great!! And will the blitz.config.js be converted into a next.config.js? This is the reason I can't use this repo for the moment. I would love to be able to deploy Blitz.js to AWS Lambda / S3.

from terraform-aws-next-js.

flybayer avatar flybayer commented on July 19, 2024

No, it will stay as blitz.config.js

from terraform-aws-next-js.

lcswillems avatar lcswillems commented on July 19, 2024

Ok! I will try to find a workaround

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on July 19, 2024

I think a simple workaround does not exist.
Internally the builder is currently always adding a next.config.js to the project, so a solution definitely requires changes in the builder.

I will try to move the integration of the builder/runtime (that is currently in the forked vercel repo) into the repository forward, so that debugging/testing becomes simpler.

Edit: Okay, it's a little bigger than I thought 🙈 #77

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on July 19, 2024

Ok, got some time to look into this.
The fix for using blitz.config.js instead of next.config.js is really simple: https://github.com/dealmore/terraform-aws-next-js/pull/84/files#diff-7dee855b08d71479aa793b4b04ff8dd181f6283fff699b469ebe30244fd3e77f

Unfortunately Prisma makes some problems (Can be workarounded by using tf-next build --skipDownload flag) which was also reported in #73.
Will take another look with the Prisma related issue before releasing a new version of tf-next.

from terraform-aws-next-js.

lcswillems avatar lcswillems commented on July 19, 2024

Thank you for your help!!

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on July 19, 2024

Turns out Blitz.js already has a fix for this built-in, so we don't need a special handling in our builder for it:
https://github.com/blitz-js/blitz/blob/6cc4fb6c5996570b0040a7f968840e0f7b1d2316/packages/server/src/stages/config/index.ts#L59

The problem is that the fix was not triggered, because it needs the environment variable NOW_BUILDER='1' to detect whether the fix should be enabled.
Funnily enough Prisma also uses the same workaround for applying a special fix for the vercel build (#73 (comment)).
So setting the environment variable correctly should solve both issues.

This could be done manually but I prepare #85 which ensures that the variable is correctly set when running the build command.

from terraform-aws-next-js.

lcswillems avatar lcswillems commented on July 19, 2024

Wow! Thank you so much for this analysis!!

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on July 19, 2024

Just released [email protected] which should fix the issue.
Upgrading tf-next in your package.json should be enough to make it work, no update of the Terraform module required.

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on July 19, 2024

Strange, tested it and it runs the prisma generate command correctly from the postinstall script, but it still does not create the typings. 😕

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on July 19, 2024

Okay, found the issue, the prisma generate was executed in the wrong directory 🤦
Preparing a fix in #87 which should fix it finally.

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on July 19, 2024

Ok, just tested it with [email protected] and Blitz.js is now correctly deployed.
Closing it for now.

from terraform-aws-next-js.

lcswillems avatar lcswillems commented on July 19, 2024

Thanks a lot!!

from terraform-aws-next-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.