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

Error in electron-vite: Unable to load preload script because of "missing file" in chunks folder. #282

Closed
4 tasks done
Uncasted opened this issue Sep 14, 2023 · 7 comments

Comments

@Uncasted
Copy link

Describe the bug

http://prntscr.com/WvyfJ-x97k4S

Any idea why this could be happening? The chunks folder is there and it contains the module but it says it's missing for some reason.

Electron-Vite Version

1.0.25

Electron Version

24.6.2

Vite Version

4.4.2

Validations

@alex8088
Copy link
Owner

https://electron-vite.org/guide/dev.html#limitations-of-sandboxing for more details.

Because the require function is a polyfill with limited functionality, you will not be able to use CommonJS modules to separate your preload script into multiple files, unless sandbox: false is specified.

@Uncasted
Copy link
Author

Is there a way I could fix this without disabling sandbox? Would it work if they were ES modules instead?

@alex8088
Copy link
Owner

@Uncasted You can refactor preload to bundle it into a single file. If you use a third-party library, you need to turn off externalizeDepsPlugin to bundle it.

@stefmedjo

This comment was marked as off-topic.

@alex8088

This comment was marked as off-topic.

@stefmedjo

This comment was marked as off-topic.

@matthme
Copy link

matthme commented Dec 3, 2023

I'm actually having the same issue when using multiple windows with independent preload scripts that both depend on shared dependencies. In that case there's no way to configure electron.vite.config.ts in a way to not generate chunks (see the corresponding issue in rollup). I think it's worth re-opening this issue as I think electron-vite should make sure preload scripts get bundled as independent single files.

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

No branches or pull requests

4 participants