Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Babel for main process #139

Closed
davej opened this issue Feb 7, 2016 · 11 comments
Closed

Use Babel for main process #139

davej opened this issue Feb 7, 2016 · 11 comments

Comments

@davej
Copy link
Contributor

davej commented Feb 7, 2016

What's the consensus about letting the main process run through babel too? The issue I'm having is that I want to use redux-electron-store but I can't require any of the reducers because they use the ES6 module syntax which currently isn't supported by the latest versions of Electron/Chromium.

@davej davej changed the title Babelify main process too Use Babel for main process Feb 7, 2016
@jhen0409
Copy link
Member

Yes, if we don‘t use Babel, this is no way to share reducers between Main and Renderer.

@chentsulin what do you think?

@chentsulin
Copy link
Member

I don't mind using babel also in main process, but which one approach is our best choice? babel-register?

@davej
Copy link
Contributor Author

davej commented Feb 11, 2016

The problem with using babel-register is that babel then needs to be bundled with the app (rather than simply as a dev-dependency).

@davej
Copy link
Contributor Author

davej commented Feb 11, 2016

Actually, I guess we could use babel-register in development and then compile it (using webpack?) for the production version.

@wasd171
Copy link

wasd171 commented Apr 7, 2016

Code sharing is quite essential. Unfortunately, simple adding of require('babel-register'); in main.js results in

App threw an error when running TypeError: Path must be a string. Received undefined

requiring the following dummy.js:

module.exports = 'bar';

I've tried webpack'ing main.js, but no luck :(

@naderhen
Copy link

naderhen commented Apr 8, 2016

Is there a known workaround for this? @davej your solution seems reasonable, but I'm curious how you'd go about it within this boilerplate.

@davej
Copy link
Contributor Author

davej commented Apr 8, 2016

@naderhen: it just worked for me.

My entry point file looks like this:

/* eslint strict: 0 */
'use strict';

require('babel-register');
require('./main/init.js');

./main/init.js is where my main process logic is and it uses ES6 modules.

@naderhen
Copy link

naderhen commented Apr 8, 2016

I have something very similar which does indeed work in terms of running the electron application with babel included. However, when I attempt to package the app via npm run package (on OSX) and run the resulting *.app I get a host of babel related import errors:

image

Any thoughts? Do you run into the same issue when packaging?

@davej
Copy link
Contributor Author

davej commented Apr 8, 2016

@naderhen: I haven't tried packaging the app yet. My plan was to use webpack and create an entry for the main js file. Have you tried using webpack to compile the main process files instead of including babel in your production build?

@naderhen
Copy link

naderhen commented Apr 8, 2016

hmm, yea @davej I've given the separate webpack entry route a shot but ended up with a slew of other cryptic errors either during the build or packaging process. If you come up with a working solution on your end I'd love to be pointed in the right direction. Willing to test out any other options you think would work too.

@chentsulin
Copy link
Member

Closed via #197.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants