Node externals from a package in an electron app #2469
Unanswered
karolis-sh
asked this question in
Troubleshooting
Replies: 2 comments 2 replies
-
Hi @karolis-sh , thanks for reporting. Going to pass this on to the other maintainers to investigate as a potential bug. |
Beta Was this translation helpful? Give feedback.
2 replies
-
There is at least a solution to the Typescript Issue: import type fsType from 'fs';
const fs = require('fs') as typeof fsType; But otherwise I'm also interested in a solution to the original problem of import. |
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
-
Hey there!
I'm trying to use snowpack for electron app development and I'm stuck on an issue. I'm having difficulties with node externals. I have declared all externals in the snowpack config and I can easily use them in my source code just by using common js import syntax:
But if a package from node_modules uses node external, then the external doesn't get treated as an external -
const fs = require("fs");
is converted toimport fs from 'fs';
and breaks:Minimal example https://github.com/karolis-sh/issue-snowpack-externals/blob/main/packages/snowpack-app/renderer/index.js
After some trial and error understood what was happening. Can get it working with commonjs syntax, but I'm losing typings:
Beta Was this translation helpful? Give feedback.
All reactions