GithubHelp home page GithubHelp logo

loose-envify's Introduction

loose-envify

Build Status

Fast (and loose) selective process.env replacer using js-tokens instead of an AST. Works just like envify but much faster.

Gotchas

  • Doesn't handle broken syntax.
  • Doesn't look inside embedded expressions in template strings.
    • this won't work:
    console.log(`the current env is ${process.env.NODE_ENV}`);
  • Doesn't replace oddly-spaced or oddly-commented expressions.
    • this won't work:
    console.log(process./*won't*/env./*work*/NODE_ENV);

Usage/Options

loose-envify has the exact same interface as envify, including the CLI.

Benchmark

envify:

  $ for i in {1..5}; do node bench/bench.js 'envify'; done
  708ms
  727ms
  791ms
  719ms
  720ms

loose-envify:

  $ for i in {1..5}; do node bench/bench.js '../'; done
  51ms
  52ms
  52ms
  52ms
  52ms

loose-envify's People

Contributors

lydell avatar mattiasa avatar realityking avatar tomashanacek avatar zertosh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

loose-envify's Issues

loose-envify doesn't play nice with prettier

we have been using loose-envify for a while, and are pretty happy with it. We are now trying to add prettier to our toolchain, to run on all of our typescript files. We compile our typescript to ES5, and then run loose-envify on the result of that.

In testing this, we've discovered that we have a few lines of code like

preview_url: `https://${process.env.WEBSERVER}/scl/fo/hk7w48fbgw9j6ikfl4202/AAC_QACHIcZPuKOX9C9L8g6Ea`,

which works fine.

However, prettier converts this code to

preview_url: `https://${process.env
    .WEBSERVER}/scl/fo/hk7w48fbgw9j6ikfl4202/AAC_QACHIcZPuKOX9C9L8g6Ea`,

which compiles to

preview_url: "https://" + process.env
    .WEBSERVER + "/scl/fo/hk7w48fbgw9j6ikfl4202/AAC_QACHIcZPuKOX9C9L8g6Ea",

loose-envify cannot handle the whitespace between process.env and .WEBSERVER; at the moment the only workaround is to add // prettier-ignore to these cases, and I'd rather not have to educate my teammates about that. Is there any chance we could get this limitation fixed? Would upstream be amenable to a pull request?

Grunt support.

Does loose-envify support grunt?
When I use options like

transform: [
               [
                'loose-envify',
                {
                    global: true,
                    NODE_ENV: 'production',
                    _: 'purge'
                }
            ]
        ],

they seem to be ignored. processs.env.NODE_ENV is always replaced with the current NODE_ENV variable and not the one in the options.

Project licensed as MIT but there is a facebook BSD copyright in some files.

Is it accurate to say this is MIT licensed when these copyright comments exist in the following files?

/loose-envify /test/pkg/node_modules/warning/index.js
/loose-envify / test/pkg/node_modules/invariant/index.js
/loose-envify / test/react/react-with-addons-with-node_env.js

/**

  • Copyright 2013-2015, Facebook, Inc.
  • All rights reserved.
  • This source code is licensed under the BSD-style license found in the
  • LICENSE file in the root directory of this source tree. An additional grant
  • of patent rights can be found in the PATENTS file in the same directory.
  • @providesModule invariant
    */

missing `main` in `package.json` file

When using Webjar and webjar-locator, the main attribute in the package.json file is required to be able to provide the RequireJS configuration.

Could not create the RequireJS config for the loose-envify 1.1.0 WebJar from META-INF/resources/webjars/loose-envify/1.1.0/package.json
There was not enough information in the package metadata to do so.
Error: no 'main' attribute; cannot generate a config

If you could add it in your project that would let the webjar-locator operates its magic.

I would do the PR but I'm discovering your project while creating this issue.. sorry.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.