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

Upgrage Electron and Bundler #715

Closed
3 tasks
ErikSin opened this issue Jan 19, 2023 · 7 comments
Closed
3 tasks

Upgrage Electron and Bundler #715

ErikSin opened this issue Jan 19, 2023 · 7 comments
Assignees
Labels

Comments

@ErikSin
Copy link
Contributor

ErikSin commented Jan 19, 2023

To be compatible with the new Mapeo Core, the Electron version needs to be upgraded to version 22.0.3

As well, the current bundler (webpack) can be replaced with Vite-Electron.

Requirements

  • Electron Version: 22.0.3
  • Typescript Compatible
  • Hot Reloading

This electron version requires node v 16.17.1

@ErikSin
Copy link
Contributor Author

ErikSin commented Jan 24, 2023

Upgrading Electron

  • eslint-plugin-flowtype incompatible - was removed
  • react-intl-formatted-duration required peer dependency react-intl >=v4 . Upgraded react-intl from 3.2.4 to 4.7.6. Breaking API changes in react-intl do not apply to anything in our codebase
  • better-sqlite3, when running electron-rebuild throwing "error: no member named 'CreationContext' in 'v8::Object'", related to this closed issue. In mapeo-map-server, better-sqlite3 needs to be upgraded to v8.0.0. This drops support for node 12, which may be an issue for mapeo-mobile? I stubbed out mapeo-map-server temporarily.
  • npm run dev script electron . --debug was replaced with electron . --inspect

@ErikSin
Copy link
Contributor Author

ErikSin commented Jan 24, 2023

Electron breaking changes from v9 to v22

v10

  • Changed the default value of 'enableRemoteModule' to false. #22091
  • Changed the default value of app.allowRendererProcessReuse to true, this will prevent loading of non-context-aware native modules in renderer processes. See #18397 for more information on this change. #22336
  • Fixed the positioning of window buttons on MacOS when the OS locale is set to an RTL language (like Arabic or Hebrew). Frameless window apps may have to account for this change while styling their windows. #22016

v11

  • Removed experimental APIs: BrowserView.{destroy, fromId, fromWebContents, getAllViews} and the id property of BrowserView. #23578

v12

  • Changed the default of crashReporter.start({ compress }) from false to true. #25288
  • Changed the default value of contextIsolation to true. #27949
  • Changed the default value of worldSafeExecuteJavaScript to be true. #27502
  • Deprecated the remote module. It is replaced by @electron/remote. [#25293]
  • Deprecated the new-window event of WebContents. It is replaced by webContents.setWindowOpenHandler(). #24517

v13

  • Fixed so window.open() parameter frameName is no longer set as window title. #27481
  • Changed session.setPermissionCheckHandler(handler) to allow for handler's first parameter, webContents to be null.
    #19903

v14

  • Child windows no longer inherit BrowserWindow construction options from their parents. #28550
  • Deprecated worldSafeExecuteJavaScript option was removed from webPreferences. #28456
  • Removed deprecated additionalFeatures property from new-window and did-create-window WebContents events. #28548
  • Removed the deprecated app.allowRendererProcessReuse and BrowserWindow affinity options. #26874

v15

  • nativeWindowOpen: true is now the default. #28552

v16

  • The crashReporter API is now powered by Crashpad on Linux. #30278
  • Usage of the desktopCapturer.getSources API from the renderer process has been deprecated and will be removed. 30721

v17

  • desktopCapturer.getSources is now only available in the main process. #30720

v18

  • Removed the old BrowserWindowProxy-based implementation of window.open. This also removes the nativeWindowOpen option from webPreferences. #29405

v19

  • Added BrowserWindow method to change the button color, symbol color, and height of a window with WCO enabled. #33066 (Also in 18)
  • Added nativeTheme.inForcedColorsMode API to allow detecting forced color mode. #32956 (Also in 15, 16, 17, 18)
  • Added ses.setCodeCachePath() API for setting code cache directory. #31154 (Also in 17, 18)
  • Added ability to configure if window should close when opener closes. #31314
  • Added support for more color formats in setBackgroundColor. #31868 (Also in 18)
  • Added warning that preload scripts will be sandboxed by default beginning in Electron 20. #32868 (Also in 18)
  • Enabled systemPreferences.subscribe{Local|Workspace}Notification to take a null value for the event parameter. #33770 (Also in 18)
  • Fixed an issue where calling setTitlebarOverlay with an initially invalid titleBarStyle on Windows would result in a crash. #34302
  • Fixed an issue where the PDF Viewer would fail if a user attempted to reload. #33712 (Also in 18)

v20

  • Removed the skip-taskbar feature on Linux. #35156
  • Renderers are now sandboxed by default unless nodeIntegration: true or sandbox: false is specified. #35125
  • Added safeguards when building native modules with nan. Use node-gyp >=8.4.0 and electron-rebuild >=3.2.9 for when rebuilding native modules. #35160

v21

v22

  • Added WebContents input-event event. (Deprecated BrowserWindow scroll-touch-* events. #35531)
  • The deprecated new-window event has been removed. #34526

@ErikSin
Copy link
Contributor Author

ErikSin commented Jan 30, 2023

Work started on this branch

@achou11
Copy link
Member

achou11 commented Feb 2, 2023

after pairing with Erik yesterday, the following issues were addressed:

  • fixing @mapeo/map-server + better-sqlite3 integration
  • using @electron/remote instead of now removed remote api from electron (not sure if fully resolved yet)
  • fixing electron-is-dev usage (due to electron remote issue)

@achou11
Copy link
Member

achou11 commented Feb 2, 2023

another pairing session with Erik today. the following issues were addressed:

  • fixed an issue where the map server creation would crash if the electron directory didn't exist yet
  • fixed issue with importing the @electron/remote in the renderer. required using import * as remote syntax

the app runs locally now! was even able to sync a small amount of data with my phone.

next steps are more thorough testing and figuring out what's broken.

image

separately, wondering if the map server directory background-maps/ should not be living in the user data directory when in development mode (instead be in temp-resources/), or if that's okay. could be pretty catastrophic for people who use the map server in production mapeo and also develop Mapeo locally, which is an almost-zero number of people right now 😅

@achou11
Copy link
Member

achou11 commented Feb 8, 2023

after playing around with Vite and some vite electron plugins, thinking that this issue should be split into two items:

  1. Electron upgrade
  2. Bundler upgrade

To my knowledge, upgrading Electron can be done independently without requiring major changes to our frontend setup. For the sake of better isolating these major changes, doing them separately will be easier to manage and review.

Additionally, thinking that Vite may not be the option we want to use after my explorations. There's some deceptive complexity with it (maybe because of Electron) that I haven't fully managed to wrap my head around. Wondering if we can achieve 80% with just using Rollup and relevant plugins with the goal of creating a setup that

  1. Improves the dev experience compared to what we currently have
  2. Something that is maintainable and doesn't rely too much on magic from external deps

at the expense of some of the dev experience that Vite provides (when it works). Something to discuss in more detail

@ErikSin
Copy link
Contributor Author

ErikSin commented Jun 7, 2023

Closing ticket, and replacing with #726

@ErikSin ErikSin closed this as completed Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

No branches or pull requests

2 participants