Support javascript config files in addition to json
#65
Replies: 2 comments 2 replies
-
Yes!!! This actually solves a lot of issues and it would actually not require much work at all. As a matter of fact, it's already supported! The launchpad/packages/utils/lib/config-manager.js Lines 51 to 75 in f43492d And the launchpad/packages/launchpad/test/test.js Lines 4 to 6 in f43492d launchpad/packages/launchpad/test/config.js Lines 1 to 15 in f43492d In fact, we need this for a project now and I might just shimmy in a quick solution/test and then we can see if we can incorporate something like cosmiconfig, which sounds super helpful and would also address #7 The only challenge might be that we're currently using yargs for loading, which also supports overriding via CLI params. That seems solvable though. |
Beta Was this translation helpful? Give feedback.
-
Resolved with #124, plus intellisense is being added with #128 |
Beta Was this translation helpful? Give feedback.
-
Would it make sense to support javascript config files (
js
/cjs
/mjs
) in addition tojson
for users that want more control? Or would that be too redundant with the node API?Some scenarios where I imagine this could be useful:
Env Overrides
For programs that have multiple instances that require slightly different configs, it seems the common pattern currently is to have different launchpad config files for each instance. Having a js config file would allow users to use a single file that could adjust the config based on env variables or user variables:
Sharing Config Code
Having js files would allow us to import other files into our config files:
Jsdoc / typescript Hints
Using js for config also means we could take advantage of the JSDoc hints while writing up config files, similar to how nextjs types their config files:
If this all is too redundant with the node API, then it might make more sense to just show how to accomplish these same scenarios using the node API somewhere in the documentation.
There are a couple of existing tools that will automagically search for config files with different file types, ex: https://github.com/davidtheclark/cosmiconfig
Beta Was this translation helpful? Give feedback.
All reactions