| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -807,7 +807,7 @@ doc: $(NODE_EXE) doc-only ## Build Node.js, and then build the documentation wit | |||
| 807 | 807 | ||
| 808 | 808 | out/doc: | |
| 809 | 809 | mkdir -p $@ | |
| 810 | - cp doc/node_config_json_schema.json $@ | ||
| 810 | + cp doc/node-config-schema.json $@ | ||
| 811 | 811 | ||
| 812 | 812 | # If it's a source tarball, doc/api already contains the generated docs. | |
| 813 | 813 | # Just copy everything under doc/api over. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -909,61 +909,30 @@ flows within the application. As such, it is presently recommended to be sure | |||
| 909 | 909 | your application behaviour is unaffected by this change before using it in | |
| 910 | 910 | production. | |
| 911 | 911 | ||
| 912 | - ### `--experimental-default-type=type` | ||
| 913 | - | ||
| 914 | - <!-- YAML | ||
| 915 | - added: | ||
| 916 | - - v21.0.0 | ||
| 917 | - - v20.10.0 | ||
| 918 | - - v18.19.0 | ||
| 919 | - --> | ||
| 920 | - | ||
| 921 | - > Stability: 1.0 - Early development | ||
| 922 | - | ||
| 923 | - Define which module system, `module` or `commonjs`, to use for the following: | ||
| 924 | - | ||
| 925 | - * String input provided via `--eval` or STDIN, if `--input-type` is unspecified. | ||
| 926 | - | ||
| 927 | - * Files ending in `.js` or with no extension, if there is no `package.json` file | ||
| 928 | - present in the same folder or any parent folder. | ||
| 929 | - | ||
| 930 | - * Files ending in `.js` or with no extension, if the nearest parent | ||
| 931 | - `package.json` field lacks a `"type"` field; unless the `package.json` folder | ||
| 932 | - or any parent folder is inside a `node_modules` folder. | ||
| 933 | - | ||
| 934 | - In other words, `--experimental-default-type=module` flips all the places where | ||
| 935 | - Node.js currently defaults to CommonJS to instead default to ECMAScript modules, | ||
| 936 | - with the exception of folders and subfolders below `node_modules`, for backward | ||
| 937 | - compatibility. | ||
| 938 | - | ||
| 939 | - Under `--experimental-default-type=module` and `--experimental-wasm-modules`, | ||
| 940 | - files with no extension will be treated as WebAssembly if they begin with the | ||
| 941 | - WebAssembly magic number (`\0asm`); otherwise they will be treated as ES module | ||
| 942 | - JavaScript. | ||
| 943 | - | ||
| 944 | - ### `--experimental-config-file` | ||
| 912 | + ### `--experimental-config-file=config` | ||
| 945 | 913 | ||
| 946 | 914 | <!-- YAML | |
| 947 | 915 | added: REPLACEME | |
| 948 | 916 | --> | |
| 949 | 917 | ||
| 950 | 918 | > Stability: 1.0 - Early development | |
| 951 | 919 | ||
| 952 | - Use this flag to specify a configuration file that will be loaded and parsed | ||
| 953 | - before the application starts. | ||
| 920 | + If present, Node.js will look for a | ||
| 921 | + configuration file at the specified path. | ||
| 954 | 922 | Node.js will read the configuration file and apply the settings. | |
| 955 | 923 | The configuration file should be a JSON file | |
| 956 | 924 | with the following structure: | |
| 957 | 925 | ||
| 926 | + > \[!NOTE] | ||
| 927 | + > Replace `vX.Y.Z` in the `$schema` with the version of Node.js you are using. | ||
| 928 | + | ||
| 958 | 929 | ```json | |
| 959 | 930 | { | |
| 960 | - "$schema": "https://nodejs.org/dist/REPLACEME/docs/node_config_json_schema.json", | ||
| 931 | + "$schema": "https://nodejs.org/dist/vX.Y.Z/docs/node-config-schema.json", | ||
| 961 | 932 | "nodeOptions": { | |
| 962 | - "experimental-transform-types": true, | ||
| 963 | 933 | "import": [ | |
| 964 | - "amaro/transform" | ||
| 934 | + "amaro/strip" | ||
| 965 | 935 | ], | |
| 966 | - "disable-warning": "ExperimentalWarning", | ||
| 967 | 936 | "watch-path": "src", | |
| 968 | 937 | "watch-preserve-output": true | |
| 969 | 938 | } | |
@@ -974,7 +943,7 @@ In the `nodeOptions` field, only flags that are allowed in [`NODE_OPTIONS`][] ar | |||
| 974 | 943 | No-op flags are not supported. | |
| 975 | 944 | Not all V8 flags are currently supported. | |
| 976 | 945 | ||
| 977 | - It is possible to use the [official JSON schema](../node_config_json_schema.json) | ||
| 946 | + It is possible to use the [official JSON schema](../node-config-schema.json) | ||
| 978 | 947 | to validate the configuration file, which may vary depending on the Node.js version. | |
| 979 | 948 | Each key in the configuration file corresponds to a flag that can be passed | |
| 980 | 949 | as a command-line argument. The value of the key is the value that would be | |
@@ -984,7 +953,7 @@ For example, the configuration file above is equivalent to | |||
| 984 | 953 | the following command-line arguments: | |
| 985 | 954 | ||
| 986 | 955 | ```bash | |
| 987 | - node --experimental-transform-types --import amaro/transform --disable-warning=ExperimentalWarning --watch-path=src --watch-preserve-output | ||
| 956 | + node --import amaro/strip --watch-path=src --watch-preserve-output | ||
| 988 | 957 | ``` | |
| 989 | 958 | ||
| 990 | 959 | The priority in configuration is as follows: | |
@@ -1006,6 +975,50 @@ unknown keys or keys that cannot used in `NODE_OPTIONS`. | |||
| 1006 | 975 | Node.js will not sanitize or perform validation on the user-provided configuration, | |
| 1007 | 976 | so **NEVER** use untrusted configuration files. | |
| 1008 | 977 | ||
| 978 | + ### `--experimental-default-config-file` | ||
| 979 | + | ||
| 980 | + <!-- YAML | ||
| 981 | + added: REPLACEME | ||
| 982 | + --> | ||
| 983 | + | ||
| 984 | + > Stability: 1.0 - Early development | ||
| 985 | + | ||
| 986 | + If the `--experimental-default-config-file` flag is present, Node.js will look for a | ||
| 987 | + `node.config.json` file in the current working directory and load it as a | ||
| 988 | + as configuration file. | ||
| 989 | + | ||
| 990 | + ### `--experimental-default-type=type` | ||
| 991 | + | ||
| 992 | + <!-- YAML | ||
| 993 | + added: | ||
| 994 | + - v21.0.0 | ||
| 995 | + - v20.10.0 | ||
| 996 | + - v18.19.0 | ||
| 997 | + --> | ||
| 998 | + | ||
| 999 | + > Stability: 1.0 - Early development | ||
| 1000 | + | ||
| 1001 | + Define which module system, `module` or `commonjs`, to use for the following: | ||
| 1002 | + | ||
| 1003 | + * String input provided via `--eval` or STDIN, if `--input-type` is unspecified. | ||
| 1004 | + | ||
| 1005 | + * Files ending in `.js` or with no extension, if there is no `package.json` file | ||
| 1006 | + present in the same folder or any parent folder. | ||
| 1007 | + | ||
| 1008 | + * Files ending in `.js` or with no extension, if the nearest parent | ||
| 1009 | + `package.json` field lacks a `"type"` field; unless the `package.json` folder | ||
| 1010 | + or any parent folder is inside a `node_modules` folder. | ||
| 1011 | + | ||
| 1012 | + In other words, `--experimental-default-type=module` flips all the places where | ||
| 1013 | + Node.js currently defaults to CommonJS to instead default to ECMAScript modules, | ||
| 1014 | + with the exception of folders and subfolders below `node_modules`, for backward | ||
| 1015 | + compatibility. | ||
| 1016 | + | ||
| 1017 | + Under `--experimental-default-type=module` and `--experimental-wasm-modules`, | ||
| 1018 | + files with no extension will be treated as WebAssembly if they begin with the | ||
| 1019 | + WebAssembly magic number (`\0asm`); otherwise they will be treated as ES module | ||
| 1020 | + JavaScript. | ||
| 1021 | + | ||
| 1009 | 1022 | ### `--experimental-eventsource` | |
| 1010 | 1023 | ||
| 1011 | 1024 | <!-- YAML | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -169,7 +169,10 @@ Interpret as either ES modules or CommonJS modules input via --eval or STDIN, wh | |||
| 169 | 169 | .js or extensionless files whose nearest parent package.json lacks a "type" field, unless under node_modules. | |
| 170 | 170 | . | |
| 171 | 171 | .It Fl -experimental-config-file | |
| 172 | - Enable support for experimental config file | ||
| 172 | + Specifies the configuration file to load. | ||
| 173 | + . | ||
| 174 | + .It Fl -experimental-default-config-file | ||
| 175 | + Enable support for automatically loading node.config.json. | ||
| 173 | 176 | . | |
| 174 | 177 | .It Fl -experimental-import-meta-resolve | |
| 175 | 178 | Enable experimental ES modules support for import.meta.resolve(). | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -393,7 +393,8 @@ function setupSQLite() { | |||
| 393 | 393 | } | |
| 394 | 394 | ||
| 395 | 395 | function initializeConfigFileSupport() { | |
| 396 | - if (getOptionValue('--experimental-config-file')) { | ||
| 396 | + if (getOptionValue('--experimental-default-config-file') || | ||
| 397 | + getOptionValue('--experimental-config-file')) { | ||
| 397 | 398 | emitExperimentalWarning('--experimental-config-file'); | |
| 398 | 399 | } | |
| 399 | 400 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,22 +8,32 @@ namespace node { | |||
| 8 | 8 | ||
| 9 | 9 | std::optional<std::string_view> ConfigReader::GetDataFromArgs( | |
| 10 | 10 | const std::vector<std::string>& args) { | |
| 11 | - constexpr std::string_view flag = "--experimental-config-file"; | ||
| 11 | + constexpr std::string_view flag_path = "--experimental-config-file"; | ||
| 12 | + constexpr std::string_view default_file = | ||
| 13 | + "--experimental-default-config-file"; | ||
| 14 | + | ||
| 15 | + bool has_default_config_file = false; | ||
| 12 | 16 | ||
| 13 | 17 | for (auto it = args.begin(); it != args.end(); ++it) { | |
| 14 | - if (*it == flag) { | ||
| 18 | + if (*it == flag_path) { | ||
| 15 | 19 | // Case: "--experimental-config-file foo" | |
| 16 | 20 | if (auto next = std::next(it); next != args.end()) { | |
| 17 | 21 | return *next; | |
| 18 | 22 | } | |
| 19 | - } else if (it->starts_with(flag)) { | ||
| 23 | + } else if (it->starts_with(flag_path)) { | ||
| 20 | 24 | // Case: "--experimental-config-file=foo" | |
| 21 | - if (it->size() > flag.size() && (*it)[flag.size()] == '=') { | ||
| 22 | - return it->substr(flag.size() + 1); | ||
| 25 | + if (it->size() > flag_path.size() && (*it)[flag_path.size()] == '=') { | ||
| 26 | + return it->substr(flag_path.size() + 1); | ||
| 23 | 27 | } | |
| 28 | + } else if (*it == default_file || it->starts_with(default_file)) { | ||
| 29 | + has_default_config_file = true; | ||
| 24 | 30 | } | |
| 25 | 31 | } | |
| 26 | 32 | ||
| 33 | + if (has_default_config_file) { | ||
| 34 | + return "node.config.json"; | ||
| 35 | + } | ||
| 36 | + | ||
| 27 | 37 | return std::nullopt; | |
| 28 | 38 | } | |
| 29 | 39 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -690,7 +690,10 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() { | |||
| 690 | 690 | Implies("--env-file-if-exists", "[has_env_file_string]"); | |
| 691 | 691 | AddOption("--experimental-config-file", | |
| 692 | 692 | "set config file from supplied file", | |
| 693 | - &EnvironmentOptions::experimental_config_file); | ||
| 693 | + &EnvironmentOptions::experimental_config_file_path); | ||
| 694 | + AddOption("--experimental-default-config-file", | ||
| 695 | + "set config file from default config file", | ||
| 696 | + &EnvironmentOptions::experimental_default_config_file); | ||
| 694 | 697 | AddOption("--test", | |
| 695 | 698 | "launch test runner on startup", | |
| 696 | 699 | &EnvironmentOptions::test_runner); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -257,7 +257,8 @@ class EnvironmentOptions : public Options { | |||
| 257 | 257 | ||
| 258 | 258 | bool report_exclude_env = false; | |
| 259 | 259 | bool report_exclude_network = false; | |
| 260 | - std::string experimental_config_file; | ||
| 260 | + std::string experimental_config_file_path; | ||
| 261 | + bool experimental_default_config_file = false; | ||
| 261 | 262 | ||
| 262 | 263 | inline DebugOptions* get_debug_options() { return &debug_options_; } | |
| 263 | 264 | inline const DebugOptions& debug_options() const { return debug_options_; } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,5 @@ | |||
| 1 | + { | ||
| 2 | + "nodeOptions": { | ||
| 3 | + "max-http-header-size": 10 | ||
| 4 | + } | ||
| 5 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,5 @@ | |||
| 1 | + { | ||
| 2 | + "nodeOptions": { | ||
| 3 | + "max-http-header-size": 20 | ||
| 4 | + } | ||
| 5 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments