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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ default-members = [
"xtask",
]

[profile.release]

[profile.bench]

[profile.dev.package.turbo-tasks-macros]
opt-level = 3

Expand All @@ -86,20 +82,21 @@ opt-level = 3
# Declare dependencies used across workspace packages requires single version bump.
# ref: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#inheriting-a-dependency-from-a-workspace
[workspace.dependencies]
indexmap = { version = "1.9.2" }
# Keep consistent with preset_env_base through swc_core
browserslist-rs = { version = "0.12.2" }
swc_core = { version = "0.53.0" }
testing = { version = "0.31.25" }
swc_emotion = { version = "0.28.9" }
styled_jsx = { version = "0.29.13" }
styled_components = { version = "0.52.13" }
modularize_imports = { version = "0.25.13" }
crossterm = { version = "0.25.0" }
indexmap = { version = "1.9.2" }
mdxjs = { version = "0.1.4" }
modularize_imports = { version = "0.25.13" }
next-dev = { path = "crates/next-dev", version = "0.1.0" }
node-file-trace = { path = "crates/node-file-trace", version = "0.1.0" }
# Be careful when selecting tls backend, including change default tls backend.
# If you changed, must verify with ALL build targets with next-swc to ensure
# it works. next-swc have various platforms, some doesn't support native (using openssl-sys)
# and some aren't buildable with rustls.
reqwest = { version = "0.11.13", default-features = false }
styled_components = { version = "0.52.13" }
styled_jsx = { version = "0.29.13" }
swc_core = { version = "0.53.0" }
swc_emotion = { version = "0.28.9" }
testing = { version = "0.31.25" }
2 changes: 2 additions & 0 deletions crates/next-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ bench = false
[dependencies]
anyhow = "1.0.47"
auto-hash-map = { path = "../auto-hash-map" }
crossterm = { workspace = true }
indexmap = { workspace = true, features = ["serde"] }
indoc = "1.0"
mime = "0.3.16"
num_cpus = "1.13.1"
once_cell = "1.13.0"
qstring = "0.7.2"
serde = "1.0.136"
Expand Down
10 changes: 9 additions & 1 deletion crates/next-core/js/src/entry/config/next.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ import { PHASE_DEVELOPMENT_SERVER } from "next/dist/shared/lib/constants";

const loadNextConfig = async () => {
const nextConfig = await loadConfig(PHASE_DEVELOPMENT_SERVER, process.cwd());
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?

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

// TODO: these functions takes arguments, have to be supported in a different way
nextConfig.exportPathMap = nextConfig.exportPathMap && {};
nextConfig.webpack = nextConfig.webpack && {};

return nextConfig;
};

Expand Down
Loading