bytenode-webpack-plugin icon indicating copy to clipboard operation
bytenode-webpack-plugin copied to clipboard

Fixes herberttn/bytenode-webpack-plugin#5

Open cfadams opened this issue 3 years ago • 8 comments

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 avatar Jul 18 '21 11:07 cfadams

@cfadams on the surface this looks good. Can you address the lint errors?

dopry avatar Jul 19 '21 22:07 dopry

I tested this PR manually, and got this error: image

webpack5 & electron-builder

Alecyrus avatar Aug 17 '21 10:08 Alecyrus

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",
]

mmaietta avatar Aug 17 '21 23:08 mmaietta

Does anyone work on this PR? If not: What should be done to merge this PR?

Zomono avatar Sep 22 '21 07:09 Zomono

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.

Alecyrus avatar Sep 22 '21 07:09 Alecyrus

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.

dopry avatar Oct 04 '21 15:10 dopry

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 avatar Oct 05 '21 12:10 cfadams

@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.

dopry avatar Oct 05 '21 14:10 dopry

https://github.com/herberttn/bytenode-webpack-plugin/releases/tag/v2.0.0

herberttn avatar Oct 20 '22 05:10 herberttn