Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
403c50bb
Unverified
Commit
403c50bb
authored
Jan 11, 2025
by
Benjamin Woodruff
Committed by
GitHub
Jan 11, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(turbopack-dev-server): Remove unresolved Vc from DevHtmlEntry, use a named struct (#74707)
parent
3651a450
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
21 deletions
+38
-21
web_entry_source.rs
turbopack/crates/turbopack-cli/src/dev/web_entry_source.rs
+15
-9
html.rs
turbopack/crates/turbopack-dev-server/src/html.rs
+23
-12
No files found.
turbopack/crates/turbopack-cli/src/dev/web_entry_source.rs
View file @
403c50bb
...
@@ -16,7 +16,7 @@ use turbopack_core::{
...
@@ -16,7 +16,7 @@ use turbopack_core::{
},
},
};
};
use
turbopack_dev_server
::{
use
turbopack_dev_server
::{
html
::
DevHtmlAsset
,
html
::
{
DevHtmlAsset
,
DevHtmlEntry
}
,
source
::{
asset_graph
::
AssetGraphContentSource
,
ContentSource
},
source
::{
asset_graph
::
AssetGraphContentSource
,
ContentSource
},
};
};
use
turbopack_ecmascript_runtime
::
RuntimeType
;
use
turbopack_ecmascript_runtime
::
RuntimeType
;
...
@@ -112,7 +112,9 @@ pub async fn create_web_entry_source(
...
@@ -112,7 +112,9 @@ pub async fn create_web_entry_source(
server_root
,
server_root
,
*
server_root_to_root_path
,
*
server_root_to_root_path
,
compile_time_info
.environment
(),
compile_time_info
.environment
(),
);
)
.to_resolved
()
.await
?
;
let
entries
=
get_client_runtime_entries
(
root_path
,
node_env
);
let
entries
=
get_client_runtime_entries
(
root_path
,
node_env
);
let
runtime_entries
=
entries
.resolve_entries
(
asset_context
);
let
runtime_entries
=
entries
.resolve_entries
(
asset_context
);
...
@@ -138,21 +140,25 @@ pub async fn create_web_entry_source(
...
@@ -138,21 +140,25 @@ pub async fn create_web_entry_source(
.into_iter
()
.into_iter
()
.flatten
()
.flatten
()
.map
(|
module
|
async
move
{
.map
(|
module
|
async
move
{
if
let
(
Some
(
ch
nkab
le
),
Some
(
entry
))
=
(
if
let
(
Some
(
ch
unkable_modu
le
),
Some
(
entry
))
=
(
ResolvedVc
::
try_sidecast
::
<
Box
<
dyn
ChunkableModule
>>
(
module
)
.await
?
,
ResolvedVc
::
try_sidecast
::
<
Box
<
dyn
ChunkableModule
>>
(
module
)
.await
?
,
ResolvedVc
::
try_sidecast
::
<
Box
<
dyn
EvaluatableAsset
>>
(
module
)
.await
?
,
ResolvedVc
::
try_sidecast
::
<
Box
<
dyn
EvaluatableAsset
>>
(
module
)
.await
?
,
)
{
)
{
Ok
(
(
Ok
(
DevHtmlEntry
{
ch
nkab
le
,
ch
unkable_modu
le
,
chunking_context
,
chunking_context
,
Some
(
runtime_entries
.with_entry
(
*
entry
)
),
runtime_entries
:
Some
(
runtime_entries
.with_entry
(
*
entry
)
.to_resolved
()
.await
?
),
)
)
}
)
}
else
if
let
Some
(
chunkable
)
=
}
else
if
let
Some
(
chunkable
_module
)
=
ResolvedVc
::
try_sidecast
::
<
Box
<
dyn
ChunkableModule
>>
(
module
)
.await
?
ResolvedVc
::
try_sidecast
::
<
Box
<
dyn
ChunkableModule
>>
(
module
)
.await
?
{
{
// TODO this is missing runtime code, so it's probably broken and we should also
// TODO this is missing runtime code, so it's probably broken and we should also
// add an ecmascript chunk with the runtime code
// add an ecmascript chunk with the runtime code
Ok
((
chunkable
,
chunking_context
,
None
))
Ok
(
DevHtmlEntry
{
chunkable_module
,
chunking_context
,
runtime_entries
:
None
,
})
}
else
{
}
else
{
// TODO convert into a serve-able asset
// TODO convert into a serve-able asset
Err
(
anyhow!
(
Err
(
anyhow!
(
...
...
turbopack/crates/turbopack-dev-server/src/html.rs
View file @
403c50bb
use
anyhow
::
Result
;
use
anyhow
::
Result
;
use
mime_guess
::
mime
::
TEXT_HTML_UTF_8
;
use
mime_guess
::
mime
::
TEXT_HTML_UTF_8
;
use
serde
::{
Deserialize
,
Serialize
};
use
turbo_rcstr
::
RcStr
;
use
turbo_rcstr
::
RcStr
;
use
turbo_tasks
::{
ReadRef
,
ResolvedVc
,
TryJoinIterExt
,
Value
,
Vc
};
use
turbo_tasks
::{
trace
::
TraceRawVcs
,
NonLocalValue
,
ReadRef
,
ResolvedVc
,
TaskInput
,
TryJoinIterExt
,
Value
,
Vc
,
};
use
turbo_tasks_fs
::{
File
,
FileSystemPath
};
use
turbo_tasks_fs
::{
File
,
FileSystemPath
};
use
turbo_tasks_hash
::{
encode_hex
,
Xxh3Hash64Hasher
};
use
turbo_tasks_hash
::{
encode_hex
,
Xxh3Hash64Hasher
};
use
turbopack_core
::{
use
turbopack_core
::{
...
@@ -16,18 +19,19 @@ use turbopack_core::{
...
@@ -16,18 +19,19 @@ use turbopack_core::{
version
::{
Version
,
VersionedContent
},
version
::{
Version
,
VersionedContent
},
};
};
// TODO(WEB-945) This should become a struct once we have a
#[derive(
// `turbo_tasks::input` attribute macro/`Input` derive macro.
Clone,
Debug,
Deserialize,
Eq,
Hash,
NonLocalValue,
PartialEq,
Serialize,
TaskInput,
TraceRawVcs,
type
DevHtmlEntry
=
(
)]
ResolvedVc
<
Box
<
dyn
ChunkableModule
>>
,
pub
struct
DevHtmlEntry
{
Vc
<
Box
<
dyn
ChunkingContext
>>
,
pub
chunkable_module
:
ResolvedVc
<
Box
<
dyn
ChunkableModule
>>
,
Option
<
Vc
<
EvaluatableAssets
>>
,
pub
chunking_context
:
ResolvedVc
<
Box
<
dyn
ChunkingContext
>>
,
);
pub
runtime_entries
:
Option
<
ResolvedVc
<
EvaluatableAssets
>>
,
}
/// The HTML entry point of the dev server.
/// The HTML entry point of the dev server.
///
///
/// Generates an HTML page that includes the ES and CSS chunks.
/// Generates an HTML page that includes the ES and CSS chunks.
#[turbo_tasks
::
value(shared
,
local
)]
#[turbo_tasks
::
value(shared)]
#[derive(Clone)]
#[derive(Clone)]
pub
struct
DevHtmlAsset
{
pub
struct
DevHtmlAsset
{
path
:
ResolvedVc
<
FileSystemPath
>
,
path
:
ResolvedVc
<
FileSystemPath
>
,
...
@@ -132,19 +136,26 @@ impl DevHtmlAsset {
...
@@ -132,19 +136,26 @@ impl DevHtmlAsset {
.entries
.entries
.iter
()
.iter
()
.map
(|
entry
|
async
move
{
.map
(|
entry
|
async
move
{
let
&
(
chunkable_module
,
chunking_context
,
runtime_entries
)
=
entry
;
let
&
DevHtmlEntry
{
chunkable_module
,
chunking_context
,
runtime_entries
,
}
=
entry
;
let
assets
=
if
let
Some
(
runtime_entries
)
=
runtime_entries
{
let
assets
=
if
let
Some
(
runtime_entries
)
=
runtime_entries
{
let
runtime_entries
=
if
let
Some
(
evaluatable
)
=
let
runtime_entries
=
if
let
Some
(
evaluatable
)
=
ResolvedVc
::
try_downcast
(
chunkable_module
)
.await
?
ResolvedVc
::
try_downcast
(
chunkable_module
)
.await
?
{
{
runtime_entries
.with_entry
(
*
evaluatable
)
runtime_entries
.with_entry
(
*
evaluatable
)
.to_resolved
()
.await
?
}
else
{
}
else
{
runtime_entries
runtime_entries
};
};
chunking_context
.evaluated_chunk_group_assets
(
chunking_context
.evaluated_chunk_group_assets
(
chunkable_module
.ident
(),
chunkable_module
.ident
(),
runtime_entries
,
*
runtime_entries
,
Value
::
new
(
AvailabilityInfo
::
Root
),
Value
::
new
(
AvailabilityInfo
::
Root
),
)
)
}
else
{
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment