-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
devserver_options.rs
97 lines (84 loc) · 3.58 KB
/
devserver_options.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
use std::{net::IpAddr, path::PathBuf};
#[cfg(feature = "cli")]
use clap::Parser;
use turbopack_cli_utils::issue::IssueSeverityCliOption;
#[derive(Debug)]
#[cfg_attr(feature = "cli", derive(Parser))]
#[cfg_attr(feature = "cli", clap(author, version, about, long_about = None))]
#[cfg_attr(feature = "serializable", derive(serde::Deserialize))]
#[cfg_attr(feature = "serializable", serde(rename_all = "camelCase"))]
pub struct DevServerOptions {
/// The directory of the Next.js application.
/// If no directory is provided, the current directory will be used.
#[cfg_attr(feature = "cli", clap(value_parser))]
#[cfg_attr(feature = "serializable", serde(default))]
pub dir: Option<PathBuf>,
/// The root directory of the project. Nothing outside of this directory can
/// be accessed. e. g. the monorepo root.
/// If no directory is provided, `dir` will be used.
#[cfg_attr(feature = "cli", clap(long, value_parser))]
#[cfg_attr(feature = "serializable", serde(default))]
pub root: Option<PathBuf>,
/// The port number on which to start the application
#[cfg_attr(
feature = "cli",
clap(short, long, value_parser, default_value_t = 3000)
)]
#[cfg_attr(feature = "serializable", serde(default = "default_port"))]
pub port: u16,
/// Hostname on which to start the application
#[cfg_attr(
feature = "cli",
clap(short = 'H', long, value_parser, default_value = "0.0.0.0")
)]
#[cfg_attr(feature = "serializable", serde(default = "default_host"))]
pub hostname: IpAddr,
/// Compile all, instead of only compiling referenced assets when their
/// parent asset is requested
#[cfg_attr(feature = "cli", clap(long))]
#[cfg_attr(feature = "serializable", serde(default))]
pub eager_compile: bool,
/// Don't open the browser automatically when the dev server has started.
#[cfg_attr(feature = "cli", clap(long))]
#[cfg_attr(feature = "serializable", serde(default))]
pub no_open: bool,
#[cfg_attr(feature = "cli", clap(short, long))]
#[cfg_attr(feature = "serializable", serde(default))]
/// Filter by issue severity.
pub log_level: Option<IssueSeverityCliOption>,
#[cfg_attr(feature = "cli", clap(long))]
#[cfg_attr(feature = "serializable", serde(default))]
/// Show all log messages without limit.
pub show_all: bool,
#[cfg_attr(feature = "cli", clap(long))]
#[cfg_attr(feature = "serializable", serde(default))]
/// Expand the log details.
pub log_detail: bool,
// Inherited options from next-dev, need revisit later.
#[cfg_attr(feature = "cli", clap(long))]
#[cfg_attr(feature = "serializable", serde(default))]
/// If port is not explicitly specified, use different port if it's already
/// in use.
pub allow_retry: bool,
#[cfg_attr(feature = "cli", clap(long))]
#[cfg_attr(feature = "serializable", serde(default))]
/// Internal for next.js, no specific usage yet.
pub dev: bool,
#[cfg_attr(feature = "cli", clap(long))]
#[cfg_attr(feature = "serializable", serde(default))]
/// Internal for next.js, no specific usage yet.
pub is_next_dev_command: bool,
#[cfg_attr(feature = "cli", clap(long))]
#[cfg_attr(feature = "serializable", serde(default))]
/// Specify server component external packages explicitly. This is an
/// experimental flag.
pub server_components_external_packages: Vec<String>,
}
#[cfg(feature = "serializable")]
fn default_port() -> u16 {
3000
}
#[cfg(feature = "serializable")]
fn default_host() -> IpAddr {
IpAddr::V4(std::net::Ipv4Addr::new(0, 0, 0, 0))
}