Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 23 additions & 13 deletions crates/next-api/src/next_server_nft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,28 @@ enum ServerNftType {

#[turbo_tasks::function]
pub async fn next_server_nft_assets(project: Vc<Project>) -> Result<Vc<OutputAssets>> {
Ok(Vc::cell(vec![
ResolvedVc::upcast(
ServerNftJsonAsset::new(project, ServerNftType::Full)
.to_resolved()
.await?,
),
ResolvedVc::upcast(
ServerNftJsonAsset::new(project, ServerNftType::Minimal)
.to_resolved()
.await?,
),
]))
let has_next_support = *project.ci_has_next_support().await?;
let is_standalone = *project.next_config().is_standalone().await?;

let minimal = ResolvedVc::upcast(
ServerNftJsonAsset::new(project, ServerNftType::Minimal)
.to_resolved()
.await?,
);

if has_next_support && !is_standalone {
// When deploying to Vercel, we only need next-minimal-server.js.nft.json
Ok(Vc::cell(vec![minimal]))
} else {
Ok(Vc::cell(vec![
minimal,
ResolvedVc::upcast(
ServerNftJsonAsset::new(project, ServerNftType::Full)
.to_resolved()
.await?,
),
]))
}
}

#[turbo_tasks::value]
Expand Down Expand Up @@ -248,7 +258,7 @@ impl ServerNftJsonAsset {
#[turbo_tasks::function]
async fn ignores(&self) -> Result<Vc<Glob>> {
let is_standalone = *self.project.next_config().is_standalone().await?;
let has_next_support = *self.project.next_config().ci_has_next_support().await?;
let has_next_support = *self.project.ci_has_next_support().await?;
let project_path = self.project.project_path().owned().await?;

let output_file_tracing_excludes = self
Expand Down
7 changes: 7 additions & 0 deletions crates/next-api/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
/// E.g. `/home/user/projects/my-repo`.
pub root_path: RcStr,

/// A path which contains the app/pages directories, relative to [`Project::root_path`], always

Check warning on line 156 in crates/next-api/src/project.rs

View workflow job for this annotation

GitHub Actions / rustdoc check / build

public documentation for `project_path` links to private item `Project::root_path`
/// Unix path. E.g. `apps/my-app`
pub project_path: RcStr,

Expand Down Expand Up @@ -764,6 +764,13 @@
*self.env
}

#[turbo_tasks::function]
pub async fn ci_has_next_support(&self) -> Result<Vc<bool>> {
Ok(Vc::cell(
self.env.read(rcstr!("NOW_BUILDER")).await?.is_some(),
))
}

#[turbo_tasks::function]
pub(super) fn current_node_js_version(&self) -> Vc<NodeJsVersion> {
NodeJsVersion::Static(ResolvedVc::cell(self.current_node_js_version.clone())).cell()
Expand Down
5 changes: 0 additions & 5 deletions crates/next-core/src/next_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1328,11 +1328,6 @@ impl NextConfig {
Vc::cell(self.output == Some(OutputType::Standalone))
}

#[turbo_tasks::function]
pub fn ci_has_next_support(&self) -> Vc<bool> {
Vc::cell(self.env.contains_key("NOW_BUILDER"))
}

#[turbo_tasks::function]
pub fn cache_handler(&self, project_path: FileSystemPath) -> Result<Vc<OptionFileSystemPath>> {
if let Some(handler) = &self.cache_handler {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ describe('required server files app router', () => {
await setupNext({ nextEnv: true, minimalMode: true })
})
afterAll(async () => {
delete process.env.NOW_BUILDER
delete process.env.NEXT_PRIVATE_TEST_HEADERS
await next.destroy()
if (server) await killApp(server)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ describe('required server files app router', () => {
})

afterAll(async () => {
delete process.env.NOW_BUILDER
delete process.env.NEXT_PRIVATE_TEST_HEADERS
await next.destroy()
if (server) await killApp(server)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ describe('required server files', () => {
})

afterAll(async () => {
delete process.env.NOW_BUILDER
delete process.env.NEXT_PRIVATE_TEST_HEADERS
await next.destroy()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ describe('minimal-mode-response-cache', () => {
appPort = `http://127.0.0.1:${port}`
})
afterAll(async () => {
delete process.env.NOW_BUILDER
delete process.env.NEXT_PRIVATE_TEST_HEADERS
await next.destroy()
if (server) await killApp(server)
Expand Down
Loading