@mintlab/cherrypack
Do different things depending on NODE_ENV.
Installation
$ yarn add @mintlab/cherrypack
Usage
The package exports a function that is called with an object that uses the environments as property names.
const cherrypack = require('cherrypack');
module.exports = cherrypack({
development: 'foo', // export `foo` in production
production: 'bar', // export `bar` in production
});
If you need to require and execute complex and expensive code, you can encapsulate that with a method that will be used as a callback:
module.exports = cherrypack({
development() {
return new require('ExpensiveDevelopmentClass')(/* complex argument(s) */);
},
production() {
return new require('ExpensiveProductionClass')(/* complex argument(s) */);
},
});
If process.env.NODE_ENV
is not set, it defaults to development
;
License
Copyright Mintlab B.V.
Licensed under the EUPL, Version 1.1 or – as soon they will be approved by the European Commission - subsequent versions of the EUPL (the "Licence").
You may not use this work except in compliance with the Licence.
You may obtain a copy of the Licence at: https://joinup.ec.europa.eu/software/page/eupl