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 next.config.js validation to turbopack #3105

Closed
wants to merge 3 commits into from

Conversation

ForsakenHarmony
Copy link
Contributor

No description provided.

@vercel
Copy link

vercel bot commented Dec 21, 2022

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

Name Status Preview Comments Updated
examples-cra-web 🔄 Building (Inspect) Jan 10, 2023 at 3:58PM (UTC)
examples-native-web 🔄 Building (Inspect) Jan 10, 2023 at 3:58PM (UTC)
turbo-site ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Jan 10, 2023 at 3:58PM (UTC)
turbo-vite-web 🔄 Building (Inspect) Jan 10, 2023 at 3:58PM (UTC)
6 Ignored Deployments
Name Status Preview Comments Updated
examples-basic-web ⬜️ Ignored (Inspect) Jan 10, 2023 at 3:58PM (UTC)
examples-designsystem-docs ⬜️ Ignored (Inspect) Jan 10, 2023 at 3:58PM (UTC)
examples-kitchensink-blog ⬜️ Ignored (Inspect) Jan 10, 2023 at 3:58PM (UTC)
examples-nonmonorepo ⬜️ Ignored (Inspect) Jan 10, 2023 at 3:58PM (UTC)
examples-svelte-web ⬜️ Ignored (Inspect) Jan 10, 2023 at 3:58PM (UTC)
examples-tailwind-web ⬜️ Ignored (Inspect) Jan 10, 2023 at 3:58PM (UTC)

@ForsakenHarmony
Copy link
Contributor Author

ForsakenHarmony commented Dec 21, 2022

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 21, 2022

⚠️ CI failed ⚠️

The following steps have failed in CI:

  • Rust lints
  • Rust tests
  • Rust benchmark tests

See workflow summary for details

nextConfig.rewrites = await nextConfig.rewrites?.();

nextConfig.generateBuildId = await nextConfig.generateBuildId?.();
nextConfig.headers = await nextConfig.headers?.();
Copy link
Contributor

Choose a reason for hiding this comment

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

the loadCustomRoutes from next/dist/lib/load-custom-routes will perform some validation and loading for headers/redirects/rewrites.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not entirely sure what you're telling me here, is that a function I should use?

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, TraceRawVcs)]
#[serde(rename_all = "camelCase")]
struct OnDemandEntriesConfig {
max_inactive_age: f64,
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these floats or u64s?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess JS can always provide Infinity there, hence we treat any number as a f64.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, ideally these would be u64, but for JS compat I've put them in here as f64 for now

@jridgewell
Copy link
Contributor

I admittedly didn't fully review every line.

@alexkirsz
Copy link
Contributor

alexkirsz commented Dec 22, 2022

I'm also validating next.config.js in #3071 (basePath specifically) so that will likely cause a conflict.

@@ -11,9 +11,11 @@ bench = false
[dependencies]
anyhow = "1.0.47"
auto-hash-map = { path = "../auto-hash-map" }
crossterm = "0.25"
Copy link
Contributor

Choose a reason for hiding this comment

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

Put this dependency at the workspace level? We now use it for both turbopack-cli-utils and this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there are a lot of dependencies that are used across multiple crates but are not at the workspace level, anyhow above is a good example

Should we move all of those to the workspace?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. I created WEB-174 a while back to tackle this.

crates/next-core/src/next_config.rs Outdated Show resolved Hide resolved
// default to 50MB limit
isr_memory_cache_size: Some(50.0 * 1024.0 * 1024.0),
// default to 128KB
large_page_data_bytes: Some(128.0 * 1000.0),
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
large_page_data_bytes: Some(128.0 * 1000.0),
large_page_data_bytes: Some(128.0 * 1024.0),

Unless it was also defined this way in JS land?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, TraceRawVcs)]
#[serde(rename_all = "camelCase")]
struct OnDemandEntriesConfig {
max_inactive_age: f64,
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess JS can always provide Infinity there, hence we treat any number as a f64.

"experimental.serverComponentsExternalPackages",
];

pub async fn validate_next_config(
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to be pub?

Suggested change
pub async fn validate_next_config(
async fn validate_next_config(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope 👍

pub images: ImageConfig,

#[serde(flatten)]
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a cool use of flatten.

@ForsakenHarmony
Copy link
Contributor Author

closing for now

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.

3 participants