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

Created on 23 Oct 2018  路  3Comments  路  Source: babel/minify

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

  • Export any environment variable and then launch app with react-native start --reset-cache
  • Now change the environment variable's value
  • Reload the app
  • The value in react-native doesn't update

babelrc:

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

Most helpful comment

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

All 3 comments

@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 }
}

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

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

Was this page helpful?
0 / 5 - 0 ratings