Unverified Commit 33b8e615 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

change static path to /_next/static/media (#50207)

### What?

align output path of turbopack and webpack

### Why?

passing test cases

### Turbopack Changes

* https://github.com/vercel/turbo/pull/5072 <!-- Tobias Koppers -
improve asset path -->
parent 9eaf4f5d
This diff is collapsed.
...@@ -42,11 +42,11 @@ swc_core = { version = "0.76.18" } ...@@ -42,11 +42,11 @@ swc_core = { version = "0.76.18" }
testing = { version = "0.33.11" } testing = { version = "0.33.11" }
# Turbo crates # 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.. # [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 # [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 # General Deps
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
"check": "tsc --noEmit" "check": "tsc --noEmit"
}, },
"dependencies": { "dependencies": {
"@vercel/turbopack-dev": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/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.2", "@vercel/turbopack-node": "https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.3",
"anser": "^2.1.1", "anser": "^2.1.1",
"css.escape": "^1.5.1", "css.escape": "^1.5.1",
"next": "*", "next": "*",
......
...@@ -674,6 +674,7 @@ async fn create_app_route_source_for_route( ...@@ -674,6 +674,7 @@ async fn create_app_route_source_for_route(
project_path, project_path,
intermediate_output_path: intermediate_output_path_root, intermediate_output_path: intermediate_output_path_root,
output_root: intermediate_output_path_root, output_root: intermediate_output_path_root,
app_dir,
} }
.cell() .cell()
.into(), .into(),
...@@ -1018,7 +1019,7 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}"; ...@@ -1018,7 +1019,7 @@ import {}, {{ chunks as {} }} from "COMPONENT_{}";
project_path, project_path,
intermediate_output_path, intermediate_output_path,
intermediate_output_path.join("chunks"), 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(), context.compile_time_info().environment(),
) )
.layer("ssr") .layer("ssr")
...@@ -1087,6 +1088,7 @@ struct AppRoute { ...@@ -1087,6 +1088,7 @@ struct AppRoute {
project_path: FileSystemPathVc, project_path: FileSystemPathVc,
server_root: FileSystemPathVc, server_root: FileSystemPathVc,
output_root: FileSystemPathVc, output_root: FileSystemPathVc,
app_dir: FileSystemPathVc,
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
...@@ -1099,7 +1101,12 @@ impl AppRouteVc { ...@@ -1099,7 +1101,12 @@ impl AppRouteVc {
this.project_path, this.project_path,
this.intermediate_output_path, this.intermediate_output_path,
this.intermediate_output_path.join("chunks"), 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(), this.context.compile_time_info().environment(),
) )
.layer("ssr") .layer("ssr")
......
...@@ -343,7 +343,7 @@ pub fn get_client_assets_path( ...@@ -343,7 +343,7 @@ pub fn get_client_assets_path(
match ty.into_value() { match ty.into_value() {
ClientContextType::Pages { .. } ClientContextType::Pages { .. }
| ClientContextType::App { .. } | ClientContextType::App { .. }
| ClientContextType::Fallback => server_root.join("/_next/static/assets"), | ClientContextType::Fallback => server_root.join("/_next/static/media"),
ClientContextType::Other => server_root.join("/_assets"), ClientContextType::Other => server_root.join("/_assets"),
} }
} }
......
...@@ -8,7 +8,7 @@ export default function Test() { ...@@ -8,7 +8,7 @@ export default function Test() {
function runTests() { function runTests() {
it('should link to imported image', async () => { it('should link to imported image', async () => {
const img = document.querySelector('#imported') 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) const res = await fetch(img.src)
expect(res.status).toBe(200) expect(res.status).toBe(200)
......
...@@ -83,7 +83,7 @@ function runTests() { ...@@ -83,7 +83,7 @@ function runTests() {
it('should link to imported image', async () => { it('should link to imported image', async () => {
const img = document.querySelector('#imported') 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) const res = await fetch(img.src)
expect(res.status).toBe(200) expect(res.status).toBe(200)
...@@ -91,7 +91,7 @@ function runTests() { ...@@ -91,7 +91,7 @@ function runTests() {
it('should link to imported svg image', async () => { it('should link to imported svg image', async () => {
const img = document.querySelector('#svg') const img = document.querySelector('#svg')
expect(img.src).toContain('_next/static/assets') expect(img.src).toContain('_next/static/media')
const res = await fetch(img.src) const res = await fetch(img.src)
expect(res.status).toBe(200) expect(res.status).toBe(200)
...@@ -107,7 +107,7 @@ function runTests() { ...@@ -107,7 +107,7 @@ function runTests() {
it('should link to imported broken image', async () => { it('should link to imported broken image', async () => {
const img = document.querySelector('#broken') const img = document.querySelector('#broken')
expect(img.src).toContain(encodeURIComponent('_next/static/assets')) expect(img.src).toContain(encodeURIComponent('_next/static/media'))
const res = await fetch(img.src) const res = await fetch(img.src)
expect(res.status).toBe(404) expect(res.status).toBe(404)
...@@ -115,7 +115,7 @@ function runTests() { ...@@ -115,7 +115,7 @@ function runTests() {
it('should link to imported broken svg image', async () => { it('should link to imported broken svg image', async () => {
const img = document.querySelector('#broken-svg') const img = document.querySelector('#broken-svg')
expect(img.src).toContain('_next/static/assets') expect(img.src).toContain('_next/static/media')
const res = await fetch(img.src) const res = await fetch(img.src)
expect(res.status).toBe(200) expect(res.status).toBe(200)
......
PlainIssue { PlainIssue {
severity: Error, severity: Error,
context: "[root of the server]/_next/static/assets/11d09843b5b83333.jpeg", context: "[root of the server]/_next/static/media/broken.11d09843.jpeg",
category: "image", category: "image",
title: "Processing image failed", title: "Processing image failed",
description: "unable to decode image data\n\nCaused by:\n- failed to fill whole buffer", description: "unable to decode image data\n\nCaused by:\n- failed to fill whole buffer",
......
...@@ -10,6 +10,6 @@ export default function Home() { ...@@ -10,6 +10,6 @@ export default function Home() {
function runTests() { function runTests() {
it('it should link to imported image from a package', function () { it('it should link to imported image from a package', function () {
const img = document.querySelector('#magic') const img = document.querySelector('#magic')
expect(img.src).toContain(encodeURIComponent('_next/static/assets')) expect(img.src).toContain(encodeURIComponent('_next/static/media'))
}) })
} }
...@@ -1012,8 +1012,8 @@ importers: ...@@ -1012,8 +1012,8 @@ importers:
'@types/react': 18.2.5 '@types/react': 18.2.5
'@types/react-dom': 18.2.3 '@types/react-dom': 18.2.3
'@vercel/ncc': ^0.36.0 '@vercel/ncc': ^0.36.0
'@vercel/turbopack-dev': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/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.2 '@vercel/turbopack-node': https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.3
anser: ^2.1.1 anser: ^2.1.1
css.escape: ^1.5.1 css.escape: ^1.5.1
find-up: ^6.3.0 find-up: ^6.3.0
...@@ -1025,8 +1025,8 @@ importers: ...@@ -1025,8 +1025,8 @@ importers:
stacktrace-parser: ^0.1.10 stacktrace-parser: ^0.1.10
strip-ansi: ^7.0.1 strip-ansi: ^7.0.1
dependencies: dependencies:
'@vercel/turbopack-dev': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.2_react-refresh@0.12.0' '@vercel/turbopack-dev': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.3_react-refresh@0.12.0'
'@vercel/turbopack-node': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.2' '@vercel/turbopack-node': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.3'
anser: 2.1.1 anser: 2.1.1
css.escape: 1.5.1 css.escape: 1.5.1
next: link:../../../../next next: link:../../../../next
...@@ -5997,7 +5997,7 @@ packages: ...@@ -5997,7 +5997,7 @@ packages:
dependencies: dependencies:
'@mdx-js/mdx': 2.2.1 '@mdx-js/mdx': 2.2.1
source-map: 0.7.3 source-map: 0.7.3
webpack: 5.74.0 webpack: 5.74.0_@swc+core@1.3.55
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
...@@ -6669,7 +6669,6 @@ packages: ...@@ -6669,7 +6669,6 @@ packages:
cpu: [arm64] cpu: [arm64]
os: [darwin] os: [darwin]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-darwin-x64/1.3.55: /@swc/core-darwin-x64/1.3.55:
...@@ -6678,7 +6677,6 @@ packages: ...@@ -6678,7 +6677,6 @@ packages:
cpu: [x64] cpu: [x64]
os: [darwin] os: [darwin]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-linux-arm-gnueabihf/1.3.55: /@swc/core-linux-arm-gnueabihf/1.3.55:
...@@ -6687,7 +6685,6 @@ packages: ...@@ -6687,7 +6685,6 @@ packages:
cpu: [arm] cpu: [arm]
os: [linux] os: [linux]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-linux-arm64-gnu/1.3.55: /@swc/core-linux-arm64-gnu/1.3.55:
...@@ -6696,7 +6693,6 @@ packages: ...@@ -6696,7 +6693,6 @@ packages:
cpu: [arm64] cpu: [arm64]
os: [linux] os: [linux]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-linux-arm64-musl/1.3.55: /@swc/core-linux-arm64-musl/1.3.55:
...@@ -6705,7 +6701,6 @@ packages: ...@@ -6705,7 +6701,6 @@ packages:
cpu: [arm64] cpu: [arm64]
os: [linux] os: [linux]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-linux-x64-gnu/1.3.55: /@swc/core-linux-x64-gnu/1.3.55:
...@@ -6714,7 +6709,6 @@ packages: ...@@ -6714,7 +6709,6 @@ packages:
cpu: [x64] cpu: [x64]
os: [linux] os: [linux]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-linux-x64-musl/1.3.55: /@swc/core-linux-x64-musl/1.3.55:
...@@ -6723,7 +6717,6 @@ packages: ...@@ -6723,7 +6717,6 @@ packages:
cpu: [x64] cpu: [x64]
os: [linux] os: [linux]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-win32-arm64-msvc/1.3.55: /@swc/core-win32-arm64-msvc/1.3.55:
...@@ -6732,7 +6725,6 @@ packages: ...@@ -6732,7 +6725,6 @@ packages:
cpu: [arm64] cpu: [arm64]
os: [win32] os: [win32]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-win32-ia32-msvc/1.3.55: /@swc/core-win32-ia32-msvc/1.3.55:
...@@ -6741,7 +6733,6 @@ packages: ...@@ -6741,7 +6733,6 @@ packages:
cpu: [ia32] cpu: [ia32]
os: [win32] os: [win32]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core-win32-x64-msvc/1.3.55: /@swc/core-win32-x64-msvc/1.3.55:
...@@ -6750,7 +6741,6 @@ packages: ...@@ -6750,7 +6741,6 @@ packages:
cpu: [x64] cpu: [x64]
os: [win32] os: [win32]
requiresBuild: true requiresBuild: true
dev: true
optional: true optional: true
/@swc/core/1.3.55_@swc+helpers@0.5.1: /@swc/core/1.3.55_@swc+helpers@0.5.1:
...@@ -6775,7 +6765,6 @@ packages: ...@@ -6775,7 +6765,6 @@ packages:
'@swc/core-win32-arm64-msvc': 1.3.55 '@swc/core-win32-arm64-msvc': 1.3.55
'@swc/core-win32-ia32-msvc': 1.3.55 '@swc/core-win32-ia32-msvc': 1.3.55
'@swc/core-win32-x64-msvc': 1.3.55 '@swc/core-win32-x64-msvc': 1.3.55
dev: true
/@swc/helpers/0.4.14: /@swc/helpers/0.4.14:
resolution: {integrity: sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==} resolution: {integrity: sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==}
...@@ -23669,7 +23658,6 @@ packages: ...@@ -23669,7 +23658,6 @@ packages:
source-map: 0.6.1 source-map: 0.6.1
terser: 5.14.1 terser: 5.14.1
webpack: 5.74.0_@swc+core@1.3.55 webpack: 5.74.0_@swc+core@1.3.55
dev: true
/terser-webpack-plugin/5.2.4_webpack@5.74.0: /terser-webpack-plugin/5.2.4_webpack@5.74.0:
resolution: {integrity: sha512-E2CkNMN+1cho04YpdANyRrn8CyN4yMy+WdFKZIySFZrGXZxJwJP6PMNGGc/Mcr6qygQHUUqRxnAPmi0M9f00XA==} resolution: {integrity: sha512-E2CkNMN+1cho04YpdANyRrn8CyN4yMy+WdFKZIySFZrGXZxJwJP6PMNGGc/Mcr6qygQHUUqRxnAPmi0M9f00XA==}
...@@ -25079,7 +25067,6 @@ packages: ...@@ -25079,7 +25067,6 @@ packages:
- '@swc/core' - '@swc/core'
- esbuild - esbuild
- uglify-js - uglify-js
dev: true
/websocket-driver/0.7.3: /websocket-driver/0.7.3:
resolution: {integrity: sha512-bpxWlvbbB459Mlipc5GBzzZwhoZgGEZLuqPaR0INBGnPAY1vdBX6hPnoFXiw+3yWxDuHyQjO2oXTMyS8A5haFg==} resolution: {integrity: sha512-bpxWlvbbB459Mlipc5GBzzZwhoZgGEZLuqPaR0INBGnPAY1vdBX6hPnoFXiw+3yWxDuHyQjO2oXTMyS8A5haFg==}
...@@ -25490,9 +25477,9 @@ packages: ...@@ -25490,9 +25477,9 @@ packages:
/zwitch/2.0.4: /zwitch/2.0.4:
resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==}
'@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.2_react-refresh@0.12.0': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.3_react-refresh@0.12.0':
resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.2} resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.3}
id: '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.2' id: '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-dev/js?turbopack-230523.3'
name: '@vercel/turbopack-dev' name: '@vercel/turbopack-dev'
version: 0.0.0 version: 0.0.0
dependencies: dependencies:
...@@ -25502,8 +25489,8 @@ packages: ...@@ -25502,8 +25489,8 @@ packages:
- webpack - webpack
dev: false dev: false
'@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.2': '@gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.3':
resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.2} resolution: {tarball: https://gitpkg.vercel.app/vercel/turbo/crates/turbopack-node/js?turbopack-230523.3}
name: '@vercel/turbopack-node' name: '@vercel/turbopack-node'
version: 0.0.0 version: 0.0.0
dependencies: dependencies:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment