Webpack template does not work with native modules on Windows
See original GitHub issuePre-flight checklist
- I have read the contribution documentation for this project.
- I agree to follow the code of conduct that this project uses.
- I have searched the issue tracker for a bug that matches the one I want to file, without success.
Electron Forge version
6.0.0-beta.64
Electron version
v19.0.7
Operating system
Windows 10 (19044)
Last known working Electron Forge version
No response
Expected behavior
Webpack template should work with native modules on Windows
Actual behavior
Webpack template fails with native modules because it uses Linux paths on Windows
Steps to reproduce
- As per steps on the documentation, run:
npx create-electron-app my-new-app --template=webpack
- Add a native module npmjs package, like this one:
yarn add @nut-tree/nut-js
- Package application using
yarn package
.
Received error:
WARNING in ./src/main.js
Invalid dependencies have been reported by plugins or loaders for this module. All reported dependencies need to be absolute paths.
Invalid dependencies may lead to broken watching and caching.
As best effort we try to convert all invalid values to absolute paths and converting globs into context dependencies, but this is deprecated behavior.
Loaders: Pass absolute paths to this.addDependency (existing files), this.addMissingDependency (not existing files), and this.addContextDependency (directories).
Plugins: Pass absolute paths to fileDependencies (existing files), missingDependencies (not existing files), and contextDependencies (directories).
Globs: They are not supported. Pass absolute path to the directory as context dependencies.
The following invalid values have been reported:
* "G:/t2/new-app/node_modules/@babel/runtime/LICENSE"
* "G:/t2/new-app/node_modules/@babel/runtime/helpers/AsyncGenerator.js"
* "G:/t2/new-app/node_modules/@babel/runtime/helpers/AwaitValue.js"
* and more ...
Additional information
Vercel webpack asset relocator loader v1.7.1 has a fix for Windows path handling. See commit: https://github.com/vercel/webpack-asset-relocator-loader/commit/38f839f36b6e80c925194cb8442b6b0f0f3f2e31
But the webpack template for electron is pinned to version 1.7.0 (see docs), therefore this fix is missing from there. The docs linked above say that:
Warning: Electron Forge needs to monkeypatch the asset relocator loader in order for it to work with Electron properly, so the version has been pinned to ensure compatibility. If you upgrade that version, you do so at your own risk.
Now I upgraded the package to 1.7.2 and still got the same error on packaging. I wonder if the monkeypatch is interfering with vercel’s patch.
Would appreciate any quick workarounds to solve this, while a proper fix is implemented.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
@GaurangTandon No worries at all, really appreciate both the report and the fast response! Let us know if you have any issues in the future 🙂
Hi @VerteDinde , I am very surprised as now I am also unable to reproduce the issue. Only Electron seems to have updated to v19.0.8 in the meantime, but the update seems irrelevant to this issue.
I apologize I don’t have any more information. Feel free to close this ticket if you wish to.