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
ecec67d3
Unverified
Commit
ecec67d3
authored
Feb 29, 2024
by
OJ Kwon
Committed by
GitHub
Feb 29, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(next-swc): remove unused features (#62696)
### What Remove unused features for the turbopack. Closes PACK-2628
parent
56c87926
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
0 additions
and
187 deletions
+0
-187
Cargo.lock
Cargo.lock
+0
-1
Cargo.toml
packages/next-swc/crates/next-api/Cargo.toml
+0
-1
Cargo.toml
packages/next-swc/crates/next-build/Cargo.toml
+0
-1
Cargo.toml
packages/next-swc/crates/next-core/Cargo.toml
+0
-2
lib.rs
packages/next-swc/crates/next-core/src/lib.rs
+0
-1
content_source.rs
...ext-swc/crates/next-core/src/next_image/content_source.rs
+0
-180
mod.rs
packages/next-swc/crates/next-core/src/next_image/mod.rs
+0
-1
No files found.
Cargo.lock
View file @
ecec67d3
...
@@ -7622,7 +7622,6 @@ dependencies = [
...
@@ -7622,7 +7622,6 @@ dependencies = [
"turbopack-cli-utils",
"turbopack-cli-utils",
"turbopack-core",
"turbopack-core",
"turbopack-dev",
"turbopack-dev",
"turbopack-dev-server",
"turbopack-ecmascript",
"turbopack-ecmascript",
"turbopack-ecmascript-hmr-protocol",
"turbopack-ecmascript-hmr-protocol",
"turbopack-ecmascript-plugins",
"turbopack-ecmascript-plugins",
...
...
packages/next-swc/crates/next-api/Cargo.toml
View file @
ecec67d3
...
@@ -34,7 +34,6 @@ turbopack-binding = { workspace = true, features = [
...
@@ -34,7 +34,6 @@ turbopack-binding = { workspace = true, features = [
"__turbopack_env"
,
"__turbopack_env"
,
"__turbopack_cli_utils"
,
"__turbopack_cli_utils"
,
"__turbopack_node"
,
"__turbopack_node"
,
"__turbopack_dev_server"
,
]
}
]
}
turbo-tasks
=
{
workspace
=
true
}
turbo-tasks
=
{
workspace
=
true
}
tracing
=
{
workspace
=
true
}
tracing
=
{
workspace
=
true
}
...
...
packages/next-swc/crates/next-build/Cargo.toml
View file @
ecec67d3
...
@@ -28,7 +28,6 @@ turbopack-binding = { workspace = true, features = [
...
@@ -28,7 +28,6 @@ turbopack-binding = { workspace = true, features = [
"__turbo_tasks_memory"
,
"__turbo_tasks_memory"
,
"__turbopack"
,
"__turbopack"
,
"__turbopack_build"
,
"__turbopack_build"
,
"__turbopack_cli_utils"
,
"__turbopack_core"
,
"__turbopack_core"
,
"__turbopack_dev"
,
"__turbopack_dev"
,
"__turbopack_ecmascript"
,
"__turbopack_ecmascript"
,
...
...
packages/next-swc/crates/next-core/Cargo.toml
View file @
ecec67d3
...
@@ -45,10 +45,8 @@ turbopack-binding = { workspace = true, features = [
...
@@ -45,10 +45,8 @@ turbopack-binding = { workspace = true, features = [
"__turbo_tasks_hash"
,
"__turbo_tasks_hash"
,
"__turbopack"
,
"__turbopack"
,
"__turbopack_build"
,
"__turbopack_build"
,
"__turbopack_cli_utils"
,
"__turbopack_core"
,
"__turbopack_core"
,
"__turbopack_dev"
,
"__turbopack_dev"
,
"__turbopack_dev_server"
,
"__turbopack_ecmascript"
,
"__turbopack_ecmascript"
,
"__turbopack_ecmascript_plugin"
,
"__turbopack_ecmascript_plugin"
,
"__turbopack_ecmascript_runtime"
,
"__turbopack_ecmascript_runtime"
,
...
...
packages/next-swc/crates/next-core/src/lib.rs
View file @
ecec67d3
...
@@ -58,7 +58,6 @@ pub fn register() {
...
@@ -58,7 +58,6 @@ pub fn register() {
turbo
::
tasks_fs
::
register
();
turbo
::
tasks_fs
::
register
();
turbo
::
tasks_fetch
::
register
();
turbo
::
tasks_fetch
::
register
();
turbopack
::
dev
::
register
();
turbopack
::
dev
::
register
();
turbopack
::
dev_server
::
register
();
turbopack
::
node
::
register
();
turbopack
::
node
::
register
();
turbopack
::
turbopack
::
register
();
turbopack
::
turbopack
::
register
();
turbopack
::
image
::
register
();
turbopack
::
image
::
register
();
...
...
packages/next-swc/crates/next-core/src/next_image/content_source.rs
deleted
100644 → 0
View file @
56c87926
use
anyhow
::{
bail
,
Result
};
use
turbo_tasks
::{
Value
,
Vc
};
use
turbo_tasks_fs
::
FileSystem
;
use
turbopack_binding
::
turbopack
::{
core
::{
asset
::
AssetContent
,
ident
::
AssetIdent
,
introspect
::
Introspectable
,
server_fs
::
ServerFileSystem
,
version
::
VersionedContent
,
},
dev_server
::
source
::{
query
::
QueryValue
,
route_tree
::{
RouteTree
,
RouteType
},
wrapping_source
::{
ContentSourceProcessor
,
WrappedGetContentSourceContent
},
ContentSource
,
ContentSourceContent
,
ContentSourceData
,
ContentSourceDataFilter
,
ContentSourceDataVary
,
GetContentSourceContent
,
ProxyResult
,
RewriteBuilder
,
},
image
::
process
::
optimize
,
};
/// Serves, resizes, optimizes, and re-encodes images to be used with
/// next/image.
#[turbo_tasks
::
value(shared)]
pub
struct
NextImageContentSource
{
asset_source
:
Vc
<
Box
<
dyn
ContentSource
>>
,
}
#[turbo_tasks
::
value_impl]
impl
NextImageContentSource
{
#[turbo_tasks
::
function]
pub
fn
new
(
asset_source
:
Vc
<
Box
<
dyn
ContentSource
>>
)
->
Vc
<
NextImageContentSource
>
{
NextImageContentSource
{
asset_source
}
.cell
()
}
}
#[turbo_tasks
::
value_impl]
impl
ContentSource
for
NextImageContentSource
{
#[turbo_tasks
::
function]
fn
get_routes
(
self
:
Vc
<
Self
>
)
->
Vc
<
RouteTree
>
{
RouteTree
::
new_route
(
Vec
::
new
(),
RouteType
::
Exact
,
Vc
::
upcast
(
self
))
}
}
#[turbo_tasks
::
value_impl]
impl
GetContentSourceContent
for
NextImageContentSource
{
#[turbo_tasks
::
function]
async
fn
vary
(
&
self
)
->
Vc
<
ContentSourceDataVary
>
{
ContentSourceDataVary
{
query
:
Some
(
ContentSourceDataFilter
::
Subset
(
[
"url"
.to_string
(),
"w"
.to_string
(),
"q"
.to_string
()]
.into
(),
)),
..
Default
::
default
()
}
.cell
()
}
#[turbo_tasks
::
function]
async
fn
get
(
self
:
Vc
<
Self
>
,
_path
:
String
,
data
:
Value
<
ContentSourceData
>
,
)
->
Result
<
Vc
<
ContentSourceContent
>>
{
let
this
=
self
.await
?
;
let
Some
(
query
)
=
&
data
.query
else
{
bail!
(
"missing query"
);
};
let
Some
(
QueryValue
::
String
(
url
))
=
query
.get
(
"url"
)
else
{
bail!
(
"missing url"
);
};
let
q
=
match
query
.get
(
"q"
)
{
None
=>
75
,
Some
(
QueryValue
::
String
(
s
))
=>
{
let
Ok
(
q
)
=
s
.parse
::
<
u8
>
()
else
{
bail!
(
"invalid q query argument"
)
};
q
}
_
=>
bail!
(
"missing q query argument"
),
};
let
w
=
match
query
.get
(
"w"
)
{
Some
(
QueryValue
::
String
(
s
))
=>
{
let
Ok
(
w
)
=
s
.parse
::
<
u32
>
()
else
{
bail!
(
"invalid w query argument"
)
};
w
}
_
=>
bail!
(
"missing w query argument"
),
};
// TODO: re-encode into next-gen formats.
if
let
Some
(
path
)
=
url
.strip_prefix
(
'/'
)
{
let
sources
=
this
.asset_source
.get_routes
()
.get
(
path
.to_string
())
.await
?
;
let
sources
=
sources
.iter
()
.map
(|
s
|
{
Vc
::
upcast
(
WrappedGetContentSourceContent
::
new
(
*
s
,
Vc
::
upcast
(
NextImageContentSourceProcessor
::
new
(
path
.to_string
(),
w
,
q
)),
))
})
.collect
();
let
sources
=
Vc
::
cell
(
sources
);
return
Ok
(
ContentSourceContent
::
Rewrite
(
RewriteBuilder
::
new_sources
(
sources
)
.build
())
.cell
(),
);
}
// TODO: This should be downloaded by the server, and resized, etc.
Ok
(
ContentSourceContent
::
HttpProxy
(
ProxyResult
{
status
:
302
,
headers
:
vec!
[(
"Location"
.to_string
(),
url
.clone
())],
body
:
""
.into
(),
}
.cell
(),
)
.cell
())
}
}
#[turbo_tasks
::
value_impl]
impl
Introspectable
for
NextImageContentSource
{
#[turbo_tasks
::
function]
fn
ty
(
&
self
)
->
Vc
<
String
>
{
Vc
::
cell
(
"next image content source"
.to_string
())
}
#[turbo_tasks
::
function]
fn
details
(
&
self
)
->
Vc
<
String
>
{
Vc
::
cell
(
"supports dynamic serving of any statically imported image"
.to_string
())
}
}
#[turbo_tasks
::
value]
struct
NextImageContentSourceProcessor
{
path
:
String
,
width
:
u32
,
quality
:
u8
,
}
#[turbo_tasks
::
value_impl]
impl
NextImageContentSourceProcessor
{
#[turbo_tasks
::
function]
pub
fn
new
(
path
:
String
,
width
:
u32
,
quality
:
u8
)
->
Vc
<
NextImageContentSourceProcessor
>
{
NextImageContentSourceProcessor
{
path
,
width
,
quality
,
}
.cell
()
}
}
#[turbo_tasks
::
value_impl]
impl
ContentSourceProcessor
for
NextImageContentSourceProcessor
{
#[turbo_tasks
::
function]
async
fn
process
(
&
self
,
content
:
Vc
<
ContentSourceContent
>
)
->
Result
<
Vc
<
ContentSourceContent
>>
{
let
ContentSourceContent
::
Static
(
static_content
)
=
*
content
.await
?
else
{
return
Ok
(
content
);
};
let
static_content
=
static_content
.await
?
;
let
asset_content
=
static_content
.content
.content
()
.await
?
;
let
AssetContent
::
File
(
file_content
)
=
*
asset_content
else
{
return
Ok
(
content
);
};
let
optimized_file_content
=
optimize
(
AssetIdent
::
from_path
(
ServerFileSystem
::
new
()
.root
()
.join
(
self
.path
.clone
())),
file_content
,
self
.width
,
u32
::
MAX
,
self
.quality
,
);
Ok
(
ContentSourceContent
::
static_content
(
AssetContent
::
File
(
optimized_file_content
)
.into
(),
))
}
}
packages/next-swc/crates/next-core/src/next_image/mod.rs
View file @
ecec67d3
pub
(
crate
)
mod
content_source
;
pub
(
crate
)
mod
module
;
pub
(
crate
)
mod
module
;
pub
(
crate
)
mod
source_asset
;
pub
(
crate
)
mod
source_asset
;
...
...
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