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
19723b56
Commit
19723b56
authored
Nov 20, 2024
by
Benjamin Woodruff
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
turbopack inline css
parent
1bf02661
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
18 deletions
+52
-18
next_config.rs
crates/next-core/src/next_config.rs
+1
-0
client_reference_manifest.rs
...next-core/src/next_manifests/client_reference_manifest.rs
+42
-17
mod.rs
crates/next-core/src/next_manifests/mod.rs
+9
-1
No files found.
crates/next-core/src/next_config.rs
View file @
19723b56
...
...
@@ -551,6 +551,7 @@ pub struct ExperimentalConfig {
fully_specified
:
Option
<
bool
>
,
gzip_size
:
Option
<
bool
>
,
pub
inline_css
:
Option
<
bool
>
,
instrumentation_hook
:
Option
<
bool
>
,
client_trace_metadata
:
Option
<
Vec
<
String
>>
,
large_page_data_bytes
:
Option
<
f64
>
,
...
...
crates/next-core/src/next_manifests/client_reference_manifest.rs
View file @
19723b56
...
...
@@ -4,7 +4,7 @@ use turbo_rcstr::RcStr;
use
turbo_tasks
::{
FxIndexSet
,
TryJoinIterExt
,
Value
,
ValueToString
,
Vc
};
use
turbo_tasks_fs
::{
File
,
FileSystemPath
};
use
turbopack_core
::{
asset
::
AssetContent
,
asset
::
{
Asset
,
AssetContent
}
,
chunk
::{
availability_info
::
AvailabilityInfo
,
ChunkItem
,
ChunkItemExt
,
ChunkableModule
,
ChunkingContext
,
ModuleId
as
TurbopackModuleId
,
...
...
@@ -14,7 +14,7 @@ use turbopack_core::{
};
use
turbopack_ecmascript
::
utils
::
StringifyJs
;
use
super
::{
ClientReferenceManifest
,
ManifestNode
,
ManifestNodeEntry
,
ModuleId
};
use
super
::{
ClientReferenceManifest
,
CssResource
,
ManifestNode
,
ManifestNodeEntry
,
ModuleId
};
use
crate
::{
next_app
::
ClientReferencesChunks
,
next_client_reference
::{
ClientReferenceGraphResult
,
ClientReferenceType
},
...
...
@@ -241,40 +241,65 @@ impl ClientReferenceManifest {
for
(
server_component
,
client_chunks
)
in
client_references_chunks
.layout_segment_client_chunks
.iter
()
{
let
client_chunks
=
&
client_chunks
.await
?
;
let
client_chunks_paths
=
client_chunks
.iter
()
.map
(|
chunk
|
chunk
.ident
()
.path
())
.try_join
()
.await
?
;
let
server_component_name
=
server_component
.server_path
()
.with_extension
(
""
.into
())
.to_string
()
.await
?
;
let
entry_css_files
=
entry_manifest
.entry_css_files
.entry
(
server_component_name
.clone_value
())
.or_default
();
let
mut
entry_css_files_with_chunk
=
Vec
::
new
();
let
entry_js_files
=
entry_manifest
.entry_js_files
.entry
(
server_component_name
.clone_value
())
.or_default
();
for
chunk_path
in
client_chunks_paths
{
let
client_chunks
=
&
client_chunks
.await
?
;
let
client_chunks_with_path
=
client_chunks
.iter
()
.map
(|
chunk
|
async
move
{
Ok
((
chunk
,
chunk
.ident
()
.path
()
.await
?
))
})
.try_join
()
.await
?
;
for
(
chunk
,
chunk_path
)
in
client_chunks_with_path
{
if
let
Some
(
path
)
=
client_relative_path
.get_path_to
(
&
chunk_path
)
{
let
path
=
path
.into
();
if
chunk_path
.extension_ref
()
==
Some
(
"css"
)
{
entry_css_files
.insert
(
path
);
entry_css_files
_with_chunk
.push
((
path
,
chunk
)
);
}
else
{
entry_js_files
.insert
(
path
);
}
}
}
let
inlined
=
next_config
.await
?
.experimental.inline_css
.unwrap_or
(
false
);
let
entry_css_files_vec
=
entry_css_files_with_chunk
.into_iter
()
.map
(|(
path
,
chunk
)|
async
{
let
content
=
if
inlined
{
if
let
Some
(
content_file
)
=
chunk
.content
()
.file_content
()
.await
?
.as_content
()
{
Some
(
content_file
.content
()
.to_str
()
?
.into
())
}
else
{
Some
(
""
.into
())
}
}
else
{
None
};
Ok
(
CssResource
{
path
,
inlined
,
content
,
})
})
.try_join
()
.await
?
;
let
entry_css_files
=
entry_manifest
.entry_css_files
.entry
(
server_component_name
.clone_value
())
.or_default
();
entry_css_files
.extend
(
entry_css_files_vec
);
}
let
client_reference_manifest_json
=
serde_json
::
to_string
(
&
entry_manifest
)
.unwrap
();
...
...
crates/next-core/src/next_manifests/mod.rs
View file @
19723b56
...
...
@@ -355,12 +355,20 @@ pub struct ClientReferenceManifest {
pub
edge_rsc_module_mapping
:
HashMap
<
ModuleId
,
ManifestNode
>
,
/// Mapping of server component path to required CSS client chunks.
#[serde(rename
=
"entryCSSFiles"
)]
pub
entry_css_files
:
HashMap
<
RcStr
,
FxIndexSet
<
RcStr
>>
,
pub
entry_css_files
:
HashMap
<
RcStr
,
FxIndexSet
<
CssResource
>>
,
/// Mapping of server component path to required JS client chunks.
#[serde(rename
=
"entryJSFiles"
)]
pub
entry_js_files
:
HashMap
<
RcStr
,
FxIndexSet
<
RcStr
>>
,
}
#[derive(Serialize,
Debug,
Clone,
Eq,
Hash,
PartialEq)]
pub
struct
CssResource
{
pub
path
:
RcStr
,
pub
inlined
:
bool
,
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
content
:
Option
<
RcStr
>
,
}
#[derive(Serialize,
Default,
Debug)]
#[serde(rename_all
=
"camelCase"
)]
pub
struct
ModuleLoading
{
...
...
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