Help trying to import ES module into preload process #947
Replies: 1 comment
-
Moved away from Electron so no longer have this problem. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My issue is that I have an electron app here: https://github.com/learn-anything/learn-anything
And inside
preload
function I want to use this package:https://github.com/syntax-tree/mdast-util-from-markdown
My preload function looks like this:
https://github.com/learn-anything/learn-anything/blob/main/app/packages/preload/src/index.ts
It tries to do this import:
https://github.com/learn-anything/learn-anything/blob/main/app/packages/preload/src/index.ts#L25
But this breaks electron fully as it tres to import from this file that has esm module import.
Is it possible to make imports from lib at root work with preload?
I tried solution outlined in this discussion here with ssr.noExternal:
#856
I added these lines:
https://github.com/learn-anything/learn-anything/blob/main/app/packages/preload/vite.config.js#L17
But it did not help and app still crashes.
Also after adding above line, it actually tries to get some aws-sdk package which I don't import anywhere in my app.
To replicate issue, can clone repo. Run
pnpm i
,pnpm dev-setup
andpnpm app:dev
to start electron. What's inside app is basically the template. I just have shared code logic one folder up inlib
. And would love to use functions exported from lib even if they have esm only imports in there.Thank you for the help.♥️
Beta Was this translation helpful? Give feedback.
All reactions