@mintlab/cherrypack

1.0.0 • Public • Published

@mintlab/cherrypack npm version

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

Readme

Keywords

none

Package Sidebar

Install

npm i @mintlab/cherrypack

Weekly Downloads

13

Version

1.0.0

License

EUPL-1.1

Unpacked Size

16.1 kB

Total Files

4

Last publish

Collaborators

  • arnedeboer
  • martijnvds
  • zaaksysteem
  • waterkip
  • devenwel