Skip to content

webpack-dev-server compatibility #131

Description

@karolyi

Hello,

does this module have support for webpack 5?

It doesn't seem so to me.

Activity

  1. fjsj commented on Oct 8, 2025

    @fjsj
    Member

    It works both with 4 and 5. What issue are you seeing?
    All django-webpack-loader examples that use webpack-bundle-tracker use webpack 5: https://github.com/django-webpack/django-webpack-loader/tree/master/examples

  2. karolyi commented on Oct 8, 2025

    @karolyi
    Author

    Hm, I can't bring it to finish building.

    As to why I don't know yet, I will have to look into it. For me it seemingly builds the modules (CPU load high), and then just doesn't finish. This all with the latest version of webpack 5.

  3. fjsj commented on Oct 9, 2025

    @fjsj
    Member

    I see, we'll will try to reproduce with latest webpack 5.

  4. karolyi commented on Oct 9, 2025

    @karolyi
    Author

    I can't reproduce my issue with the webpack tests, but that doesn't mean there's no error. The module tests use very old dependencies, any of them could have broken this module since I (at least I aim to) use the latest versions of modules.

    I'm going to have to look deeper on my end.

  5. fjsj commented on Oct 9, 2025

    @fjsj
    Member

    You mean old devDependencies, right? Some of them are old due to webpack 4 support. We can drop that in near future with a new major version release.

  6. karolyi commented on Oct 11, 2025

    @karolyi
    Author

    So my initial investigation so far shows that even the modified code (which contains a lot of my originally rejected changes) wants to calculate integrity on _handleDone, but in my case the assets are not in there the filesystem where they are pointed to (probably because they're stored in the memory and not saved yet).

    My version (that still works) uses the _handleAssetEmitted hook where the content is available and is not pulled from a file that is nonexistent: at which point webpack compilation just silently hangs without an error emitted.

    I'm still using my version flawlessly, just wanted to try and give another go to this in the hopes of it being properly updated, which doesn't seem to be the case.

  7. karolyi commented on Oct 11, 2025

    @karolyi
    Author

    Oh yeah, I remember now why files aren't stored: webpack-dev-server. It only keeps the files in memory.

  8. karolyi commented on Oct 12, 2025

    @karolyi
    Author

    So I took the time today and made my fork run the tests. It involved plenty of fixes in the tests, but only one in lib/index.js which points out that my fork will work seamlessly with both webpack 4 AND 5, and with using webpack-dev-server too.

    I still don't care about reformatting the code, just corrected and run all the tests to see if webpack4 would work, which I don't use.

  9. karolyi commented on Oct 12, 2025

    @karolyi
    Author
  10. fjsj commented on Oct 13, 2025

    @fjsj
    Member

    thanks, we'll investigate

  11. self-assigned this
    on Oct 26, 2025
  12. rvlb commented on Oct 30, 2025

    @rvlb
    Contributor

    Hi @karolyi, we've been giving a look at this issue and managed to port over the changes from your fork to our branch (#132).

    However, once we were testing the changes on the examples at django-webpack-loader (i.e.: https://github.com/django-webpack/django-webpack-loader/tree/master/examples/simple), we've noticed an issue where the assetEmitted hook call is skipped if the asset file has already created on disk on previous run (as in the examples, if it's already at the webpack_bundles output dir), which ends up creating an inconsistent stats file.

    I've double-checked the examples using your fork code as-is and also detected the issue in that case. For both scenarios, however, the hot-reload example (https://github.com/django-webpack/django-webpack-loader/tree/master/examples/hot-reload) works flawlessly.

    My question then is to double-check if this ended up showing up for on your setup and if it was something that you ended up solving with some webpack setting.

    From our side, one possible solution we may end up trying to handle all cases is the following:
    Use a different hook (i.e.: processAssets), which could end up bringing the original problem on calculating the integrity since the asset isn't written to disk at that point, but we could try reading from the in-memory data instead of reading from the disk

    Let me know your thoughts on that. Thanks!

  13. karolyi commented on Oct 31, 2025

    @karolyi
    Author

    Hey,

    I've never faced this issue but also don't deny its existence. In my case I was using webpack-dev-server on my local dev env.

    The pipeline I've built for compiling assets with gulp, always cleans the output files before building them, so they can't exist. Hence, I can't reproduce this test case in my environment.

    Make of that what you will. I think the healthy way of building physical (non-in-memory) assets is to clean the output directory every time before doing it, at least that's what makes sense to me. Leaving the files there would imply some kind of an 'incremental' build.

  14. changed the title [-]Webpack 5 compatibility[/-] [+]webpack-dev-server compatibility[/+] on Oct 31, 2025
  15. rvlb commented on Nov 5, 2025

    @rvlb
    Contributor

    Integrity calculation has been revamped at #132, now we'll always use the content from the in-memory asset that webpack emits, which won't break with webpack-dev-server.

    An example with a similar setting has been updated on the django-webpack-loader side https://github.com/django-webpack/django-webpack-loader/blob/v3.2.2/examples/hot-reload/webpack.config.js.

  16. karolyi commented on Nov 12, 2025

    @karolyi
    Author

    I can confirm it works, although you've left out a lot of type imports from my version, that ensures typescript will be able to typecheck webpack 4 AND 5 compatibility.

    Since I only use webpack 5 I'm fine with it, but you may want to amend that if you still intend to support webpack 4.

  17. karolyi commented on Nov 12, 2025

    @karolyi
    Author

    Also, some credits would have been nice, but I can live with that. I already feature it in my contributions :)

  18. fjsj commented on Nov 12, 2025

    @fjsj
    Member

    that ensures typescript will be able to typecheck webpack 4 AND 5 compatibility.

    we'll verify that, thanks

    some credits would have been nice

    it was challenging to keep your original commits at Renato's PR, but we can later set up an AUTHORS.md file similar to Django one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions