Comments (7)
I found that I can override that setting in vite.main.config.js
:
// https://vitejs.dev/config
export default defineConfig({
resolve: {
...
},
build: {
lib: {
formats: ["es"],
},
},
});
I have another issue now though, as in esm __dirname is not available. This is needed to specify the index.html path and the preload file. I changed it to:
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
...
mainWindow.loadFile(path.join(dirname, "index.html"));
However, Vite replaces import.meta.url
with self.location
and then Vite errors out ReferenceError: self is not defined
.
If I replace them with relative paths, it loads the files but warns it wants an absolute path for preload.js.
Guessing some sort of MAIN_WINDOW_PRELOAD_VITE_ENTRY
and MAIN_WINDOW_VITE_ENTRY
will need to be generated outside of Vite similar to how the webpack plugin works?
from forge.
The combination of svelte + vite + electron + forge doesn't seem to work unless we have ESM support.
from forge.
Aweome! I haven't had a chance to try your suggestion but I'm starting a new project tomorrow and might mess around with it more. Hopefully the official support comes soon but good to know its coming by default soon!
from forge.
+1.
Thanks for your investigation!
I wonder if you tried import.meta.resolve(...)
? It's both more to the point and perhaps vite doesn't try to mess with it?
I'm brought here trying to use both @sveltejs/vite-plugin-svelte
which is esm-only, (and so it requires "type": "module"
in package.json), and this is tripping me up.
I think I can slap an dist-electron/package.json
in with { "type": "commonjs" }
as a work-around but it feels a bit horrid. 😉
from forge.
The combination of svelte + vite + electron + forge doesn't seem to work unless we have ESM support.
You can try to this 👉 #3309
The next version of Vite plugin will be use "type"="module"
by default, coming soon...
from forge.
Is this something that's planned? I'm hoping to use Forge with Svelte + Vite (not SvelteKit).
from forge.
The "horrid" workaround I suggested seems to be working for me. I've got vite
+forge
+tailwind
+typescript
+svelte
+melt
+workers
+import("node:module").register
(node20, electron29-alpha) working fine.
from forge.
Related Issues (20)
- electron-forge publish,Fatal error: Unable to commit changes
- Dependency on outcated core-js 2.x core-js/library/web/timers
- package.json does not exist at ./.vite/package.json HOT 1
- [email protected] can't handle universal arch native node.js module correctly on macOS. HOT 1
- [electron-forge make] EPERM: operation not permitted, rmdir. HOT 8
- the main entry point to your app was not found HOT 1
- rspack support HOT 1
- A custom plugin's init and hook methods are invoked twice during make
- Error: ENOENT, [email protected] not found in app.asar
- win app icon not change
- .vscode/settings.json changes on open HOT 2
- npm install modifies .zshrc HOT 1
- Use StyleX with Electron
- Still cannot make when package name is scoped (on Windows) HOT 1
- Add Vite+React+TypeScript template HOT 2
- DevDependencies are not removed when running electron-forge make HOT 3
- Vite Plugin for Svelte Support HOT 2
- The function of the maker-squirrel attribute is not explained and the exe file name is garbled. HOT 2
- Error => Could not find module with name '@electron-forge/maker-squirrel' HOT 2
- Can't move the forge config files in any subdirectory HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from forge.