question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack code-splitting produce wrong chunks paths

See original GitHub issue

Preflight Checklist

  • [x ] I have read the contribution documentation for this project.
  • [ x] I agree to follow the code of conduct that this project follows, as appropriate.
  • [x ] I have searched the issue tracker for a bug that matches the one I want to file, without success.

Issue Details

  • Electron Forge Version:
    • 6.0.0-beta.50
  • Electron Version:
    • 8.2.1
  • Operating System:
    • macOS 10.15.4

Expected Behavior

Webpack code chunks are resolved and loaded successfully in production mode

Actual Behavior

Webpack code chunks cannot be resolved and loaded in production mode (but in dev it works)

To Reproduce

  • use react lazy-loading in your app (for example, make some /page route lazy-loading)
  • use webpack config without optimisation preferences
  • run electron-forge package
  • check out/name.app/Resources/app/.webpack/renderer folder.
  • See main_window/index.jsthere - it’s an entry point of the app
  • See 1/index.js there - as I understand, it’s a chunk of our splitted route
  • Run built app
  • Go to /page route
  • Observe 404 error in console - it tries to load renderer/main_window/1/index.js instead of renderer/1/index.js

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

4reactions
sebastianwdcommented, Apr 10, 2020

I think I managed to make it work. I added this to my webpack.renderer.config.js

output: { chunkFilename: 'main_window/[name].chunk.js', publicPath: '../', },

So what this does is create the files in the main_window directory entry, this alone would make webpack search for the file main_window/main_window/0.chunk.js and return 404. So I added the publicPath property to search outside that directory and make the paths coincide.

0reactions
ianpogi5commented, May 4, 2021

@sebastianwd Thank you very much!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack code-splitting produce wrong chunks paths #1612
I faced with the same issues, but fix above not working for me, I am still getting chunk loading error, for fix issue...
Read more >
Code Splitting - webpack
Entry Points: Manually split code using entry configuration. Prevent Duplication: Use Entry dependencies or SplitChunksPlugin to dedupe and split chunks.
Read more >
Webpack, new chunk is loading in with wrong path
bundle.js is an unnamed chunk created by code splitting. It will be placed in the output:path mentioned above but will be referred in...
Read more >
The 100% correct way to split your chunks with Webpack
The idea behind bundle splitting is pretty simple. If you have one giant file, and change one line of code, the user must...
Read more >
Code Splitting - webpack 3 documentation
Prevent Duplication: Use the CommonsChunkPlugin to dedupe and split chunks. Dynamic Imports: Split code via inline function calls within modules.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found