Closed jedwards1211 closed 7 years ago
Any chance of getting this merged?
Looks like @baer has a life 😎
OMG! I am so sorry - thank you for pinging me. Every once in a while I miss a GH notification and this happens. I'll have a look tonight. Thank you so much for your contribution to the project.
@baer no worries, thanks!
Ah, CI is failing on a lint error:
/home/travis/build/FormidableLabs/babel-plugin-transform-define/src/index.js
4:7 error A space is required after '{' object-curly-spacing
4:22 error A space is required before '}' object-curly-spacing
✖ 2 problems (2 errors, 0 warnings)
@baer whoops! I run lint in a precommit script (via husky
) to avoid making those mistakes in my own projects. It's fixed now
Will cut a release shortly.
@baer great, thanks!
Hi, I don't really understand how to actually use the false value if I needed to, because webpack's DefinePlugin actually allows this. Using this plugin though:
config.js file
module.exports = {
PRODUCTION: false
};
with this the application throws an error of undefined because it does not get replace with false. any idea?
@minheq this is useful in situations where you don't want to use Webpack, for instance when you're running code on the server side via babel-node
. It looks like @baer hasn't actually released this, so if you just installed from npm it's no surprise you would see that error. Replacing with false should only work if you use the code from this PR, which has not been released to npm.
@jedwards1211 Thanks for explanation, very much needed PR :) Pinging @baer to release it to npm ^^
@baer - any chance of getting 1.2.1 (with this merged included) pushed to npm soon?
@jedwards1211 - After a bit of back and forth with the NPM (the package was broken) we got everything straightened out and published. Thanks again for your contribution. 1.3.x is live.
//cc @jrylan
the current version doesn't perform replacements with falsy values because
getFirstReplacementValueForNode
returnsget(obj, replacementKey) || null
, andprocessNode
doesif (replacement)
.This change uses
lodash.has
to check if thereplacementKey
is present inreplacements
, and if so, performs the replacement -- even if it'snull
,0
,''
,false
,NaN
, orundefined
.