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

chore: Create a prebuild script to generate next data. #5461

Merged

Conversation

Harkunwar
Copy link
Contributor

Description

Currently we're generating next-data at the lint stage, which isn't the right place. This PR moves that generation to a prebuild stage.

Related Issues

Fixes #5455

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run npx turbo lint to ensure the code follows the style guide. And run npx turbo lint:fix to fix the style errors if necessary.
  • I have run npx turbo format to ensure the code follows the style guide.
  • I have run npx turbo test to check if all tests are passing, and/or npx turbo test:snapshot to update snapshots if I created and/or updated React Components.
  • I've covered new added functionality with unit tests if necessary.

@Harkunwar Harkunwar requested a review from a team as a code owner July 2, 2023 02:40
@vercel
Copy link

vercel bot commented Jul 2, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nodejs-org ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 2, 2023 2:45am
nodejs-org-stories ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 2, 2023 2:45am

@vercel vercel bot temporarily deployed to Preview – nodejs-org July 2, 2023 02:41 Inactive
Copy link
Member

@ovflowd ovflowd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@vercel vercel bot temporarily deployed to Preview – nodejs-org July 2, 2023 02:44 Inactive
@vercel vercel bot temporarily deployed to Preview – nodejs-org-stories July 2, 2023 02:45 Inactive
@Harkunwar Harkunwar merged commit 6a0b0b5 into nodejs:main Jul 2, 2023
@Harkunwar
Copy link
Contributor Author

Merged this PR as it is simple enough and unblocks another PR.

@Harkunwar Harkunwar deleted the chore/create-prebuild-script-next-data branch July 2, 2023 02:53
@ovflowd
Copy link
Member

ovflowd commented Jul 2, 2023

Just to double-check @Harkunwar you tested this command indeed gets invoked before build, right?

@Harkunwar
Copy link
Contributor Author

Harkunwar commented Jul 2, 2023

@ovflowd Yes, I did check and it was working.

I just also realized and prebuild is a special script keyword and is executed automatically when we run npm run build or npx turbo build.

So now it's executing twice since it's also part of the build script. Should we change the name of the script from prebuild to something else such as build:nextData so there's no uncertainty that prebuild will always execute before build, or should we just remove it from the build script, since it automatically executes?

@ovflowd
Copy link
Member

ovflowd commented Jul 2, 2023

I know that prebuild is a special keyword. Any script that starts with “pre” or “post” and as a suffix of another script name, will then either run before or after.

My intent here was to check if the script is generating the files as expected 👀

@ovflowd
Copy link
Member

ovflowd commented Jul 2, 2023

I don’t get it why it would be executing twice. Where is it being invoked for the 2nd time?

@Harkunwar
Copy link
Contributor Author

@ovflowd Yes, the files are being generated.

It's being invoked twice because of this change. build is calling prebuild. I'll make a PR to remove this redundant call.

"build": "cross-env NODE_NO_WARNINGS=1 npm run prebuild && next build",

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

Successfully merging this pull request may close these issues.

2 participants