electron-webpack icon indicating copy to clipboard operation
electron-webpack copied to clipboard

Usage of custom babel config

Open atassis opened this issue 5 years ago • 6 comments

  • Version: 10.1.3
  • Target: Windows

I want to use custom babel config (provide options for @babel/preset-react module, which is required for new RC of react). How can I do that with less effort?

atassis avatar Oct 04 '20 18:10 atassis

I am using all the latest module versions, which are actual tvm. (electron-webpack: 2.8.2, etc)

atassis avatar Oct 04 '20 18:10 atassis

To add a babel preset, you only have to install it to your project in devDependencies (package.json). It should be detected and used automatically.

To configure babel options, you create a regular babel config file, e.g. babel.config.json and adjust it.

loopmode avatar Oct 04 '20 19:10 loopmode

@loopmode I have created a babel.config.js file with next sources:

const isDevelopment = process.env.NODE_ENV !== 'production';

module.exports = {
  presets: [
    ['@babel/preset-env', { useBuiltIns: 'entry', corejs: 3 }],
    ['@babel/preset-react', { runtime: 'automatic' }],
    ['@babel/preset-typescript', { allExtensions: true, isTSX: true }],
  ],
  plugins: [
    '@reatom/babel-plugin',
    isDevelopment && 'react-refresh/babel',
  ].filter(Boolean),
};

Providing it as it is. No magic. As well if we insert any console.log into this file- it is still not running, while it does with a common webpack setup.

atassis avatar Oct 07 '20 21:10 atassis

Did you ever get the automatic runtime to work?

steveoh avatar Oct 05 '21 17:10 steveoh

Sorry, but what stands for "automatic runtime"? In any case, I have stopped developing electron part of my project also because of this issue

atassis avatar Oct 06 '21 00:10 atassis

@steveoh Also running into this issue. I have a .babelrc file originally set as the following:

{
  "presets": [
    "@babel/preset-env",
    ["@babel/preset-react", {
      "runtime": "automatic"
    }]
  ],
  "plugins": [
    "styled-components"
  ]
}

…and the automatic runtime is not working.

wrgoto avatar Mar 22 '22 00:03 wrgoto