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

fix(vite-template): fix vite template start failed after package #3713

Merged
merged 3 commits into from
Nov 12, 2024

Conversation

caoxiemeihao
Copy link
Member

@caoxiemeihao caoxiemeihao commented Sep 21, 2024

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • The changes are appropriately documented (if applicable).
  • The changes have sufficient test coverage (if applicable).
  • The testsuite passes successfully on my local machine (if applicable).

Summarize your changes:

Closes #3714

Since we removed the copy dependencies logic in vite-plugin of v7.5.0, this will cause if (require('electron-squirrel-startup')) to fail to load.
This is because Vite's built-in @rollup/plugin-commonjs cannot handle CommonJS's require() function like Webpack in many cases. We need to make some compromises in code writing and try to use ESModule's import statement to avoid this problem.

If anyone wants to know more about this issue, I wrote an article introducing the problem of Vite building CommonJS format code. 👉🏻 https://github.com/vite-plugin/vite-plugin-commonjs/blob/main/commonjs.zh-CN.md

@caoxiemeihao caoxiemeihao requested a review from a team as a code owner September 21, 2024 14:30
@caoxiemeihao caoxiemeihao changed the title Fix/vite template fix(vite-template): fix vite template start failed after package Sep 21, 2024
@caoxiemeihao caoxiemeihao requested review from a team, BlackHole1 and erickzhao and removed request for a team September 23, 2024 02:09
Copy link
Member

@BlackHole1 BlackHole1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hichemfantar
Copy link

let's merge this bad boy

@BlackHole1
Copy link
Member

PTAL @electron/forgers

@hichemfantar
Copy link

@caoxiemeihao can you explain the changes you’ve made to the type declarations code?

@VerteDinde VerteDinde added this pull request to the merge queue Nov 12, 2024
Merged via the queue into electron:main with commit f947936 Nov 12, 2024
12 checks passed
@hichemfantar
Copy link

hichemfantar commented Nov 14, 2024

hey, this pr removed the vite-forge type declarations in forge.env.d.ts which were broken because the actual declarations file wasn't present in @electron-forge/plugin-vite/forge-vite-env for some reason

i think the packaging process is not including the forge-vite-env.d.ts file for some reason

i added the file and now the reference /// <reference types="@electron-forge/plugin-vite/forge-vite-env" /> in forge.env.d.ts seems to be working correctly

image

image

@hichemfantar
Copy link

ah looks like the vite const type declarations were fixed in 3ad7485 but haven't been released yet which fixed the forge-vite-env.d.ts issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error: Cannot find module ´electron-squirrel-startup´ - Vite or Vite with Typescript on execute .exe
5 participants