alexwkleung / Iris

✨ A comfortable note-taking app powered by Markdown
https://irisnotes.vercel.app/
MIT License
15 stars 1 forks source link

Remove `electron-vite` for stock Electron (ESM) #63

Closed alexwkleung closed 9 months ago

alexwkleung commented 11 months ago

Starting from Electron 28, there will be support for ESM.

This means I won't need the dependency of electron-vite for ESM. If that's the case here, I want to remove electron-vite and use stock Electron.

This is the better choice long-term and has proper compatibility with newer Electron releases. If time permits, I will begin removing electron-vite at the end of the core cleanup and setting it up for Electron 28+.

alexwkleung commented 11 months ago

Some recent commits to prepare: 6f8d2e9, 3a72b1f, dfa5996

alexwkleung commented 9 months ago

Planning on updating to Electron v28 for ESM and removing electron-vite in v0.2.0-dev-6.0.

Not 100% sure if the migration process will be smooth but I'll give it a try.

alexwkleung commented 9 months ago

In Electron-ESM-Vite sample project, I'm testing to see if it's worth setting up Vite with Electron and ESM "natively" out of the box.

I've been running into some issues related to HMR/reloading and preload scripts, so that is one of the downsides for now. I have not tried packaging the application yet so I will test it as well.

For small projects, it might be sufficient. I'm mostly concerned about scalability and other edge cases that might cause things to break.

alexwkleung commented 9 months ago

In Electron-ESM-Vite sample project, I'm testing to see if it's worth setting up Vite with Electron and ESM "natively" out of the box.

I've been running into some issues related to HMR/reloading and preload scripts, so that is one of the downsides for now. I have not tried packaging the application yet so I will test it as well.

For small projects, it might be sufficient. I'm mostly concerned about scalability and other edge cases that might cause things to break.

I added HMR support to it and it seems to work fine for now. I am planning on trying this in v0.2.0-dev-6.0.

alexwkleung commented 9 months ago

Within the next few days, I will be working on migrating from electron-vite to Electron-ESM-Vite.

Since there are a lot of files in the source code, it will be a good test to see if it works.

alexwkleung commented 9 months ago

Currently in the process of migrating and for the most part it works fine.

However, the issue I'm facing is compiling the universal build of the app. For compiling macOS x64 and arm64 separately, it works without issues.

The error I'm getting is related to the glob pattern being too big. I don't know what would cause this so I'll need to dig further into the issue.

  • electron-builder  version=23.6.0 os=22.6.0
  • loaded configuration  file=package.json ("build" field)
  • writing effective config  file=dist/builder-effective-config.yaml
  • packaging       platform=darwin arch=x64 electron=28.0.0 appOutDir=dist/mac-universal--x64
  • packaging       platform=darwin arch=arm64 electron=28.0.0 appOutDir=dist/mac-universal--arm64
  • packaging       platform=darwin arch=universal electron=28.0.0 appOutDir=dist/mac-universal
  ⨯ pattern is too long  failedTask=build stackTrace=TypeError: pattern is too long
    at assertValidPattern (/Users/alex/Desktop/Git/Iris/node_modules/minimatch/minimatch.js:279:11)
    at minimatch (/Users/alex/Desktop/Git/Iris/node_modules/minimatch/minimatch.js:116:3)
    at handleFile (/Users/alex/Desktop/Git/Iris/node_modules/asar/lib/asar.js:123:26)
    at next (/Users/alex/Desktop/Git/Iris/node_modules/asar/lib/asar.js:148:11)
    at next (/Users/alex/Desktop/Git/Iris/node_modules/asar/lib/asar.js:149:12)
    at Object.exports.mergeASARs (/Users/alex/Desktop/Git/Iris/node_modules/@electron/universal/src/asar-utils.ts:198:5)
    at exports.makeUniversalApp (/Users/alex/Desktop/Git/Iris/node_modules/@electron/universal/src/index.ts:205:7)
    at MacPackager.doPack (/Users/alex/Desktop/Git/Iris/node_modules/app-builder-lib/src/macPackager.ts:125:9)
    at MacPackager.pack (/Users/alex/Desktop/Git/Iris/node_modules/app-builder-lib/src/macPackager.ts:192:7)
    at Packager.doBuild (/Users/alex/Desktop/Git/Iris/node_modules/app-builder-lib/src/packager.ts:441:9)
    at Object.executeFinally (/Users/alex/Desktop/Git/Iris/node_modules/builder-util/src/promise.ts:12:14)
    at Packager._build (/Users/alex/Desktop/Git/Iris/node_modules/app-builder-lib/src/packager.ts:376:31)
    at Packager.build (/Users/alex/Desktop/Git/Iris/node_modules/app-builder-lib/src/packager.ts:337:12)
    at Object.executeFinally (/Users/alex/Desktop/Git/Iris/node_modules/builder-util/src/promise.ts:12:14)
make: *** [build-mac-universal] Error 1

I will push the changes but need to note that the universal build for macOS might not be possible for now.

alexwkleung commented 9 months ago

Removed electron-vite in d1657e1