Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Using script-loader seems to lead to a different [chunkhash] being generated each time #56

Closed
jakub-g opened this issue Aug 30, 2018 · 6 comments

Comments

@jakub-g
Copy link
Contributor

jakub-g commented Aug 30, 2018

Hello,

First of all, I know that [chunkhash] is not the best idea for long term caching, and it's better to use a plugin that creates content-hash, which we will probably do very soon.
Nevertheless I wanted to report the issue, even if only to help some other people who are investigating similar issues.


So, we're using webpack 3.x for now, and we have two external scripts, let's call them foo and bar that are loaded through script-loader 0.7.1 like this:

  loadFooLib() {
    return import(/* webpackChunkName: 'foobar' */ 'script-loader!foo')
  },

(with foo$: 'html/vendor/foo/Foo' in webpack resolve config).

When we run the build twice after some time, without any code change in foo or bar (for example, a non-code commit), this often* results in the chunkhash change for foo and bar (the chunks that go through script-loader), and no output change for the other chunks -- and this in turn means that the manifest chunk has to be regenerated as well.

*often = not always, and it's happening a lot on our Linux build machines, but I could not reproduce so far on Windows

Looking at the code, things look very simple and there seems to be no obvious reason for script-loader to generate different chunkhash each time.

@sokra Do you have any ideas? Is this kind of issue more likely to be on the plugin side, or webpack side?

@michael-ciniawsky
Copy link
Member

It's a bit 'old' but maybe it helps https://medium.com/webpack/predictable-long-term-caching-with-webpack-d3eee1d3fa31, otherwise I'm sry but it is very hard to exactly tell where/what in your application currently causes the [chunkhash] to change

@jakub-g
Copy link
Contributor Author

jakub-g commented Oct 25, 2018

FWIW we've migrated do webpack 4 and contenthash (and followed all other best practices to get reproducible builds) and this still happens (only for stuff loaded with script-loader).
Will need to deep dive into it to figure out what's exactly happening.

@jakub-g
Copy link
Contributor Author

jakub-g commented Dec 22, 2018

Update: from what I've noticed in the recent weeks, the issue actually happens also for some new chunks in our project that are not loaded via script-loader. The issue is not script-loader then (probably).

webpack/webpack#7179 (comment)

@onlybye
Copy link

onlybye commented Mar 28, 2019

Update: from what I've noticed in the recent weeks, the issue actually happens also for some new chunks in our project that are not loaded via script-loader. The issue is not script-loader then (probably).

webpack/webpack#7179 (comment)
@jakub-g we have also met this problem, have you solved?

@jakub-g
Copy link
Contributor Author

jakub-g commented Mar 28, 2019

we have also met this problem, have you solved?

nope, not yet unfortunately

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants