-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
webpack-asset-relocator-loader fails when adding native module to basic webpack template #2154
Comments
Hi @lostfictions ! Can you help me? When I put |
@pablodanilomota Really not sure why that would be, unfortunately. To be honest, I've been looking around for an alternate solution to electron-forge, since it seems to be in maintenance mode and lots of important issues are not getting addressed. There's commits being made, but 99% of them seem to be blind dependency bumps. For my part, beyond the existing bugs, it's getting more and more inconvenient to not be able to use Webpack 5. I may just end up writing my own watcher toolchain. It's a shame, since I think it's a really important part of the Electron ecosystem -- I wish the foundation/sponsors behind Electron proper would adopt it as an official tool so that it could be more actively developed and governed. |
I've been looking into a way to fix this and so far I've come up with a webpack plugin that modifies the code injected by the vercel plugin to be compatible with Electron renderers. You can see an example project here and the plugin that patches the code injection is here. If this is deemed to not be a terrible fragile solution, I'll submit a PR to add this to forge. |
This comment has been minimized.
This comment has been minimized.
For now, I've published this loader. that wraps the Vercel loader and works with forge. |
Preflight Checklist
Issue Details
Expected Behavior
Using the Prisma package with the webpack template should work correctly.
Actual Behavior
When trying to launch with
electron-forge start
, the following error is thrown:To Reproduce
A full repro is available here: https://github.com/lostfictions/electron-forge-webpack-native-repro
You can clone it and run
yarn
to install deps and thenyarn start
to see the issue.Steps to repro yourself:
yarn create electron-app my-new-app --template=webpack
.yarn add -D prisma
.yarn prisma generate
.main.js
:yarn start
. The error is produced on the console.Additional Information
I noticed that
@marshallofsound/webpack-asset-relocator-loader
was pretty outdated relative to@vercel/webpack-asset-relocator-loader
, so experimentally I tried replacing the former with the latter. This actually resolves the above issue!However, trying to actually use the library results in a different error, where it seems it cannot find some of the relocated assets. It spits out an error like this:
Sure enough, the assets in question have been relocated to
/<repo directory>/.webpack/main/native_modules
, and Prisma is not able to find them there.Removing
outputAssetBase
from the loader config so that assets are emitted to the base.webpack/main
directory resolves this issue:Finally, this results in a working project. You can see the working version in effect in a branch of the above repro repository: https://github.com/lostfictions/electron-forge-webpack-native-repro/tree/use-vercel-plugin. (However, I get that this might not be ideal -- it's not clear to me whether there's a risk of relocated native module assets clobbering other files if they're not placed under a subdirectory. It's unclear to me how to get Prisma working otherwise, unfortunately.)
Sorry for the long issue, but this does appear to be a fairly complex problem. I tried with a different native dependency (
better-sqlite3
) and noticed that it seems to work with the initial template, so it may be something unique to Prisma's configuration.The text was updated successfully, but these errors were encountered: