Skip to content

Commit

Permalink
Named page chunks (#51921)
Browse files Browse the repository at this point in the history
Depends on vercel/turbo#5398 (and downstack) on
the Turbo side.

This PR makes it so the output path of Node.js entry chunks for pages is
determined solely from the pathname. This isn't actually necessary for
pages, but it makes for easier debugging anyway. See the Turbo PR for
more details.

This also changes the page structure so it also works if there is no
`pages` directory. In this case, we still want to use pages' default
_app, _document, and _error pages, even with existing app routes. So an
empty page structure should still have an effect.

## Turbopack updates

* vercel/turbo#5415 <!-- Will Binns-Smith -
Turbopack: Execution tests in node.js -->
* vercel/turbo#5461 <!-- Tobias Koppers - use a
lock to ensure atomic invalidation from file changes -->
* vercel/turbo#5398 <!-- Alex Kirszenberg -
Configure the path of the Node.js entry chunk -->
* vercel/turbo#5469 <!-- Tobias Koppers - allow
hmr tests to correctly detect hmr event -->
  • Loading branch information
alexkirsz committed Jul 6, 2023
1 parent 2743d0c commit ec19537
Show file tree
Hide file tree
Showing 13 changed files with 327 additions and 272 deletions.
73 changes: 37 additions & 36 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ swc_core = { version = "0.78.24" }
testing = { version = "0.33.19" }

# Turbo crates
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230704.5" }
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230706.3" }
# [TODO]: need to refactor embed_directory! macro usages, as well as resolving turbo_tasks::function, macros..
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230704.5" }
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230706.3" }
# [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230704.5" }
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230706.3" }

# General Deps

Expand Down
4 changes: 3 additions & 1 deletion packages/next-swc/crates/next-build/src/next_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ pub(crate) async fn next_build(options: TransientInstance<BuildOptions>) -> Resu

let page_chunks = get_page_chunks(
pages_structure,
next_router_root,
project_root,
execution_context,
node_root,
Expand Down Expand Up @@ -411,9 +412,10 @@ pub(crate) async fn next_build(options: TransientInstance<BuildOptions>) -> Resu
continue;
}

let dependencies = pages_manifest
let dependencies = build_manifest
.pages
.get(page)
.unwrap()
.iter()
.map(|dep| dep.as_str())
.filter(|dep| !app_dependencies.contains(*dep))
Expand Down

0 comments on commit ec19537

Please sign in to comment.