-
Notifications
You must be signed in to change notification settings - Fork 26.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'canary' into fix/css-in-js-streaming
- Loading branch information
Showing
38 changed files
with
334 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Invalid Layout or Page Export | ||
|
||
#### Why This Error Occurred | ||
|
||
Your [layout](https://beta.nextjs.org/docs/api-reference/file-conventions/layout) or [page](https://beta.nextjs.org/docs/api-reference/file-conventions/page) inside the app directory exports an invalid field. In these files, you're only allowed to export a default React component, or [Segment Configuration Options](https://beta.nextjs.org/docs/api-reference/segment-config) for layout and pages, such as `revalidate`, `generateStaticParams`, etc. | ||
|
||
Other custom exports are not allowed to catch misspelt configuration options and prevent conflicts with future options. | ||
|
||
#### Possible Ways to Fix It | ||
|
||
You can create a new file and co-locate it with the page or layout. In the new file, you can export any custom fields and import it from anywhere. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,5 +16,5 @@ | |
"registry": "https://registry.npmjs.org/" | ||
} | ||
}, | ||
"version": "13.0.1" | ||
"version": "13.0.2-canary.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "create-next-app", | ||
"version": "13.0.1", | ||
"version": "13.0.2-canary.0", | ||
"keywords": [ | ||
"react", | ||
"next", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@next/env", | ||
"version": "13.0.1", | ||
"version": "13.0.2-canary.0", | ||
"keywords": [ | ||
"react", | ||
"next", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,157 +1,9 @@ | ||
use std::{ | ||
future::join, | ||
net::{IpAddr, Ipv4Addr}, | ||
path::PathBuf, | ||
time::{Duration, Instant}, | ||
}; | ||
|
||
use crate::util::MapErr; | ||
use napi::bindgen_prelude::*; | ||
use next_dev::{register, NextDevServerBuilder}; | ||
use owo_colors::OwoColorize; | ||
use serde::Deserialize; | ||
use turbo_tasks::{util::FormatDuration, TurboTasks}; | ||
use turbo_tasks_memory::MemoryBackend; | ||
use turbopack_core::issue::IssueSeverity; | ||
|
||
#[derive(Clone, Debug, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
#[allow(unused)] | ||
struct TurboDevServerOptions { | ||
#[serde(default = "default_port")] | ||
port: u16, | ||
|
||
#[serde(default = "default_host")] | ||
hostname: IpAddr, | ||
|
||
#[serde(default)] | ||
eager_compile: bool, | ||
|
||
#[serde(default)] | ||
log_level: Option<IssueSeverity>, | ||
|
||
#[serde(default)] | ||
show_all: bool, | ||
|
||
#[serde(default)] | ||
log_detail: bool, | ||
|
||
#[serde(default = "default_dir")] | ||
dir: PathBuf, | ||
|
||
#[serde(default = "default_dir")] | ||
root_dir: PathBuf, | ||
|
||
#[serde(default)] | ||
allow_retry: bool, | ||
|
||
#[serde(default)] | ||
dev: bool, | ||
|
||
#[serde(default)] | ||
is_next_dev_command: bool, | ||
|
||
#[serde(default)] | ||
server_components_external_packages: Vec<String>, | ||
} | ||
|
||
fn default_port() -> u16 { | ||
3000 | ||
} | ||
|
||
fn default_host() -> IpAddr { | ||
IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)) | ||
} | ||
|
||
fn default_dir() -> PathBuf { | ||
std::env::current_dir().expect("Current dir should be accessible") | ||
} | ||
|
||
async fn start_server(options: TurboDevServerOptions) -> napi::Result<()> { | ||
let start = Instant::now(); | ||
|
||
register(); | ||
|
||
let tt = TurboTasks::new(MemoryBackend::new()); | ||
let tt_clone = tt.clone(); | ||
|
||
let dir = options | ||
.dir | ||
.canonicalize() | ||
.expect("Cannot canonicalize project directory") | ||
.to_str() | ||
.expect("project directory contains invalid characters") | ||
.to_string(); | ||
|
||
let root_dir = options | ||
.root_dir | ||
.canonicalize() | ||
.expect("Cannot canonicalize project directory") | ||
.to_str() | ||
.expect("project directory contains invalid characters") | ||
.to_string(); | ||
|
||
//server_component_external | ||
|
||
let mut server = NextDevServerBuilder::new(tt, dir, root_dir) | ||
.entry_request("src/index".into()) | ||
.eager_compile(options.eager_compile) | ||
.hostname(options.hostname) | ||
.port(options.port) | ||
.log_detail(options.log_detail) | ||
.show_all(options.show_all) | ||
.log_level( | ||
options | ||
.log_level | ||
.map_or_else(|| IssueSeverity::Warning, |l| l), | ||
); | ||
|
||
for package in options.server_components_external_packages { | ||
server = server.server_component_external(package); | ||
} | ||
|
||
let server = server.build().await.convert_err()?; | ||
|
||
let index_uri = if server.addr.ip().is_loopback() || server.addr.ip().is_unspecified() { | ||
format!("http://localhost:{}", server.addr.port()) | ||
} else { | ||
format!("http://{}", server.addr) | ||
}; | ||
println!( | ||
"{} - started server on {}:{}, url: {}", | ||
"ready".green(), | ||
server.addr.ip(), | ||
server.addr.port(), | ||
index_uri | ||
); | ||
|
||
let stats_future = async move { | ||
println!( | ||
"{event_type} - initial compilation {start}", | ||
event_type = "event".purple(), | ||
start = FormatDuration(start.elapsed()), | ||
); | ||
|
||
loop { | ||
let (elapsed, _count) = tt_clone | ||
.get_or_wait_update_info(Duration::from_millis(100)) | ||
.await; | ||
println!( | ||
"{event_type} - updated in {elapsed}", | ||
event_type = "event".purple(), | ||
elapsed = FormatDuration(elapsed), | ||
); | ||
} | ||
}; | ||
|
||
join!(stats_future, async { server.future.await.unwrap() }).await; | ||
|
||
Ok(()) | ||
} | ||
use next_dev::{devserver_options::DevServerOptions, start_server}; | ||
|
||
#[napi] | ||
pub async fn start_turbo_dev(options: Buffer) -> napi::Result<()> { | ||
let options: TurboDevServerOptions = serde_json::from_slice(&options)?; | ||
|
||
start_server(options).await | ||
let options: DevServerOptions = serde_json::from_slice(&options)?; | ||
start_server(&options).await.convert_err() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,4 +17,6 @@ export const EXTERNAL_PACKAGES = [ | |
'next-seo', | ||
'rimraf', | ||
'next-mdx-remote', | ||
'sqlite3', | ||
'mongodb', | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.