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

Enable support for ES modules #14482

Open
komret opened this issue Sep 23, 2024 · 1 comment · May be fixed by #15544
Open

Enable support for ES modules #14482

komret opened this issue Sep 23, 2024 · 1 comment · May be fixed by #15544
Assignees
Labels
dependencies Pull requests that update a dependency file

Comments

@komret
Copy link
Contributor

komret commented Sep 23, 2024

Configure Electron build process to output main and preload bundles as ES instead of CommonJS.
That is possible since electron 28.0.0.

It is needed to upgrade dependencies which do not support CommonJS anymore:

@komret komret added the dependencies Pull requests that update a dependency file label Sep 23, 2024
@github-project-automation github-project-automation bot moved this to 🎯 To do in Issues Suite Sep 23, 2024
@Lemonexe Lemonexe self-assigned this Nov 25, 2024
@Lemonexe Lemonexe moved this from 🎯 To do to 🏃‍♀️ In progress in Issues Suite Nov 25, 2024
@Lemonexe Lemonexe linked a pull request Nov 25, 2024 that will close this issue
@Lemonexe Lemonexe moved this from 🏃‍♀️ In progress to 🎯 To do in Issues Suite Dec 5, 2024
@Lemonexe Lemonexe moved this from 🎯 To do to 🏃‍♀️ In progress in Issues Suite Dec 12, 2024
@Lemonexe Lemonexe moved this from 🏃‍♀️ In progress to 🎯 To do in Issues Suite Dec 20, 2024
@Lemonexe
Copy link
Contributor

Lemonexe commented Jan 8, 2025

Status report: TL;DR: tried many things, invested a lot of effort, but did not come up with a viable solution yet ❌

Electron-store + CJS

Original problem: it's incompatible, as stated. Build runs fine, but in runtime, the electron-main script throws ❌

Webpack + ESM

WIP in #15544
Does not work with chunking, see the PR. Though it does successfully run without chunking ✅
Since chunking was the very reason for switching ESBuild to Webpack (main+preload) in #9931, it's not something we can write off easily.
➡ I'd like to make minimal reproduction example and report bug at Webpack. Maybe it can be fixed there..

Rspack exploration work

An emerging bundler that seeks to reimplement webpack in rust, being mostly compatible. They claim that projects with simple config can replace Webpack with Rspack 1:1 with almost no effort.

💭 🤔 Maybe, just maybe, ESM could work better in Rspack? Also, it could significantly improve DX - much faster initial dev bundle + HMR 😍
➡️ So I explored.

But in Trezor Suite, our webpack config is very complex. It required a considerable effort. I've made it work for main+preload with CJS, but I have not finished renderer.. See #16017
Anyway, since main+CJS works I tried ESM, but it's even more broken than in webpack (branch here) 🙈

The peformance benefits do look promising, about 50% quicker for dev builds.

Conclusion: I couldn't make Rspack work, and see no clear path forward. It was a lot of effort, but personally I'd write it off as sunken costs 😢

@Lemonexe Lemonexe moved this from 🎯 To do to 🚫 Blocked in Issues Suite Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
Status: 🚫 Blocked
Development

Successfully merging a pull request may close this issue.

2 participants