Vlsir / Hdl21Schematics

Hdl21 Schematics
BSD 3-Clause "New" or "Revised" License
14 stars 2 forks source link

Tracking all the `electron-forge` things #24

Open dan-fritchman opened 1 year ago

dan-fritchman commented 1 year ago

https://github.com/electron/forge has been incredibly valuable for:

It also has plenty of configurability, and history.
Tracking how we use it and why, what we'd prefer if possible.


Workspace-ability and "Hoisting"

Hdl21SchematicEditor is a yarn workspace. It has separate packages for:

Workspaces and electron-forge don't seem to play especially nice together. Issues about when googling those topics, the seminal one seeming to be:

https://github.com/electron/forge/issues/869

The authors say it was fixed in electron-forge v6; that seems wrong. We use v6.0.3, and consistently get:

Error: Cannot find the package "electron". Perhaps you need to run "yarn install" 

Unless applying the nohoist option recommended in this comment:

https://github.com/electron/forge/issues/869#issuecomment-601887184

"private": true,
"workspaces": {
  "nohoist": [
    "electron",
    "electron/**",
    "electron-squirrel-startup",
    "electron-squirrel-startup/**",
    "@electron-forge",
    "@electron-forge/**"
  ]
},

Whereas many of the issue-commenters think of this as a workaround more than a fix, I think it... seems OK here(?). The "hoisting" idea is essentially "copy these package dependencies into some additional local folder where something expects to find them". Which certainly wastes some disk space. But I don't think it breaks anything - especially for the case where we distribute OS-native packages (dmg, deb, etc).


Versions

We rely on a pretty weird-sounding version of electron-forge:

"@electron-forge/cli": "^6.0.0-beta.65",

Some time between that beta.65 and v6.0, they seem to have removed one of my favorite features: live type-checking as the renderer is edited. With beta.65, injecting a type error generates this in the terminal:

ERROR in editor.ts
../EditorCore/src/editor.ts 134:21-25
[tsl] ERROR in editor.ts(134,22)
      TS2552: Cannot find name 'msg_'. Did you mean 'msg'?
 @ ../EditorCore/src/start.tsx 18:17-36
 @ ../EditorCore/src/index.ts 7:14-32
 @ ./src/renderer.js 8:0-35 26:0-5

Which I find really valuable! And it seems this was changed on purpose:

https://github.com/electron-userland/electron-forge-templates/issues/27#issuecomment-294277496

But I do "want the app to stop running if there are type errors"! And it does - they just don't get reported in the terminal. They show up in the Electron GUI window. But that's aways less helpful, especially compared to the VsCode internal terminal with all its nice source-mapped clickability.

It seems likely there is some configuration-means of making this happen, but I haven't found it.


Templates

We started Hdl21SchematicEditor with the electron-forge webpack template:
https://www.electronforge.io/templates/webpack-template

And then started to add TypeScript. And then pretty much became all TypeScript. So we thought, why not move to the webpack + TypeScript template: https://www.electronforge.io/templates/typescript-+-webpack-template

Thus far, that hasn't worked. I believe the reasons are tied up in #versions, particularly the difference between electron-forge v6.0 and its beta-predecessors.


I expect the links in here will notify the electron-forge authors. If it does - thanks so much! The overriding message here is: this library has been invaluable. The secondary message is, keeping track of the subtleties of how we use it.