Parcel: Electron Error: process is not defined

Created on 5 Aug 2019  路  2Comments  路  Source: parcel-bundler/parcel

馃悰 bug report

When building an electron project, it appears that some of the configuration prevents the app from running correctly. I'm not sure if I have configuration all wrong or what, but I tried with the default tutorial for electron and a minimal configuration to get parcel working, but have had no luck building an app that would work.

馃帥 Configuration (.babelrc, package.json, cli command)

package.json is using cli, scripts look like this:

"scripts": {
    "build": "parcel build index.html --public-url ./ --target electron",
    "start": "electron ."
},

馃 Expected Behavior


renderer.js should load, there should be no console errors in default build.

馃槸 Current Behavior


Getting a console error and renderer.js is unable to load.
Note in example repo, renderer.js is actually an empty file, but I'm guessing that shouldn't impact this.


image

馃拋 Possible Solution


It looks like the line that is failing is an HMR configuration, which can't be disabled for build, but shouldn't even be included?

Line where you can see HMR being loaded: https://github.com/JRJurman/electron-parcel-test/blob/master/dist/renderer.f84e1103.js#L1

馃敠 Context


In reality I'm trying to build a tutorial for building electron apps with my view-framework, that by-default uses parcel. The dummy repo proved that this appears to be happening in the most basic of scenarios.

I also noticed some issues when trying to load babel-polyfill, but I'll save that for after this... One issue at a time 馃槢

馃捇 Code Sample

Repo (off of the electron-quick-start): https://github.com/JRJurman/electron-parcel-test
Commit Adding Parcel: https://github.com/JRJurman/electron-parcel-test/commit/69d0bb69de7f15820e517e42c23c622509423c5d

馃實 Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.12.3 |
| Node | 12.6.0 |
| npm/Yarn | npm 6.9.0 |
| Operating System | Windows 10 |

Bug Electron

Most helpful comment

In the main.js file when you create the BrowserWindow try to add after the width and height :

webPreferences: {
nodeIntegration: true,
},

All 2 comments

In the main.js file when you create the BrowserWindow try to add after the width and height :

webPreferences: {
nodeIntegration: true,
},

@ssoric hey, that worked! Glad that was an easy fix...
If there's an appropriate place in the repo to add this kind of documentation, I would be happy to add it, finding that and the --public-url ./ was kind of a challenge...

Otherwise feel free to close this issue! 馃槃

Was this page helpful?
0 / 5 - 0 ratings