@rnx-kit/config
Advanced tools
Comparing version 0.4.24 to 0.5.0
# Change Log - @rnx-kit/config | ||
## 0.5.0 | ||
### Minor Changes | ||
- e2535866: # Breaking Changes | ||
## Schema: align property names with @react-native-community/cli | ||
Add, rename, and remove properties in @rnx-kit/config to fully align with the | ||
well-known names used in @react-native-community/cli. This change will ripple | ||
outward to @rnx-kit/cli as well. | ||
In doing this, we'll be making it easier for developers to migrate to using our | ||
config/cli combination, and our cli will become a "drop in" replacement | ||
@react-native-community/cli. The longer-term goal is to upstream our work into | ||
the community CLI, but until it is proven and accepted, we will continue to | ||
maintain our wrapper commands. | ||
To assist with this change, we detect the use of _old_ property names, and | ||
report detailed failure messages. This will highlight app config that needs to | ||
be updated (which seems better than silently ignoring it). | ||
Add: | ||
- bundleOutput | ||
- sourcemapUseAbsolutePath | ||
Remove: | ||
- bundlePrefix | ||
- distPath | ||
Rename: | ||
- entryPath -> entryFile | ||
- sourceMapPath -> sourcemapOutput | ||
- sourceMapSourcesRootPath -> sourcemapSourcesRoot | ||
- assetsPath -> assetsDest | ||
## getKitConfig(): only search for rnx-kit configuration in package.json | ||
We no longer search for config in places like rnx-kit.config.js (e.g. no more | ||
`cosmiconfig`). | ||
**Why this change?** In all the places we use rnx-kit internally, no one is | ||
using this mechanism. Further, in external forums, there have been general | ||
complaints from JS devs about having too many config files -- package.json is | ||
the preferred "single source". In light of this, it didn't seem worthwhile to | ||
continue carrying `comsmiconfig` as a dependency. | ||
## getBundleDefinition() -> getBundleConfig() | ||
Now takes rnx-kit configuration as input, and outputs a bundle configuration | ||
(which has changed in this release). | ||
No longer provides default values. Returns only what is in configuration. | ||
Defaults have moved into the CLI, which is our opinionated view of how config | ||
should be interpreted. | ||
Drops support for a previously deprecated property `experimental_treeShake`, | ||
which has since been replaced with `treeShake`. | ||
## getBundlePlatformDefinition() -> getPlatformBundleConfig() | ||
Now requires a bundle configuration as input, and outputs a platform-specific | ||
bundle configuration. | ||
No longer provides default values. Returns only what is in configuration. | ||
Defaults have moved into the CLI, which is our opinionated view of how config | ||
should be interpreted. | ||
## getServerConfig() | ||
No longer provides default values. Returns only what is in configuration. | ||
Defaults have moved into the CLI, which is our opinionated view of how config | ||
should be interpreted. | ||
# Non-breaking Changes | ||
## Add fine-grained control for typescriptValidation | ||
Give developers fine-grained control over how TypeScript validation behaves. | ||
## 0.4.24 | ||
@@ -4,0 +87,0 @@ |
@@ -1,5 +0,4 @@ | ||
{"/home/runner/work/rnx-kit/rnx-kit/packages/config/src/getBundleDefinition.ts": {"path":"/home/runner/work/rnx-kit/rnx-kit/packages/config/src/getBundleDefinition.ts","statementMap":{"0":{"start":{"line":16,"column":4},"end":{"line":16,"column":10}},"1":{"start":{"line":17,"column":2},"end":{"line":27,"column":3}},"2":{"start":{"line":18,"column":4},"end":{"line":20,"column":6}},"3":{"start":{"line":21,"column":17},"end":{"line":21,"column":35}},"4":{"start":{"line":22,"column":4},"end":{"line":24,"column":5}},"5":{"start":{"line":23,"column":6},"end":{"line":23,"column":51}},"6":{"start":{"line":25,"column":4},"end":{"line":25,"column":39}},"7":{"start":{"line":26,"column":4},"end":{"line":26,"column":16}},"8":{"start":{"line":28,"column":2},"end":{"line":28,"column":16}},"9":{"start":{"line":45,"column":54},"end":{"line":54,"column":3}},"10":{"start":{"line":55,"column":2},"end":{"line":57,"column":3}},"11":{"start":{"line":56,"column":4},"end":{"line":56,"column":29}},"12":{"start":{"line":59,"column":18},"end":{"line":59,"column":35}},"13":{"start":{"line":60,"column":2},"end":{"line":66,"column":3}},"14":{"start":{"line":61,"column":19},"end":{"line":61,"column":57}},"15":{"start":{"line":61,"column":39},"end":{"line":61,"column":50}},"16":{"start":{"line":62,"column":4},"end":{"line":65,"column":6}},"17":{"start":{"line":68,"column":2},"end":{"line":71,"column":4}},"18":{"start":{"line":85,"column":25},"end":{"line":85,"column":71}},"19":{"start":{"line":86,"column":2},"end":{"line":86,"column":68}}},"fnMap":{"0":{"name":"collapseDeprecatedExperimentalTreeShake","decl":{"start":{"line":12,"column":9},"end":{"line":12,"column":48}},"loc":{"start":{"line":14,"column":20},"end":{"line":29,"column":1}},"line":14},"1":{"name":"getBundleDefinition","decl":{"start":{"line":41,"column":16},"end":{"line":41,"column":35}},"loc":{"start":{"line":44,"column":42},"end":{"line":72,"column":1}},"line":44},"2":{"name":"(anonymous_2)","decl":{"start":{"line":61,"column":32},"end":{"line":61,"column":33}},"loc":{"start":{"line":61,"column":39},"end":{"line":61,"column":50}},"line":61},"3":{"name":"getBundlePlatformDefinition","decl":{"start":{"line":81,"column":16},"end":{"line":81,"column":43}},"loc":{"start":{"line":84,"column":42},"end":{"line":87,"column":1}},"line":84}},"branchMap":{"0":{"loc":{"start":{"line":17,"column":2},"end":{"line":27,"column":3}},"type":"if","locations":[{"start":{"line":17,"column":2},"end":{"line":27,"column":3}},{"start":{},"end":{}}],"line":17},"1":{"loc":{"start":{"line":22,"column":4},"end":{"line":24,"column":5}},"type":"if","locations":[{"start":{"line":22,"column":4},"end":{"line":24,"column":5}},{"start":{},"end":{}}],"line":22},"2":{"loc":{"start":{"line":55,"column":2},"end":{"line":57,"column":3}},"type":"if","locations":[{"start":{"line":55,"column":2},"end":{"line":57,"column":3}},{"start":{},"end":{}}],"line":55},"3":{"loc":{"start":{"line":60,"column":2},"end":{"line":66,"column":3}},"type":"if","locations":[{"start":{"line":60,"column":2},"end":{"line":66,"column":3}},{"start":{},"end":{}}],"line":60},"4":{"loc":{"start":{"line":61,"column":19},"end":{"line":61,"column":57}},"type":"binary-expr","locations":[{"start":{"line":61,"column":19},"end":{"line":61,"column":51}},{"start":{"line":61,"column":55},"end":{"line":61,"column":57}}],"line":61},"5":{"loc":{"start":{"line":85,"column":25},"end":{"line":85,"column":71}},"type":"binary-expr","locations":[{"start":{"line":85,"column":25},"end":{"line":85,"column":41}},{"start":{"line":85,"column":45},"end":{"line":85,"column":71}}],"line":85},"6":{"loc":{"start":{"line":86,"column":9},"end":{"line":86,"column":67}},"type":"cond-expr","locations":[{"start":{"line":86,"column":26},"end":{"line":86,"column":58}},{"start":{"line":86,"column":61},"end":{"line":86,"column":67}}],"line":86}},"s":{"0":4,"1":4,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":3,"9":5,"10":5,"11":1,"12":4,"13":4,"14":2,"15":4,"16":2,"17":2,"18":3,"19":3},"f":{"0":4,"1":5,"2":4,"3":3},"b":{"0":[1,3],"1":[1,0],"2":[1,4],"3":[2,2],"4":[2,1],"5":[3,2],"6":[1,2]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"eb03dfefc5718a34e99415fd1c46ed2836e2cb21"} | ||
{"/home/runner/work/rnx-kit/rnx-kit/packages/config/src/getBundleConfig.ts": {"path":"/home/runner/work/rnx-kit/rnx-kit/packages/config/src/getBundleConfig.ts","statementMap":{"0":{"start":{"line":11,"column":2},"end":{"line":15,"column":3}},"1":{"start":{"line":12,"column":4},"end":{"line":14,"column":6}},"2":{"start":{"line":23,"column":2},"end":{"line":23,"column":74}},"3":{"start":{"line":27,"column":2},"end":{"line":27,"column":71}},"4":{"start":{"line":29,"column":2},"end":{"line":29,"column":58}},"5":{"start":{"line":30,"column":2},"end":{"line":30,"column":68}},"6":{"start":{"line":31,"column":2},"end":{"line":35,"column":4}},"7":{"start":{"line":36,"column":2},"end":{"line":36,"column":60}},"8":{"start":{"line":38,"column":2},"end":{"line":42,"column":4}},"9":{"start":{"line":43,"column":2},"end":{"line":47,"column":4}},"10":{"start":{"line":63,"column":2},"end":{"line":65,"column":3}},"11":{"start":{"line":64,"column":4},"end":{"line":64,"column":21}},"12":{"start":{"line":69,"column":2},"end":{"line":73,"column":3}},"13":{"start":{"line":70,"column":4},"end":{"line":72,"column":6}},"14":{"start":{"line":75,"column":18},"end":{"line":75,"column":42}},"15":{"start":{"line":78,"column":2},"end":{"line":82,"column":3}},"16":{"start":{"line":79,"column":4},"end":{"line":79,"column":46}},"17":{"start":{"line":79,"column":33},"end":{"line":79,"column":44}},"18":{"start":{"line":81,"column":4},"end":{"line":81,"column":57}},"19":{"start":{"line":83,"column":2},"end":{"line":85,"column":3}},"20":{"start":{"line":84,"column":4},"end":{"line":84,"column":21}},"21":{"start":{"line":89,"column":2},"end":{"line":89,"column":33}},"22":{"start":{"line":91,"column":2},"end":{"line":91,"column":16}},"23":{"start":{"line":105,"column":25},"end":{"line":107,"column":15}},"24":{"start":{"line":108,"column":2},"end":{"line":108,"column":68}}},"fnMap":{"0":{"name":"failOnUnsupportedProp","decl":{"start":{"line":6,"column":9},"end":{"line":6,"column":30}},"loc":{"start":{"line":10,"column":8},"end":{"line":16,"column":1}},"line":10},"1":{"name":"failOnRenamedProp","decl":{"start":{"line":18,"column":9},"end":{"line":18,"column":26}},"loc":{"start":{"line":22,"column":8},"end":{"line":24,"column":1}},"line":22},"2":{"name":"failOnUnsupportedProps","decl":{"start":{"line":26,"column":9},"end":{"line":26,"column":31}},"loc":{"start":{"line":26,"column":68},"end":{"line":48,"column":1}},"line":26},"3":{"name":"getBundleConfig","decl":{"start":{"line":59,"column":16},"end":{"line":59,"column":31}},"loc":{"start":{"line":62,"column":28},"end":{"line":92,"column":1}},"line":62},"4":{"name":"(anonymous_4)","decl":{"start":{"line":79,"column":26},"end":{"line":79,"column":27}},"loc":{"start":{"line":79,"column":33},"end":{"line":79,"column":44}},"line":79},"5":{"name":"getPlatformBundleConfig","decl":{"start":{"line":101,"column":16},"end":{"line":101,"column":39}},"loc":{"start":{"line":104,"column":16},"end":{"line":109,"column":1}},"line":104}},"branchMap":{"0":{"loc":{"start":{"line":11,"column":2},"end":{"line":15,"column":3}},"type":"if","locations":[{"start":{"line":11,"column":2},"end":{"line":15,"column":3}},{"start":{},"end":{}}],"line":11},"1":{"loc":{"start":{"line":63,"column":2},"end":{"line":65,"column":3}},"type":"if","locations":[{"start":{"line":63,"column":2},"end":{"line":65,"column":3}},{"start":{},"end":{}}],"line":63},"2":{"loc":{"start":{"line":69,"column":2},"end":{"line":73,"column":3}},"type":"if","locations":[{"start":{"line":69,"column":2},"end":{"line":73,"column":3}},{"start":{},"end":{}}],"line":69},"3":{"loc":{"start":{"line":78,"column":2},"end":{"line":82,"column":3}},"type":"if","locations":[{"start":{"line":78,"column":2},"end":{"line":82,"column":3}},{"start":{"line":80,"column":9},"end":{"line":82,"column":3}}],"line":78},"4":{"loc":{"start":{"line":81,"column":13},"end":{"line":81,"column":56}},"type":"cond-expr","locations":[{"start":{"line":81,"column":34},"end":{"line":81,"column":44}},{"start":{"line":81,"column":47},"end":{"line":81,"column":56}}],"line":81},"5":{"loc":{"start":{"line":83,"column":2},"end":{"line":85,"column":3}},"type":"if","locations":[{"start":{"line":83,"column":2},"end":{"line":85,"column":3}},{"start":{},"end":{}}],"line":83},"6":{"loc":{"start":{"line":105,"column":25},"end":{"line":107,"column":15}},"type":"cond-expr","locations":[{"start":{"line":106,"column":6},"end":{"line":106,"column":32}},{"start":{"line":107,"column":6},"end":{"line":107,"column":15}}],"line":105},"7":{"loc":{"start":{"line":108,"column":9},"end":{"line":108,"column":67}},"type":"cond-expr","locations":[{"start":{"line":108,"column":26},"end":{"line":108,"column":58}},{"start":{"line":108,"column":61},"end":{"line":108,"column":67}}],"line":108}},"s":{"0":37,"1":6,"2":30,"3":8,"4":7,"5":6,"6":5,"7":4,"8":4,"9":3,"10":13,"11":2,"12":11,"13":1,"14":10,"15":10,"16":2,"17":4,"18":8,"19":10,"20":2,"21":8,"22":2,"23":3,"24":3},"f":{"0":37,"1":30,"2":8,"3":13,"4":4,"5":3},"b":{"0":[6,31],"1":[2,11],"2":[1,10],"3":[2,8],"4":[7,1],"5":[2,8],"6":[2,1],"7":[1,2]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"56e5c87c327085e8ff8644a49a72960da749b021"} | ||
,"/home/runner/work/rnx-kit/rnx-kit/packages/config/src/getKitCapabilities.ts": {"path":"/home/runner/work/rnx-kit/rnx-kit/packages/config/src/getKitCapabilities.ts","statementMap":{"0":{"start":{"line":23,"column":2},"end":{"line":29,"column":3}},"1":{"start":{"line":28,"column":4},"end":{"line":28,"column":76}},"2":{"start":{"line":31,"column":2},"end":{"line":33,"column":3}},"3":{"start":{"line":32,"column":4},"end":{"line":32,"column":72}},"4":{"start":{"line":36,"column":4},"end":{"line":36,"column":67}},"5":{"start":{"line":38,"column":2},"end":{"line":45,"column":3}},"6":{"start":{"line":42,"column":4},"end":{"line":44,"column":6}},"7":{"start":{"line":47,"column":2},"end":{"line":53,"column":4}}},"fnMap":{"0":{"name":"getKitCapabilities","decl":{"start":{"line":16,"column":16},"end":{"line":16,"column":34}},"loc":{"start":{"line":22,"column":31},"end":{"line":54,"column":1}},"line":22}},"branchMap":{"0":{"loc":{"start":{"line":17,"column":2},"end":{"line":17,"column":19}},"type":"default-arg","locations":[{"start":{"line":17,"column":17},"end":{"line":17,"column":19}}],"line":17},"1":{"loc":{"start":{"line":18,"column":2},"end":{"line":18,"column":21}},"type":"default-arg","locations":[{"start":{"line":18,"column":12},"end":{"line":18,"column":21}}],"line":18},"2":{"loc":{"start":{"line":23,"column":2},"end":{"line":29,"column":3}},"type":"if","locations":[{"start":{"line":23,"column":2},"end":{"line":29,"column":3}},{"start":{},"end":{}}],"line":23},"3":{"loc":{"start":{"line":24,"column":4},"end":{"line":26,"column":45}},"type":"binary-expr","locations":[{"start":{"line":24,"column":4},"end":{"line":24,"column":23}},{"start":{"line":25,"column":5},"end":{"line":25,"column":38}},{"start":{"line":26,"column":6},"end":{"line":26,"column":44}}],"line":24},"4":{"loc":{"start":{"line":31,"column":2},"end":{"line":33,"column":3}},"type":"if","locations":[{"start":{"line":31,"column":2},"end":{"line":33,"column":3}},{"start":{},"end":{}}],"line":31},"5":{"loc":{"start":{"line":31,"column":6},"end":{"line":31,"column":40}},"type":"binary-expr","locations":[{"start":{"line":31,"column":6},"end":{"line":31,"column":23}},{"start":{"line":31,"column":27},"end":{"line":31,"column":40}}],"line":31},"6":{"loc":{"start":{"line":36,"column":4},"end":{"line":36,"column":67}},"type":"binary-expr","locations":[{"start":{"line":36,"column":4},"end":{"line":36,"column":17}},{"start":{"line":36,"column":21},"end":{"line":36,"column":67}}],"line":36},"7":{"loc":{"start":{"line":38,"column":2},"end":{"line":45,"column":3}},"type":"if","locations":[{"start":{"line":38,"column":2},"end":{"line":45,"column":3}},{"start":{},"end":{}}],"line":38},"8":{"loc":{"start":{"line":39,"column":4},"end":{"line":40,"column":61}},"type":"binary-expr","locations":[{"start":{"line":39,"column":4},"end":{"line":39,"column":26}},{"start":{"line":40,"column":4},"end":{"line":40,"column":61}}],"line":39}},"s":{"0":21,"1":2,"2":19,"3":1,"4":19,"5":19,"6":3,"7":16},"f":{"0":21},"b":{"0":[19],"1":[18],"2":[2,19],"3":[21,19,9],"4":[1,18],"5":[19,2],"6":[19,11],"7":[3,16],"8":[19,19]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"1e94e0a47bdefec5b9484694472c3272d678f0cb"} | ||
,"/home/runner/work/rnx-kit/rnx-kit/packages/config/src/getKitConfig.ts": {"path":"/home/runner/work/rnx-kit/rnx-kit/packages/config/src/getKitConfig.ts","statementMap":{"0":{"start":{"line":24,"column":14},"end":{"line":26,"column":34}},"1":{"start":{"line":29,"column":23},"end":{"line":29,"column":67}},"2":{"start":{"line":30,"column":17},"end":{"line":30,"column":41}},"3":{"start":{"line":31,"column":2},"end":{"line":31,"column":32}}},"fnMap":{"0":{"name":"getKitConfig","decl":{"start":{"line":20,"column":16},"end":{"line":20,"column":28}},"loc":{"start":{"line":22,"column":20},"end":{"line":32,"column":1}},"line":22}},"branchMap":{"0":{"loc":{"start":{"line":21,"column":2},"end":{"line":21,"column":35}},"type":"default-arg","locations":[{"start":{"line":21,"column":33},"end":{"line":21,"column":35}}],"line":21},"1":{"loc":{"start":{"line":24,"column":14},"end":{"line":26,"column":34}},"type":"cond-expr","locations":[{"start":{"line":25,"column":6},"end":{"line":25,"column":69}},{"start":{"line":26,"column":6},"end":{"line":26,"column":34}}],"line":24},"2":{"loc":{"start":{"line":26,"column":6},"end":{"line":26,"column":34}},"type":"binary-expr","locations":[{"start":{"line":26,"column":6},"end":{"line":26,"column":17}},{"start":{"line":26,"column":21},"end":{"line":26,"column":34}}],"line":26},"3":{"loc":{"start":{"line":31,"column":9},"end":{"line":31,"column":31}},"type":"binary-expr","locations":[{"start":{"line":31,"column":9},"end":{"line":31,"column":23}},{"start":{"line":31,"column":27},"end":{"line":31,"column":31}}],"line":31}},"s":{"0":4,"1":4,"2":4,"3":4},"f":{"0":4},"b":{"0":[3],"1":[0,4],"2":[4,3],"3":[4,1]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"f57db9dc1e666ea22e39aadff1a98a1d3f1f957f"} | ||
,"/home/runner/work/rnx-kit/rnx-kit/packages/config/src/getServerConfig.ts": {"path":"/home/runner/work/rnx-kit/rnx-kit/packages/config/src/getServerConfig.ts","statementMap":{"0":{"start":{"line":16,"column":54},"end":{"line":21,"column":3}},"1":{"start":{"line":23,"column":2},"end":{"line":23,"column":56}}},"fnMap":{"0":{"name":"getServerConfig","decl":{"start":{"line":13,"column":16},"end":{"line":13,"column":31}},"loc":{"start":{"line":15,"column":32},"end":{"line":24,"column":1}},"line":15}},"branchMap":{"0":{"loc":{"start":{"line":23,"column":33},"end":{"line":23,"column":52}},"type":"binary-expr","locations":[{"start":{"line":23,"column":33},"end":{"line":23,"column":46}},{"start":{"line":23,"column":50},"end":{"line":23,"column":52}}],"line":23}},"s":{"0":3,"1":3},"f":{"0":3},"b":{"0":[3,1]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"14530990dc3526d9973a45f1a485b7de0a2dcb79"} | ||
,"/home/runner/work/rnx-kit/rnx-kit/packages/config/src/getKitConfig.ts": {"path":"/home/runner/work/rnx-kit/rnx-kit/packages/config/src/getKitConfig.ts","statementMap":{"0":{"start":{"line":30,"column":21},"end":{"line":32,"column":34}},"1":{"start":{"line":35,"column":2},"end":{"line":40,"column":3}},"2":{"start":{"line":36,"column":24},"end":{"line":36,"column":47}},"3":{"start":{"line":37,"column":4},"end":{"line":37,"column":34}},"4":{"start":{"line":39,"column":4},"end":{"line":39,"column":21}}},"fnMap":{"0":{"name":"getKitConfig","decl":{"start":{"line":26,"column":16},"end":{"line":26,"column":28}},"loc":{"start":{"line":28,"column":25},"end":{"line":41,"column":1}},"line":28}},"branchMap":{"0":{"loc":{"start":{"line":27,"column":2},"end":{"line":27,"column":35}},"type":"default-arg","locations":[{"start":{"line":27,"column":33},"end":{"line":27,"column":35}}],"line":27},"1":{"loc":{"start":{"line":30,"column":21},"end":{"line":32,"column":34}},"type":"cond-expr","locations":[{"start":{"line":31,"column":6},"end":{"line":31,"column":69}},{"start":{"line":32,"column":6},"end":{"line":32,"column":34}}],"line":30},"2":{"loc":{"start":{"line":32,"column":6},"end":{"line":32,"column":34}},"type":"binary-expr","locations":[{"start":{"line":32,"column":6},"end":{"line":32,"column":17}},{"start":{"line":32,"column":21},"end":{"line":32,"column":34}}],"line":32}},"s":{"0":6,"1":6,"2":6,"3":6,"4":0},"f":{"0":6},"b":{"0":[2],"1":[2,4],"2":[4,2]},"_coverageSchema":"1a1c01bbd47fc00a2c39e90264f33305004495a9","hash":"73d896ad05137996e1b735881595486f4a7b0969"} | ||
} |
@@ -5,39 +5,31 @@ import type { AllPlatforms } from "@rnx-kit/tools-react-native/platform"; | ||
import type { OutputOptions } from "metro"; | ||
export declare type TypeScriptValidationOptions = { | ||
/** | ||
* Controls whether an error is thrown when type-validation fails. | ||
*/ | ||
throwOnError?: boolean; | ||
}; | ||
/** | ||
* Parameters controlling bundler behavior at runtime. | ||
* Parameters controlling bundler plugins. | ||
*/ | ||
export declare type BundlerRuntimeParameters = { | ||
export declare type BundlerPlugins = { | ||
/** | ||
* Choose whether to detect cycles in the dependency graph. If true, then a default set | ||
* of options will be used. Otherwise the object allows for fine-grained control over | ||
* the detection process. | ||
* | ||
* @default true | ||
* Choose whether to detect cycles in the dependency graph. `true` uses defaults, | ||
* while `CyclicDetectorOptions` lets you control the detection process. | ||
*/ | ||
detectCyclicDependencies: boolean | CyclicDetectorOptions; | ||
detectCyclicDependencies?: boolean | CyclicDetectorOptions; | ||
/** | ||
* Choose whether to detect duplicate packages in the dependency graph. | ||
* | ||
* A duplicate error happens when a package is imported from two or more unique paths, | ||
* even if the versions are all the same. Duplicate packages increase bundle size and | ||
* can lead to unexpected errors. | ||
* | ||
* If true, then a default set of options will be used. Otherwise the object allows for | ||
* fine-grained control over the detection process. | ||
* | ||
* @default true | ||
* Choose whether to detect duplicate packages in the dependency graph. `true` uses defaults, | ||
* while `DuplicateDetectorOptions` lets you control the detection process. | ||
*/ | ||
detectDuplicateDependencies: boolean | DuplicateDetectorOptions; | ||
detectDuplicateDependencies?: boolean | DuplicateDetectorOptions; | ||
/** | ||
* Choose whether to type-check source files using TypeScript. | ||
* | ||
* @default true | ||
* Choose whether to type-check source files using TypeScript. `true` uses defaults, | ||
* while `TypeScriptValidationOptions` lets you control the validation process. | ||
*/ | ||
typescriptValidation: boolean; | ||
typescriptValidation?: boolean | TypeScriptValidationOptions; | ||
/** | ||
* Choose whether to enable tree shaking. | ||
* | ||
* @default false | ||
*/ | ||
treeShake: boolean; | ||
treeShake?: boolean; | ||
}; | ||
@@ -47,34 +39,13 @@ /** | ||
*/ | ||
export declare type BundleRequiredParameters = BundlerRuntimeParameters & { | ||
export declare type BundleParameters = BundlerPlugins & { | ||
/** | ||
* Path to the .js file which is the entry-point for building the bundle. | ||
* Either absolute, or relative to the package. | ||
* | ||
* @default "lib/index.js" | ||
*/ | ||
entryPath: string; | ||
entryFile?: string; | ||
/** | ||
* Path where the bundle and source map files are written. | ||
* Either absolute, or relative to the package. | ||
* | ||
* @default "dist" | ||
* Path to the output bundle file. Either absolute or relative to the package. | ||
*/ | ||
distPath: string; | ||
bundleOutput?: string; | ||
/** | ||
* Path where all bundle assets (strings, images, fonts, sounds, ...) are written. | ||
* Either absolute, or relative to the package. | ||
* | ||
* @default "dist" | ||
*/ | ||
assetsPath: string; | ||
/** | ||
* Prefix for the bundle name, followed by the platform and either ".bundle" (win, android) | ||
* or ".jsbundle" (mac, ios). | ||
* | ||
* @default "index" | ||
*/ | ||
bundlePrefix: string; | ||
}; | ||
export declare type BundleParameters = Partial<BundleRequiredParameters> & { | ||
/** | ||
* Encoding scheme to use when writing the bundle file. Currently limited | ||
@@ -90,23 +61,32 @@ * to UTF-8, UTF-16 (little endian), and 7-bit ASCII. | ||
*/ | ||
sourceMapPath?: string; | ||
sourcemapOutput?: string; | ||
/** | ||
* Path to the package's source files. Used to make source-map paths relative and therefore portable. | ||
*/ | ||
sourceMapSourceRootPath?: string; | ||
sourcemapSourcesRoot?: string; | ||
/** | ||
* Controls whether or not SourceMapURL is reported as a full path or just a file name. | ||
*/ | ||
sourcemapUseAbsolutePath?: boolean; | ||
/** | ||
* Path where all bundle assets (strings, images, fonts, sounds, ...) are written. | ||
* Either absolute, or relative to the package. If not given, assets are ignored. | ||
*/ | ||
assetsDest?: string; | ||
}; | ||
/** | ||
* Defines how a kit is bundled. Includes shared bundling parameters with platform-specific overrides. | ||
* Defines how a package is bundled. Includes shared bundling parameters with platform-specific overrides. | ||
*/ | ||
export declare type BundleDefinition = BundleParameters & { | ||
export declare type BundleConfig = BundleParameters & { | ||
/** | ||
* Unique identifier for this bundle definition. Only used as a reference within the kit build system. | ||
* Unique identifier for this bundle configuration. Only needed when specifying multiple bundle configurations. | ||
*/ | ||
id?: string; | ||
/** | ||
* The platform(s) for which this kit may be bundled. | ||
* The platform(s) for which this package may be bundled. | ||
*/ | ||
targets?: AllPlatforms[]; | ||
/** | ||
* Platform-specific overrides for bundling parameters. Any parameter not listed in an override gets | ||
* its value from the shared bundle definition, or falls back to defaults. | ||
* Platform-specific overrides for bundling. Any parameter not listed in an override gets | ||
* its value from the shared bundle configuration, or falls back to defaults. | ||
*/ | ||
@@ -117,7 +97,2 @@ platforms?: { | ||
}; | ||
/** | ||
* Bundle configuration for a kit. If true, then all defaults will be used. | ||
* Otherwise, the bundle definition object(s) allow more detailed specification of bundling parameters. | ||
*/ | ||
export declare type BundleConfig = boolean | BundleDefinition | BundleDefinition[]; | ||
//# sourceMappingURL=bundleConfig.d.ts.map |
@@ -7,11 +7,17 @@ import { KitConfig } from "./kitConfig"; | ||
/** | ||
* Retrieve the kit config options, if they exist, from the specified module. | ||
* Retrieve the rnx-kit configuration from a package module. | ||
*/ | ||
module?: string; | ||
/** | ||
* Retrive teh kit config options, using the target working directory. | ||
* Retrive the rnx-kit configuration from a directory containing 'package.json'. | ||
*/ | ||
cwd?: string; | ||
}; | ||
export declare function getKitConfig(options?: GetKitConfigOptions): KitConfig | null; | ||
/** | ||
* Query for a package's rnx-kit configuration. | ||
* | ||
* @param options Options for retrieving the configuration. | ||
* @returns | ||
*/ | ||
export declare function getKitConfig(options?: GetKitConfigOptions): KitConfig | undefined; | ||
//# sourceMappingURL=getKitConfig.d.ts.map |
@@ -7,16 +7,25 @@ "use strict"; | ||
exports.getKitConfig = void 0; | ||
const cosmiconfig_1 = require("cosmiconfig"); | ||
const path_1 = __importDefault(require("path")); | ||
const tools_node_1 = require("@rnx-kit/tools-node"); | ||
/** | ||
* Query for a package's rnx-kit configuration. | ||
* | ||
* @param options Options for retrieving the configuration. | ||
* @returns | ||
*/ | ||
function getKitConfig(options = {}) { | ||
var _a; | ||
// use a working directory extracted from a module, specified in cwd, or from process.cwd | ||
const cwd = options.module | ||
// find the package dir that holds the rnx-kit configuration | ||
const packageDir = options.module | ||
? path_1.default.dirname(require.resolve(options.module + "/package.json")) | ||
: options.cwd || process.cwd(); | ||
// use the synchronous cosmiconfig load method to see if there is kit info present at the specified location | ||
const explorerSync = (0, cosmiconfig_1.cosmiconfigSync)("rnx-kit", { stopDir: cwd }); | ||
const result = explorerSync.search(cwd); | ||
return (_a = result === null || result === void 0 ? void 0 : result.config) !== null && _a !== void 0 ? _a : null; | ||
// try to read package.json | ||
try { | ||
const packageJson = (0, tools_node_1.readPackage)(packageDir); | ||
return packageJson["rnx-kit"]; | ||
} | ||
catch (_a) { | ||
return undefined; | ||
} | ||
} | ||
exports.getKitConfig = getKitConfig; | ||
//# sourceMappingURL=getKitConfig.js.map |
@@ -1,4 +0,3 @@ | ||
export type { BundleConfig, BundleDefinition, BundleParameters, BundleRequiredParameters, BundlerRuntimeParameters, } from "./bundleConfig"; | ||
export { getBundleDefinition, getBundlePlatformDefinition, } from "./getBundleDefinition"; | ||
export type { BundleDefinitionWithRequiredParameters } from "./getBundleDefinition"; | ||
export type { BundleConfig, BundleParameters, BundlerPlugins, TypeScriptValidationOptions, } from "./bundleConfig"; | ||
export { getBundleConfig, getPlatformBundleConfig } from "./getBundleConfig"; | ||
export { getKitCapabilities } from "./getKitCapabilities"; | ||
@@ -8,6 +7,4 @@ export type { KitCapabilities } from "./getKitCapabilities"; | ||
export type { GetKitConfigOptions } from "./getKitConfig"; | ||
export { getServerConfig } from "./getServerConfig"; | ||
export type { ServerWithRequiredParameters } from "./getServerConfig"; | ||
export type { Capability, DependencyVersions, GetDependencyVersions, KitConfig, KitType, MetaCapability, } from "./kitConfig"; | ||
export type { ServerRequiredParameters, ServerParameters, ServerConfig, } from "./serverConfig"; | ||
export type { ServerConfig } from "./serverConfig"; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getServerConfig = exports.getKitConfig = exports.getKitCapabilities = exports.getBundlePlatformDefinition = exports.getBundleDefinition = void 0; | ||
var getBundleDefinition_1 = require("./getBundleDefinition"); | ||
Object.defineProperty(exports, "getBundleDefinition", { enumerable: true, get: function () { return getBundleDefinition_1.getBundleDefinition; } }); | ||
Object.defineProperty(exports, "getBundlePlatformDefinition", { enumerable: true, get: function () { return getBundleDefinition_1.getBundlePlatformDefinition; } }); | ||
exports.getKitConfig = exports.getKitCapabilities = exports.getPlatformBundleConfig = exports.getBundleConfig = void 0; | ||
var getBundleConfig_1 = require("./getBundleConfig"); | ||
Object.defineProperty(exports, "getBundleConfig", { enumerable: true, get: function () { return getBundleConfig_1.getBundleConfig; } }); | ||
Object.defineProperty(exports, "getPlatformBundleConfig", { enumerable: true, get: function () { return getBundleConfig_1.getPlatformBundleConfig; } }); | ||
var getKitCapabilities_1 = require("./getKitCapabilities"); | ||
@@ -11,4 +11,2 @@ Object.defineProperty(exports, "getKitCapabilities", { enumerable: true, get: function () { return getKitCapabilities_1.getKitCapabilities; } }); | ||
Object.defineProperty(exports, "getKitConfig", { enumerable: true, get: function () { return getKitConfig_1.getKitConfig; } }); | ||
var getServerConfig_1 = require("./getServerConfig"); | ||
Object.defineProperty(exports, "getServerConfig", { enumerable: true, get: function () { return getServerConfig_1.getServerConfig; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -9,3 +9,3 @@ import type { BundleConfig } from "./bundleConfig"; | ||
/** | ||
* Configuration information for an rnx-kit. This is retrieved via cosmi-config | ||
* Configuration information for an rnx-kit package. This is retrieved from 'rnx-kit' in package.json. | ||
*/ | ||
@@ -31,8 +31,7 @@ export declare type KitConfig = { | ||
/** | ||
* Specifies how the kit is bundled. When not defined, the kit cannot be bundled. | ||
* Specifies how the package is bundled. | ||
*/ | ||
bundle?: BundleConfig; | ||
bundle?: BundleConfig | BundleConfig[]; | ||
/** | ||
* Specifies how the kit's development bundle-server is configured. When not defined, | ||
* the kit will be served using default values. | ||
* Specifies how the package's bundle server is configured. | ||
*/ | ||
@@ -39,0 +38,0 @@ server?: ServerConfig; |
@@ -1,4 +0,3 @@ | ||
import type { BundlerRuntimeParameters } from "./bundleConfig"; | ||
export declare type ServerRequiredParameters = BundlerRuntimeParameters; | ||
export declare type ServerParameters = Partial<ServerRequiredParameters> & { | ||
import type { BundlerPlugins } from "./bundleConfig"; | ||
export declare type ServerConfig = BundlerPlugins & { | ||
/** | ||
@@ -25,3 +24,2 @@ * Path to the root of your react-native experience project. The bundle server uses | ||
}; | ||
export declare type ServerConfig = ServerParameters; | ||
//# sourceMappingURL=serverConfig.d.ts.map |
{ | ||
"name": "@rnx-kit/config", | ||
"version": "0.4.24", | ||
"version": "0.5.0", | ||
"description": "Define and query information about a kit package", | ||
@@ -22,3 +22,3 @@ "license": "MIT", | ||
"@rnx-kit/console": "^1.0.11", | ||
"cosmiconfig": "^7.0.0", | ||
"@rnx-kit/tools-node": "^1.2.7", | ||
"lodash": "^4.17.21", | ||
@@ -36,3 +36,3 @@ "semver": "^7.0.0" | ||
"@types/semver": "^7.0.0", | ||
"jest-extended": "^0.11.5" | ||
"jest-extended": "^2.0.0" | ||
}, | ||
@@ -49,6 +49,10 @@ "depcheck": { | ||
"preset": "@rnx-kit/scripts", | ||
"moduleDirectories": [ | ||
"node_modules", | ||
"test/__fixtures__/node_modules" | ||
], | ||
"setupFilesAfterEnv": [ | ||
"jest-extended" | ||
"jest-extended/all" | ||
] | ||
} | ||
} |
134
README.md
@@ -23,30 +23,25 @@ <!--remove-block start--> | ||
| Name | Type | Description | | ||
| --------------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| kitType | "app", "library", undefined | Library or App package. Used by the dependency manager when projecting capabilities into `dependencies`, `devDependencies`, and `peerDependencies`. Library package dependencies are private, in dev and peer. App package dependencies are public. | | ||
| reactNativeVersion | string, undefined | React Native version (or range) which this package supports. | | ||
| reactNativeDevVersion | string, undefined | React Native version to use during development of this package. If not specified, the minimum `reactNativeVersion` is used. | | ||
| bundle | `BundleConfig`, undefined | Bundler configuration for a package. If true, then all defaults will be used. If a `BundleDefinition` (or array) is given, the object(s) are a detailed specification of the bundling configurtion. If undefined, this package does not support bundling. | | ||
| server | `ServerConfig`, undefined | Bundle server configuration. If not specified, this package does not support bundle serving. | | ||
| capabilities | `Capability[]`, undefined | List of [capabilities](https://github.com/microsoft/rnx-kit/tree/main/packages/dep-check#capabilities) that this package needs. A capability is a well-known name (string). | | ||
| customProfiles | string, undefined | Path to a file containing [custom profiles](https://github.com/microsoft/rnx-kit/tree/main/packages/dep-check#custom-profiles). | | ||
Configuration information for an rnx-kit package. This is retrieved from | ||
'rnx-kit' in package.json. | ||
### `BundleConfig` | ||
| Name | Type | Description | | ||
| --------------------- | ------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| kitType | "app", "library", undefined | Library or App package. Used by the dependency manager when projecting capabilities into `dependencies`, `devDependencies`, and `peerDependencies`. Library package dependencies are private, in dev and peer. App package dependencies are public. | | ||
| reactNativeVersion | string, undefined | React Native version (or range) which this package supports. | | ||
| reactNativeDevVersion | string, undefined | React Native version to use during development of this package. If not specified, the minimum `reactNativeVersion` is used. | | ||
| bundle | `BundleConfig`, `BundleConfig[]`, undefined | Specifies how the package is bundled. | | ||
| server | `ServerConfig`, undefined | Specifies how the package's bundle server is configured. | | ||
| capabilities | `Capability[]`, undefined | List of [capabilities](https://github.com/microsoft/rnx-kit/tree/main/packages/dep-check#capabilities) that this package needs. A capability is a well-known name (string). | | ||
| customProfiles | string, undefined | Path to a file containing [custom profiles](https://github.com/microsoft/rnx-kit/tree/main/packages/dep-check#custom-profiles). | | ||
Union of: boolean, `BundleDefinition`, `BundleDefinition[]` | ||
### `BundleConfig` inherits `BundleParameters` | ||
### `BundleDefinition` inherits `BundlerRuntimeParameters` | ||
Defines how a package is bundled. Includes shared bundling parameters with | ||
platform-specific overrides. | ||
| Name | Type | Default | Description | | ||
| ----------------------- | ------------------------------------------------------ | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| id | string, undefined | | Unique identifier for this bundle definition. Only used as a reference within the build system. | | ||
| targets | `AllPlatforms[]`, undefined | | The platform(s) for which this package may be bundled. | | ||
| platforms | {[K in `AllPlatforms`]: `BundleDefinition`}, undefined | | Platform-specific overrides for bundling parameters. Any parameter not listed in an override gets its value from the shared bundle definition, or falls back to defaults. | | ||
| entryPath | string, undefined | lib/index.js | Path to the .js file which is the entry-point for building the bundle. Either absolute, or relative to the package. | | ||
| distPath | string, undefined | dist | Path where the bundle and source map files are written. Either absolute, or relative to the package. | | ||
| assetsPath | string, undefined | dist | Path where all bundle assets (strings, images, fonts, sounds, ...) are written. Either absolute, or relative to the package. | | ||
| bundlePrefix | string, undefined | index | Prefix for the bundle name, followed by the platform and either ".bundle" (win, android) or ".jsbundle" (mac, ios). | | ||
| bundleEncoding | string, undefined | | [Encoding scheme](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings) to use when writing the bundle file. Currently limited to UTF-8, UTF-16 (little endian), and 7-bit ASCII. | | ||
| sourceMapPath | string, undefined | | Path to use when creating the bundle source map file. Either absolute, or relative to the package. | | ||
| sourceMapSourceRootPath | string, undefined | | Path to the package's source files. Used to make source-map paths relative and therefore portable. | | ||
| Name | Type | Description | | ||
| --------- | ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| id | string, undefined | Unique identifier for this bundle definition. Only used as a reference within the build system. | | ||
| targets | `AllPlatforms[]`, undefined | The platform(s) for which this package may be bundled. | | ||
| platforms | {[K in `AllPlatforms`]: `BundleDefinition`}, undefined | Platform-specific overrides for bundling parameters. Any parameter not listed in an override gets its value from the shared bundle definition, or falls back to defaults. | | ||
@@ -57,11 +52,27 @@ ### `AllPlatforms` | ||
### `BundlerRuntimeParameters` | ||
### `BundleParameters` inherits `BundlerPlugins` | ||
| Name | Type | Default | Description | | ||
| --------------------------- | ---------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| detectCyclicDependencies | boolean, `CyclicDetectorOptions`, undefined | true | Choose whether to detect cycles in the dependency graph. If true, then a default set of options will be used. If `CyclicDetectorOptions` is given, the object is a detailed specification of cyclic detector configuration. | | ||
| detectDuplicateDependencies | boolean, `DuplicateDetectorOptions`, undefined | true | Choose whether to detect duplicate packages in the dependency graph. If true, then a default set of options will be used. If `DuplicateDetectorOptions` is given, the object is a detailed specification of the duplicate detector configuration. | | ||
| typescriptValidation | boolean, undefined | true | Choose whether to type-check the application during bundling and serving. | | ||
| treeShake | boolean, undefined | false | Choose whether to enable tree shaking. | | ||
Parameters controlling how a bundle is constructed. | ||
| Name | Type | Description | | ||
| ------------------------ | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| entryFile | string, undefined | Path to the .js file which is the entry-point for building the bundle. Either absolute, or relative to the package. | | ||
| bundleOutput | string, undefined | Path to the output bundle file. Either absolute or relative to the package. | | ||
| bundleEncoding | string, undefined | [Encoding scheme](https://nodejs.org/api/buffer.html#buffer_buffers_and_character_encodings) to use when writing the bundle file. Currently limited to UTF-8, UTF-16 (little endian), and 7-bit ASCII. | | ||
| sourcemapOutput | string, undefined | Path to use when creating the bundle source map file. Either absolute, or relative to the package. | | ||
| sourcemapSourcesRoot | string, undefined | Path to the package's source files. Used to make source-map paths relative and therefore portable. | | ||
| sourcemapUseAbsolutePath | boolean, undefined | Controls whether or not SourceMapURL is reported as a full path or just a file name. | | ||
| assetsDest | string, undefined | Path where all bundle assets (strings, images, fonts, sounds, ...) are written. Either absolute, or relative to the package. | | ||
### `BundlerPlugins` | ||
Parameters controlling bundler plugins. | ||
| Name | Type | Description | | ||
| --------------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| detectCyclicDependencies | boolean, `CyclicDetectorOptions`, undefined | Choose whether to detect cycles in the dependency graph. `true` uses defaults, while `CyclicDetectorOptions` lets you control the detection process. | | ||
| detectDuplicateDependencies | boolean, `DuplicateDetectorOptions`, undefined | Choose whether to detect duplicate packages in the dependency graph. `true` uses defaults, while `DuplicateDetectorOptions` lets you control the detection process. | | ||
| typescriptValidation | boolean, `TypeScriptValidationOptions`, undefined | Choose whether to type-check source files using TypeScript. `true` uses defaults, while `TypeScriptValidationOptions` lets you control the validation process. | | ||
| treeShake | boolean, undefined | Choose whether to enable tree shaking. | | ||
### `CyclicDetectorOptions` | ||
@@ -83,10 +94,16 @@ | ||
### `ServerConfig` inherits `BundlerRuntimeParameters` | ||
### `TypeScriptValidationOptions` | ||
| Name | Type | Default | Description | | ||
| ------------ | ------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| projectRoot | string, undefined | | Path to the root of your react-native application. The bundle server uses this root path to resolve all web requests. The root path should contain your Babel config, otherwise Metro won't be able to find it. Either absolute, or relative to the package. | | ||
| assetPlugins | string[], undefined | | Additional asset plugins to be used by the Metro Babel transformer. Comma-separated list containing plugin modules and/or absolute paths to plugin packages. | | ||
| sourceExts | string[], undefined | | Additional source-file extensions to include when generating bundles. Comma-separated list, excluding the leading dot. | | ||
| Name | Type | Default | Description | | ||
| ------------ | ------------------ | ------- | --------------------------------------------------------------- | | ||
| throwOnError | boolean, undefined | true | Controls whether an error is thrown when type-validation fails. | | ||
### `ServerConfig` inherits `BundlerPlugins` | ||
| Name | Type | Description | | ||
| ------------ | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | ||
| projectRoot | string, undefined | Path to the root of your react-native application. The bundle server uses this root path to resolve all web requests. The root path should contain your Babel config, otherwise Metro won't be able to find it. Either absolute, or relative to the package. | | ||
| assetPlugins | string[], undefined | Additional asset plugins to be used by the Metro Babel transformer. Comma-separated list containing plugin modules and/or absolute paths to plugin packages. | | ||
| sourceExts | string[], undefined | Additional source-file extensions to include when generating bundles. Comma-separated list, excluding the leading dot. | | ||
## API | ||
@@ -96,3 +113,3 @@ | ||
Query for a package's configuration. | ||
Query for a package's rnx-kit configuration. | ||
@@ -105,24 +122,24 @@ | Parameter | Type | Description | | ||
### `getBundleDefinition(config, id)` | ||
### `getBundleConfig(config, id)` | ||
Get a "complete" bundle definition from the package configuration. | ||
Get a bundle configuration from the rnx-kit configuration. | ||
If `id` is given, search for the matching bundle and return it. Otherwise, | ||
return the first bundle definition found. | ||
If an id is given, search for the matching bundle definition. Otherwise, use the | ||
first bundle definition. | ||
| Parameter | Type | Description | | ||
| --------- | ------------------ | ------------------------------------------------------------------------------------------------------- | | ||
| config | `BundleConfig` | The bundle configuration, typically retrieved from the package configuration field `rnx-kit.bundle`. | | ||
| id | string, undefined | The id of the target bundle definition to use. This is not needed if only one bundle definition exists. | | ||
| [Return] | `BundleDefinition` | A "complete" bundle definition, with defaults applied for any missing values that have them. | | ||
| Parameter | Type | Description | | ||
| --------- | ------------------ | --------------------------------------------------------- | | ||
| config | `KitConfig` | The package's rnx-kit configuration | | ||
| id | string, undefined | Optional identity of the target bundle configuration | | ||
| [Return] | `BundleDefinition` | Bundle configuration, or `undefined` if nothing was found | | ||
### `getBundlePlatformDefinition(bundle, platform)` | ||
### `getPlatformBundleConfig(bundle, platform)` | ||
Get a platform bundle definition, applying any platform-specific overrides. | ||
Resolves the platform selector for a bundle configuration. | ||
| Parameter | Type | Description | | ||
| --------- | ------------------ | ------------------------------------------------------------------------- | | ||
| bundle | `BundleDefinition` | A "complete" bundle definition, typically from `getBundleDefinition()`. | | ||
| platform | `AllPlatforms` | The platform to resolve. | | ||
| [Return] | `BundleDefinition` | The input bundle definition with all platform-specific overrides applied. | | ||
| Parameter | Type | Description | | ||
| --------- | ------------------ | ------------------------------------------------------------------- | | ||
| bundle | `BundleConfig` | Bundle config to resolve (includes the optional platform selectors) | | ||
| platform | `AllPlatforms` | Target platform | | ||
| [Return] | `BundleDefinition` | Bundle config containing platform-specific overrides | | ||
@@ -147,10 +164,1 @@ ### `getKitCapabilities(config)` | ||
| customProfiles | string, undefined | | Path to a file containing [custom profiles](https://github.com/microsoft/rnx-kit/tree/main/packages/dep-check#custom-profiles). | | ||
### `getServerConfig(config)` | ||
Get a "complete" server configuration from the package configuration. | ||
| Parameter | Type | Description | | ||
| --------- | -------------- | ----------------------------------------------------------------------------------------------- | | ||
| config | `KitConfig` | The package configuration, typically retrieved from with `getKitConfig()`. | | ||
| [Return] | `ServerConfig` | A "complete" server configuration, with defaults applied for any missing values that have them. | |
@@ -6,42 +6,35 @@ import type { AllPlatforms } from "@rnx-kit/tools-react-native/platform"; | ||
export type TypeScriptValidationOptions = { | ||
/** | ||
* Controls whether an error is thrown when type-validation fails. | ||
*/ | ||
throwOnError?: boolean; | ||
}; | ||
/** | ||
* Parameters controlling bundler behavior at runtime. | ||
* Parameters controlling bundler plugins. | ||
*/ | ||
export type BundlerRuntimeParameters = { | ||
export type BundlerPlugins = { | ||
/** | ||
* Choose whether to detect cycles in the dependency graph. If true, then a default set | ||
* of options will be used. Otherwise the object allows for fine-grained control over | ||
* the detection process. | ||
* | ||
* @default true | ||
* Choose whether to detect cycles in the dependency graph. `true` uses defaults, | ||
* while `CyclicDetectorOptions` lets you control the detection process. | ||
*/ | ||
detectCyclicDependencies: boolean | CyclicDetectorOptions; | ||
detectCyclicDependencies?: boolean | CyclicDetectorOptions; | ||
/** | ||
* Choose whether to detect duplicate packages in the dependency graph. | ||
* | ||
* A duplicate error happens when a package is imported from two or more unique paths, | ||
* even if the versions are all the same. Duplicate packages increase bundle size and | ||
* can lead to unexpected errors. | ||
* | ||
* If true, then a default set of options will be used. Otherwise the object allows for | ||
* fine-grained control over the detection process. | ||
* | ||
* @default true | ||
* Choose whether to detect duplicate packages in the dependency graph. `true` uses defaults, | ||
* while `DuplicateDetectorOptions` lets you control the detection process. | ||
*/ | ||
detectDuplicateDependencies: boolean | DuplicateDetectorOptions; | ||
detectDuplicateDependencies?: boolean | DuplicateDetectorOptions; | ||
/** | ||
* Choose whether to type-check source files using TypeScript. | ||
* | ||
* @default true | ||
* Choose whether to type-check source files using TypeScript. `true` uses defaults, | ||
* while `TypeScriptValidationOptions` lets you control the validation process. | ||
*/ | ||
typescriptValidation: boolean; | ||
typescriptValidation?: boolean | TypeScriptValidationOptions; | ||
/** | ||
* Choose whether to enable tree shaking. | ||
* | ||
* @default false | ||
*/ | ||
treeShake: boolean; | ||
treeShake?: boolean; | ||
}; | ||
@@ -52,38 +45,15 @@ | ||
*/ | ||
export type BundleRequiredParameters = BundlerRuntimeParameters & { | ||
export type BundleParameters = BundlerPlugins & { | ||
/** | ||
* Path to the .js file which is the entry-point for building the bundle. | ||
* Either absolute, or relative to the package. | ||
* | ||
* @default "lib/index.js" | ||
*/ | ||
entryPath: string; | ||
entryFile?: string; | ||
/** | ||
* Path where the bundle and source map files are written. | ||
* Either absolute, or relative to the package. | ||
* | ||
* @default "dist" | ||
* Path to the output bundle file. Either absolute or relative to the package. | ||
*/ | ||
distPath: string; | ||
bundleOutput?: string; | ||
/** | ||
* Path where all bundle assets (strings, images, fonts, sounds, ...) are written. | ||
* Either absolute, or relative to the package. | ||
* | ||
* @default "dist" | ||
*/ | ||
assetsPath: string; | ||
/** | ||
* Prefix for the bundle name, followed by the platform and either ".bundle" (win, android) | ||
* or ".jsbundle" (mac, ios). | ||
* | ||
* @default "index" | ||
*/ | ||
bundlePrefix: string; | ||
}; | ||
export type BundleParameters = Partial<BundleRequiredParameters> & { | ||
/** | ||
* Encoding scheme to use when writing the bundle file. Currently limited | ||
@@ -100,3 +70,3 @@ * to UTF-8, UTF-16 (little endian), and 7-bit ASCII. | ||
*/ | ||
sourceMapPath?: string; | ||
sourcemapOutput?: string; | ||
@@ -106,11 +76,22 @@ /** | ||
*/ | ||
sourceMapSourceRootPath?: string; | ||
sourcemapSourcesRoot?: string; | ||
/** | ||
* Controls whether or not SourceMapURL is reported as a full path or just a file name. | ||
*/ | ||
sourcemapUseAbsolutePath?: boolean; | ||
/** | ||
* Path where all bundle assets (strings, images, fonts, sounds, ...) are written. | ||
* Either absolute, or relative to the package. If not given, assets are ignored. | ||
*/ | ||
assetsDest?: string; | ||
}; | ||
/** | ||
* Defines how a kit is bundled. Includes shared bundling parameters with platform-specific overrides. | ||
* Defines how a package is bundled. Includes shared bundling parameters with platform-specific overrides. | ||
*/ | ||
export type BundleDefinition = BundleParameters & { | ||
export type BundleConfig = BundleParameters & { | ||
/** | ||
* Unique identifier for this bundle definition. Only used as a reference within the kit build system. | ||
* Unique identifier for this bundle configuration. Only needed when specifying multiple bundle configurations. | ||
*/ | ||
@@ -120,3 +101,3 @@ id?: string; | ||
/** | ||
* The platform(s) for which this kit may be bundled. | ||
* The platform(s) for which this package may be bundled. | ||
*/ | ||
@@ -126,12 +107,6 @@ targets?: AllPlatforms[]; | ||
/** | ||
* Platform-specific overrides for bundling parameters. Any parameter not listed in an override gets | ||
* its value from the shared bundle definition, or falls back to defaults. | ||
* Platform-specific overrides for bundling. Any parameter not listed in an override gets | ||
* its value from the shared bundle configuration, or falls back to defaults. | ||
*/ | ||
platforms?: { [K in AllPlatforms]?: BundleParameters }; | ||
}; | ||
/** | ||
* Bundle configuration for a kit. If true, then all defaults will be used. | ||
* Otherwise, the bundle definition object(s) allow more detailed specification of bundling parameters. | ||
*/ | ||
export type BundleConfig = boolean | BundleDefinition | BundleDefinition[]; |
@@ -1,3 +0,3 @@ | ||
import { cosmiconfigSync } from "cosmiconfig"; | ||
import path from "path"; | ||
import { readPackage } from "@rnx-kit/tools-node"; | ||
import { KitConfig } from "./kitConfig"; | ||
@@ -10,3 +10,3 @@ | ||
/** | ||
* Retrieve the kit config options, if they exist, from the specified module. | ||
* Retrieve the rnx-kit configuration from a package module. | ||
*/ | ||
@@ -16,3 +16,3 @@ module?: string; | ||
/** | ||
* Retrive teh kit config options, using the target working directory. | ||
* Retrive the rnx-kit configuration from a directory containing 'package.json'. | ||
*/ | ||
@@ -22,14 +22,23 @@ cwd?: string; | ||
/** | ||
* Query for a package's rnx-kit configuration. | ||
* | ||
* @param options Options for retrieving the configuration. | ||
* @returns | ||
*/ | ||
export function getKitConfig( | ||
options: GetKitConfigOptions = {} | ||
): KitConfig | null { | ||
// use a working directory extracted from a module, specified in cwd, or from process.cwd | ||
const cwd = options.module | ||
): KitConfig | undefined { | ||
// find the package dir that holds the rnx-kit configuration | ||
const packageDir = options.module | ||
? path.dirname(require.resolve(options.module + "/package.json")) | ||
: options.cwd || process.cwd(); | ||
// use the synchronous cosmiconfig load method to see if there is kit info present at the specified location | ||
const explorerSync = cosmiconfigSync("rnx-kit", { stopDir: cwd }); | ||
const result = explorerSync.search(cwd); | ||
return result?.config ?? null; | ||
// try to read package.json | ||
try { | ||
const packageJson = readPackage(packageDir); | ||
return packageJson["rnx-kit"]; | ||
} catch { | ||
return undefined; | ||
} | ||
} |
export type { | ||
BundleConfig, | ||
BundleDefinition, | ||
BundleParameters, | ||
BundleRequiredParameters, | ||
BundlerRuntimeParameters, | ||
BundlerPlugins, | ||
TypeScriptValidationOptions, | ||
} from "./bundleConfig"; | ||
export { | ||
getBundleDefinition, | ||
getBundlePlatformDefinition, | ||
} from "./getBundleDefinition"; | ||
export type { BundleDefinitionWithRequiredParameters } from "./getBundleDefinition"; | ||
export { getBundleConfig, getPlatformBundleConfig } from "./getBundleConfig"; | ||
@@ -21,5 +16,2 @@ export { getKitCapabilities } from "./getKitCapabilities"; | ||
export { getServerConfig } from "./getServerConfig"; | ||
export type { ServerWithRequiredParameters } from "./getServerConfig"; | ||
export type { | ||
@@ -34,6 +26,2 @@ Capability, | ||
export type { | ||
ServerRequiredParameters, | ||
ServerParameters, | ||
ServerConfig, | ||
} from "./serverConfig"; | ||
export type { ServerConfig } from "./serverConfig"; |
@@ -58,3 +58,3 @@ import type { BundleConfig } from "./bundleConfig"; | ||
/** | ||
* Configuration information for an rnx-kit. This is retrieved via cosmi-config | ||
* Configuration information for an rnx-kit package. This is retrieved from 'rnx-kit' in package.json. | ||
*/ | ||
@@ -83,9 +83,8 @@ export type KitConfig = { | ||
/** | ||
* Specifies how the kit is bundled. When not defined, the kit cannot be bundled. | ||
* Specifies how the package is bundled. | ||
*/ | ||
bundle?: BundleConfig; | ||
bundle?: BundleConfig | BundleConfig[]; | ||
/** | ||
* Specifies how the kit's development bundle-server is configured. When not defined, | ||
* the kit will be served using default values. | ||
* Specifies how the package's bundle server is configured. | ||
*/ | ||
@@ -92,0 +91,0 @@ server?: ServerConfig; |
@@ -1,6 +0,4 @@ | ||
import type { BundlerRuntimeParameters } from "./bundleConfig"; | ||
import type { BundlerPlugins } from "./bundleConfig"; | ||
export type ServerRequiredParameters = BundlerRuntimeParameters; | ||
export type ServerParameters = Partial<ServerRequiredParameters> & { | ||
export type ServerConfig = BundlerPlugins & { | ||
/** | ||
@@ -29,3 +27,1 @@ * Path to the root of your react-native experience project. The bundle server uses | ||
}; | ||
export type ServerConfig = ServerParameters; |
@@ -5,18 +5,10 @@ import { getKitConfig } from "../src/getKitConfig"; | ||
describe("getKitConfig()", () => { | ||
const notPresentFixture = "not-present"; | ||
const inPackageFixture = "in-package"; | ||
const inConfigFixture = "in-config-js"; | ||
const currentWorkingDir = process.cwd(); | ||
function fixturePath(name: string): string { | ||
return path.join(currentWorkingDir, "test", "__fixtures__", name); | ||
function fixturePath(): string { | ||
return path.join(currentWorkingDir, "test", "__fixtures__"); | ||
} | ||
/** | ||
* Sets current working directory to specified test fixture. | ||
* @param {string} name | ||
*/ | ||
function setFixture(name: string): void { | ||
process.chdir(fixturePath(name)); | ||
function packagePath(name: string): string { | ||
return path.join(fixturePath(), "node_modules", name); | ||
} | ||
@@ -26,27 +18,31 @@ | ||
test("not-present package correctly returns a null config", () => { | ||
setFixture(notPresentFixture); | ||
expect(getKitConfig()).toBeNull(); | ||
test("returns undefined for an unconfigured package when using the current working directory", () => { | ||
process.chdir(packagePath("kit-test-unconfigured")); | ||
expect(getKitConfig()).toBeUndefined(); | ||
}); | ||
test("kit options can be found in package.json", () => { | ||
setFixture(inPackageFixture); | ||
const config = getKitConfig(); | ||
expect(config).not.toBeNull(); | ||
expect(config && config.bundle).toBeTruthy(); | ||
expect(config && config.platformBundle).toBeTruthy(); | ||
expect(config).toMatchSnapshot(); | ||
test("returns undefined for an unconfigured package when using an explicit working directory", () => { | ||
expect( | ||
getKitConfig({ cwd: packagePath("kit-test-unconfigured") }) | ||
).toBeUndefined(); | ||
}); | ||
test("kit options can be found in config file", () => { | ||
setFixture(inConfigFixture); | ||
const config = getKitConfig(); | ||
expect(config).not.toBeNull(); | ||
expect(config).toMatchSnapshot(); | ||
test("returns undefined for an unconfigured package when using a module name", () => { | ||
expect(getKitConfig({ module: "kit-test-unconfigured" })).toBeUndefined(); | ||
}); | ||
test("kit options can be loaded via path", () => { | ||
const config = getKitConfig({ cwd: fixturePath(inPackageFixture) }); | ||
expect(config).toMatchSnapshot(); | ||
test("returns rnx-kit configuration when using the current working directory", () => { | ||
process.chdir(packagePath("kit-test-configured")); | ||
expect(getKitConfig()).toMatchSnapshot(); | ||
}); | ||
test("returns rnx-kit configuration when using an explicit working directory", () => { | ||
expect( | ||
getKitConfig({ cwd: packagePath("kit-test-configured") }) | ||
).toMatchSnapshot(); | ||
}); | ||
test("returns rnx-kit configuration when using a module name", () => { | ||
expect(getKitConfig({ module: "kit-test-configured" })).toMatchSnapshot(); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
159
178946
60
1945
+ Added@rnx-kit/tools-node@^1.2.7
+ Added@rnx-kit/tools-language@1.4.2(transitive)
+ Added@rnx-kit/tools-node@1.3.1(transitive)
+ Addedfind-up@3.0.05.0.0(transitive)
+ Addedlocate-path@3.0.06.0.0(transitive)
+ Addedp-limit@2.3.03.1.0(transitive)
+ Addedp-locate@3.0.05.0.0(transitive)
+ Addedp-try@2.2.0(transitive)
+ Addedpath-exists@3.0.04.0.0(transitive)
+ Addedpkg-dir@5.0.0(transitive)
+ Addedpkg-up@3.1.0(transitive)
+ Addedyocto-queue@0.1.0(transitive)
- Removedcosmiconfig@^7.0.0
- Removed@babel/code-frame@7.26.2(transitive)
- Removed@babel/helper-validator-identifier@7.25.9(transitive)
- Removed@types/parse-json@4.0.2(transitive)
- Removedcallsites@3.1.0(transitive)
- Removedcosmiconfig@7.1.0(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedimport-fresh@3.3.0(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjson-parse-even-better-errors@2.3.1(transitive)
- Removedlines-and-columns@1.2.4(transitive)
- Removedparent-module@1.0.1(transitive)
- Removedparse-json@5.2.0(transitive)
- Removedpath-type@4.0.0(transitive)
- Removedpicocolors@1.1.1(transitive)
- Removedresolve-from@4.0.0(transitive)
- Removedyaml@1.10.2(transitive)