bytenode-webpack-plugin
bytenode-webpack-plugin copied to clipboard
Fixes herberttn/bytenode-webpack-plugin#5
Webpack 5 seems to pass through entrypoint paths with a more complex data structure, e.g. in an Electron context:
[{ main_window: { import: ['./src/index.ts'] } }]
Whereas the plugin would expect:
[{ main_window: './src/index.ts' }]
These commits add in some extra data manipulation to give the plugin the file paths as expected.
Todo:
- [ ] Dig out the Webpack docs/spec to ensure these fixes are compatible with all potential entry inputs
- [ ] Test extensively with more than just an electron-forge + TS + Webpack template app
@cfadams on the surface this looks good. Can you address the lint errors?
I tested this PR manually, and got this error:
webpack5 & electron-builder
Same as ☝️
More error logs to help debug:
ERROR in main
Module not found: Error: Can't resolve './src' in '/Users/janedoe/Development/shell'
resolve './src' in '/Users/janedoe/Development/shell'
using description file: /Users/janedoe/Development/shell/package.json (relative path: .)
using description file: /Users/janedoe/Development/shell/package.json (relative path: ./src)
no extension
/Users/janedoe/Development/shell/src is not a file
.js
/Users/janedoe/Development/shell/src.js doesn't exist
.ts
/Users/janedoe/Development/shell/src.ts doesn't exist
.node
/Users/janedoe/Development/shell/src.node doesn't exist
as directory
existing directory /Users/janedoe/Development/shell/src
using description file: /Users/janedoe/Development/shell/package.json (relative path: ./src)
using path: /Users/janedoe/Development/shell/src/index
using description file: /Users/janedoe/Development/shell/package.json (relative path: ./src/index)
no extension
/Users/janedoe/Development/shell/src/index doesn't exist
.js
/Users/janedoe/Development/shell/src/index.js doesn't exist
.ts
/Users/janedoe/Development/shell/src/index.ts doesn't exist
.node
/Users/janedoe/Development/shell/src/index.node doesn't exist
Relevant config:
merge.smart(baseConfig, {
target: "electron-main",
entry: {
main: "src/main/index.ts",
},
node: {
__dirname: false,
__filename: false
},
output: {
path: path.join(__dirname, "out", "main"),
libraryTarget: "commonjs"
},
plugins: [
new BytenodeWebpackPlugin({
compileForElectron: true
})
]
})
Also fails with same error with:
entry: [
"src/main/index.ts",
]
Does anyone work on this PR? If not: What should be done to merge this PR?
Does anyone work on this PR? If not: What should be done to merge this PR?
The PR does not solve the problem, it should not be merged.
I started working on this here, https://github.com/dopry/bytenode-webpack-plugin/tree/feat/webpack5. Updating the entrypoint only fixes the initial errors on configuration and doesn't address other internal webpack api changes. In all honesty I don't know where I stopped on my branch, but would appreciate help completing the work from someone more familiar with webpack.
Agreed with @dopry that knowledge of Webpack 5 is needed to get this over the line. Happy to close and abort this PR given this isn't a solution?
@cfadams lets keep this open a as a work space for now, so the discussion doesn't get split...
I did find https://github.com/webpack/webpack/issues/11425, which seems to indicate we should be using the processAssets instead of emit.
https://github.com/herberttn/bytenode-webpack-plugin/releases/tag/v2.0.0