fallow_config/config/resolve.rs
1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4/// Module resolver configuration.
5///
6/// Controls how fallow resolves import specifiers against package.json
7/// `exports` / `imports` fields and tsconfig paths. Configured via the
8/// `resolve` section in `.fallowrc.json` or `fallow.toml`.
9///
10/// # Examples
11///
12/// ```json
13/// {
14/// "resolve": {
15/// "conditions": ["development", "worker"]
16/// }
17/// }
18/// ```
19#[derive(Debug, Clone, Default, Deserialize, Serialize, JsonSchema)]
20#[serde(rename_all = "camelCase")]
21pub struct ResolveConfig {
22 /// Additional export/import condition names to honor during module
23 /// resolution. Merged with fallow's built-in conditions (`development`,
24 /// `import`, `require`, `default`, `types`, `node`; plus `react-native`
25 /// and `browser` when the React Native or Expo plugin is active).
26 ///
27 /// User conditions are matched with higher priority than the baseline,
28 /// so a package.json `exports` entry like:
29 ///
30 /// ```json
31 /// { "./api": { "worker": "./src/api.worker.ts", "import": "./dist/api.js" } }
32 /// ```
33 ///
34 /// resolves to the `worker` branch when `"worker"` is listed here.
35 ///
36 /// See <https://nodejs.org/api/packages.html#community-conditions-definitions>
37 /// for the set of community-defined conditions.
38 #[serde(default, skip_serializing_if = "Vec::is_empty")]
39 pub conditions: Vec<String>,
40}