jschr / electron-react-redux-boilerplate

A minimal boilerplate to get started with Electron, React and Redux.
554 stars 130 forks source link

Error: 'require is not defined' when nodeIntergration : false #85

Closed romanpod closed 5 years ago

romanpod commented 5 years ago

Hi all, When setting nodeIntergration : false, the app won't run. I'm guessing that's because of how gulp transpiles the jsx:

var _react = _interopRequireDefault(require("react"));
var _reactDom = _interopRequireDefault(require("react-dom"));
var _reactRedux = require("react-redux");
...

And 'requiring' is not supported in the renderer without node integration. I'd like to follow the electron recommendation and stick to the default setting. Please advise. Thanks!

pronebird commented 5 years ago

This is expected. Browsers do not support require, so you can't use it without node integration. You have to rewrite the renderer for the general web.

romanpod commented 5 years ago

Well, I haven't actually added any code of my own yet, I've just cloned your project, changed the setting and tried to fire it up.

pronebird commented 5 years ago

@romanpod yep, that won't work and I guess using Electron without nodeIntegration would be the entirely different approach to developing the app.

You'd have to include all of the dependencies via SCRIPT tag in HTML and then smuggle the Electron IPC via the preload script.