fix/Polyfill Node.js core modules in Webpack (5+)

This commit is contained in:
Maxime GRIS
2021-11-15 13:18:04 +01:00
parent e07410ba4a
commit e3c0d9f571
8 changed files with 1052 additions and 199 deletions

View File

@@ -28,6 +28,14 @@ export class ElectronService {
this.childProcess = window.require('child_process');
this.fs = window.require('fs');
// Notes :
// * A NodeJS's dependency imported with 'window.require' MUST BE present in `dependencies` of both `app/package.json`
// and `package.json (root folder)` in order to make it work here in Electron's Renderer process (src folder)
// because it will loaded at runtime by Electron.
// * A NodeJS's dependency imported with TS module import (ex: import { Dropbox } from 'dropbox') CAN only be present
// in `dependencies` of `package.json (root folder)` because it is loaded during build phase and does not need to be
// in the final bundle. Reminder : only if not used in Electron's Main process (app folder)
// If you want to use a NodeJS 3rd party deps in Renderer process,
// ipcRenderer.invoke can serve many common use cases.
// https://www.electronjs.org/docs/latest/api/ipc-renderer#ipcrendererinvokechannel-args