question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with babel 7

See original GitHub issue

When we define a config file like that :

{
    "plugins": [["transform-define", "./config/config.js"]]
}

We get the following error with babel 7 :

.plugins[1][1] must be an object, false, or undefined

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:22
  • Comments:14

github_iconTop GitHub Comments

26reactions
nathanqueijacommented, May 15, 2018

Hey, guys.

I managed how to fix that passing an object config to this plugin using .babelrc.js instead of .babelrc:

const env = require('./env-config')
module.exports = {
  presets: [['@babel/preset-env', {modules: 'commonjs'}], 'next/babel'],
  plugins: [
    ['lodash'],
    ['transform-define', env],
    ['transform-decorators-legacy'],
    [
      'inline-import',
      {
        extensions: ['.css']
      }
    ],
    [
      'babel-plugin-styled-components',
      {
        ssr: true
      }
    ]
  ],
  env: {
    test: {},
    development: {},
    production: {}
  }
}
9reactions
Vinczcommented, Jan 10, 2018

What about something like that : https://github.com/Vincz/babel-plugin-transform-define/commit/5ba90a6ad8ba8fc4fa9b791d80409db0b1c3ab3d

Or maybe __file instead of file

We cannot use a string as plugin configuration anymore. So we have to use an object even for the file import feature and we need to know if the user want to have an object as config or if he wants to use a config file.

I used to use it like that in my .babelrc :

"env": {
    "development": {
        "plugins": ["react-hot-loader/babel", ["transform-define", "./config/config.dev.js"]]
    },
    "production": {
        "plugins": [["transform-define", "./config/config.prod.js"]]
    }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrade to Babel 7
Babel has had issues previously with handling node_modules , symlinks, and monorepos. We've made some changes to account for this: Babel will stop...
Read more >
Issues · babel/babel - GitHub
Babel is a compiler for writing next generation JavaScript. - Issues · babel/babel. ... #15157 opened on Nov 7, 2022 by aaronadamsCA.
Read more >
Why is Babel 7 not compiling node_modules files?
This new behaviour is really stupid. It means dependencies can no longer tell their parent projects how to transpile them, which encourages library...
Read more >
babel-loader - npm
This package allows transpiling JavaScript files using Babel and webpack. Note: Issues with the output should be reported on the Babel ...
Read more >
React Ecosystem: Setting up Babel 7 and Webpack 5 for React
"@babel/plugin-proposal-throw-expressions": "7.12.13", }. To avoid any braking issue due to version change in the future, I have locked the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found