babel / minify

:scissors: An ES6+ aware minifier based on the Babel toolchain (beta)
https://babeljs.io/repl
MIT License
4.39k stars 225 forks source link

babel-plugin-transform-inline-environment-variables doesn't update unless react native cache is cleared #919

Open sourabhv opened 6 years ago

sourabhv commented 6 years ago

Describe the bug

babel-plugin-transform-inline-environment-variables doesn't use or update the value from process.env unless react-native start is called with --cache-clear

To Reproduce

babelrc:

{
  "presets": ["react-native-stage-0"],
  "plugins": [
    "transform-inline-environment-variables",
    "syntax-trailing-function-commas"
  ]
}
aleclarson commented 5 years ago

@hzoo @boopathi Could the inline-environment-variables transform somehow clear the cache for affected files only?

As a workaround, you can use a .babelrc.js file:

module.exports = api => {
  const presets = ['react-native-stage-0']
  const plugins = [
    'transform-inline-environment-variables',
    'syntax-trailing-function-commas',
  ]

  api.cache.invalidate(() => process.env.FOO)
  return { presets, plugins }
}
timosur commented 4 years ago

Is there an update on this topic? I still get this error.. Also the suggestion from @aleclarson is not working for me :-/

loiclouvet commented 4 years ago

@timosur Did you find a trick to clear some environment variables without the --reset-cache option ?