@@ -919,6 +919,69 @@ flows within the application. As such, it is presently recommended to be sure |
919 | 919 | your application behaviour is unaffected by this change before using it in |
920 | 920 | production. |
921 | 921 |
|
| 922 | +### `--experimental-config-file` |
| 923 | + |
| 924 | +<!-- YAML |
| 925 | +added: REPLACEME |
| 926 | +--> |
| 927 | + |
| 928 | +> Stability: 1.0 - Early development |
| 929 | +
|
| 930 | +Use this flag to specify a configuration file that will be loaded and parsed |
| 931 | +before the application starts. |
| 932 | +Node.js will read the configuration file and apply the settings. |
| 933 | +The configuration file should be a JSON file |
| 934 | +with the following structure: |
| 935 | + |
| 936 | +```json |
| 937 | +{ |
| 938 | + "$schema": "https://nodejs.org/dist/REPLACEME/docs/node_config_json_schema.json", |
| 939 | + "experimental-transform-types": true, |
| 940 | + "import": [ |
| 941 | + "amaro/transform" |
| 942 | + ], |
| 943 | + "disable-warning": "ExperimentalWarning", |
| 944 | + "watch-path": "src", |
| 945 | + "watch-preserve-output": true |
| 946 | +} |
| 947 | +``` |
| 948 | + |
| 949 | +Only flags that are allowed in [`NODE_OPTIONS`][] are supported. |
| 950 | +No-op flags are not supported. |
| 951 | +Not all V8 flags are currently supported. |
| 952 | + |
| 953 | +It is possible to use the [official JSON schema](../node_config_json_schema.json) |
| 954 | +to validate the configuration file, which may vary depending on the Node.js version. |
| 955 | +Each key in the configuration file corresponds to a flag that can be passed |
| 956 | +as a command-line argument. The value of the key is the value that would be |
| 957 | +passed to the flag. |
| 958 | + |
| 959 | +For example, the configuration file above is equivalent to |
| 960 | +the following command-line arguments: |
| 961 | + |
| 962 | +```bash |
| 963 | +node --experimental-transform-types --import amaro/transform --disable-warning=ExperimentalWarning --watch-path=src --watch-preserve-output |
| 964 | +``` |
| 965 | + |
| 966 | +The priority in configuration is as follows: |
| 967 | + |
| 968 | +1. NODE\_OPTIONS and command-line options |
| 969 | +2. Configuration file |
| 970 | +3. Dotenv NODE\_OPTIONS |
| 971 | + |
| 972 | +Values in the configuration file will not override the values in the environment |
| 973 | +variables and command-line options, but will override the values in the `NODE_OPTIONS` |
| 974 | +env file parsed by the `--env-file` flag. |
| 975 | + |
| 976 | +If duplicate keys are present in the configuration file, only |
| 977 | +the first key will be used. |
| 978 | + |
| 979 | +The configuration parser will throw an error if the configuration file contains |
| 980 | +unknown keys or keys that cannot used in `NODE_OPTIONS`. |
| 981 | + |
| 982 | +Node.js will not sanitize or perform validation on the user-provided configuration, |
| 983 | +so **NEVER** use untrusted configuration files. |
| 984 | + |
922 | 985 | ### `--experimental-eventsource` |
923 | 986 |
|
924 | 987 | <!-- YAML |
|