Skip to content

Commit

Permalink
change static path to /_next/static/media (vercel#50207)
Browse files Browse the repository at this point in the history
### What?

align output path of turbopack and webpack

### Why?

passing test cases

### Turbopack Changes

* vercel/turbo#5072 <!-- Tobias Koppers -
improve asset path -->
  • Loading branch information
sokra authored and hydRAnger committed Jun 12, 2023
1 parent 233e204 commit 7286132
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 71 deletions.
66 changes: 33 additions & 33 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.76.18" }
testing = { version = "0.33.11" }

# Turbo crates
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230523.2" }
turbopack-binding = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230523.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-230523.2" }
turbo-tasks = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230523.3" }
# [TODO]: need to refactor embed_directory! macro usage in next-core
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230523.2" }
turbo-tasks-fs = { git = "https://github.com/vercel/turbo.git", tag = "turbopack-230523.3" }

# General Deps

Expand Down
4 changes: 2 additions & 2 deletions packages/next-swc/crates/next-core/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"check": "tsc --noEmit"
},
"dependencies": {
"@vercel/turbopack-dev": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.2",
"@vercel/turbopack-node": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.2",
"@vercel/turbopack-dev": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.3",
"@vercel/turbopack-node": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.3",
"anser": "^2.1.1",
"css.escape": "^1.5.1",
"next": "*",
Expand Down
11 changes: 9 additions & 2 deletions packages/next-swc/crates/next-core/src/app_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ async fn create_app_route_source_for_route(
project_path,
intermediate_output_path: intermediate_output_path_root,
output_root: intermediate_output_path_root,
app_dir,
}
.cell()
.into(),
Expand Down Expand Up @@ -1018,7 +1019,7 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}";
project_path,
intermediate_output_path,
intermediate_output_path.join("chunks"),
server_root.join("_next/static/assets"),
get_client_assets_path(server_root, Value::new(ClientContextType::App { app_dir })),
context.compile_time_info().environment(),
)
.layer("ssr")
Expand Down Expand Up @@ -1087,6 +1088,7 @@ struct AppRoute {
project_path: FileSystemPathVc,
server_root: FileSystemPathVc,
output_root: FileSystemPathVc,
app_dir: FileSystemPathVc,
}

#[turbo_tasks::value_impl]
Expand All @@ -1099,7 +1101,12 @@ impl AppRouteVc {
this.project_path,
this.intermediate_output_path,
this.intermediate_output_path.join("chunks"),
this.server_root.join("_next/static/assets"),
get_client_assets_path(
this.server_root,
Value::new(ClientContextType::App {
app_dir: this.app_dir,
}),
),
this.context.compile_time_info().environment(),
)
.layer("ssr")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ pub fn get_client_assets_path(
match ty.into_value() {
ClientContextType::Pages { .. }
| ClientContextType::App { .. }
| ClientContextType::Fallback => server_root.join("/_next/static/assets"),
| ClientContextType::Fallback => server_root.join("/_next/static/media"),
ClientContextType::Other => server_root.join("/_assets"),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function Test() {
function runTests() {
it('should link to imported image', async () => {
const img = document.querySelector('#imported')
expect(img.src).toContain(encodeURIComponent('_next/static/assets'))
expect(img.src).toContain(encodeURIComponent('_next/static/media'))

const res = await fetch(img.src)
expect(res.status).toBe(200)
Expand Down

0 comments on commit 7286132

Please sign in to comment.