0

This seems related to BABEL: Unknown option: base.Children, but the fixes provided there don't help my situation. Two days ago I had an Electron application that ran in development mode (via 'electron-forge start') and as a packaged application (starting the executable in the folder produced by 'electron-forge package'). The app continues to run in development, and it will execute in production, but Babel produces an error in the Web console:

    Unknown option: base.Children. Check out http://...

This occurs on the first require statement calling for one of my JSX files (there's another thing: react-forge doesn't transpile the JSX, and I suspect I'm about to be told to RTFM over that matter). I can get the same error to pop up whenever I want; all I have to do is enter "require('somefile.jsx')" in the console, and it'll do the same thing. Investigation of the error reveals that the options manager's mergeOptions function is passed a copy of React at one point during the loop that's supposed to incorporate the presets and plugins. Again, this did not start happening after a change to the application code; I tried to update some packages in NPM, and the next build I did produced this error.

I've wiped the node_modules directory completely and run a fresh 'npm install' followed by 'electron-rebuild' and a repackaging of the app produces the same results. I've tried incorporating the .babelrc contents in package.json according to the docs at the Babel website. Again, dev works fine and production fails. Creating a compliant .compilerc produced similarly disparate results. How is my production app getting a React component where it should have the Babel options?

4

1 回答 1

0

我刚刚找到了解决方案。这是一个组合问题。React 本身和 Babel 的 React 预设都以“react”作为预设名称。如果插件缺失但 React 存在,Babel 将拉取 React 并将其传递给 mergeOptions,产生描述的错误。另一方面,如果你错误地在你的 package.json 中在 dev 依赖项和一般依赖项下都需要一个模块(如 React 预设),则由 electron-forge 运行的打包子流程将忽略一般依赖项下的条目. 结果:没有预设,Babel 并没有吐出“缺少预设”的错误,而是把 React 自己吸了进去,假装它找到了它被告知要寻找的预设。

于 2017-04-06T22:47:39.373 回答