
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
flexiconfig
Advanced tools
Consume library configuration from multiple places
If you have a library that involves large configuration, you might want to give users multiple ways to load the configuration, such as:
.kittensrc
package.json
This library allows you to set those, in any preference order you want. The first configuration method that yields a result will be returned as an object.
npm install flexiconfig
In the below example, the getConfig()
function will try to load first from the opts
object passed to the function, then from a file called .kittensrc
in the current working directory, and finally in package.json
, under the top-level key "kittens"
. If none of those work, it will move up one folder and try again, and on and on.
const getConfig = require('flexiconfig');
module.exports = function getKittens(opts) {
const options = getConfig([opts, '.kittensrc', 'package.json#kittens']);
}
Produce a configuration object from the first source that yields one.
module.exports
.package.json#[KEY]
, where [KEY]
is a top-level key on the package.json
in the current working directory.process.cwd()
.true
.Returns the first config object found based on the order of loaders
. Throws an error on any of these conditions:
package.json
is found, but the value is not an object.Hot tip! If you're okay with the process silently failing, you can supply a default config object as the last item in the loaders
parameter.
const getConfig = require('flexiconfig');
module.exports = function getKittens(opts) {
const options = getConfig([opts, '.kittensrc', 'package.json#kittens', {
breed: 'siamese',
age: 12,
}]);
}
git clone https://github.com/spacedoc/flexiconfig
cd flexiconfig
npm install
npm test
MIT © Geoff Kimball
FAQs
Consume library configuration from multiple places
We found that flexiconfig demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.