Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always used named chunks AND prevent split chunks from changing too often. #462

Merged
merged 5 commits into from
Nov 29, 2018

Conversation

weaverryan
Copy link
Member

Fixes #461

But, this does not expose the entry names internally in the code (as these are used instead of auto-incremet ids). I don't think there's a way around that.

Also, I'm still tracking down a somewhat related but that causes a related issue (meaningless id's changing in generated code) under very specific conditions. In fact, you can see it in this test case just by changing all the 3 of the entries to an array - e.g.

config.addEntry('main1', ['./js/code_splitting']);
if (includeExtraEntry) {
    config.addEntry('main2', ['./js/eslint']);
}
config.addEntry('main3', ['./js/no_require']);

That doesn't need to block this PR, but I need to figure out the issue (it's Webpack behavior) and see if it affects versioning (i.e. if the contents change but the file hashes do NOT change, this is a BIG problem, otherwise, it's more of a minor, performance problem as filenames would just be changing too often).


done();
});
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test just moved

@weaverryan weaverryan changed the title Always used named chunks to avoid caching problems Always used named chunks AND prevent split chunks from changing too often. Nov 28, 2018
@weaverryan
Copy link
Member Author

I just added an unrelated, second bug fix to this, because it uses much of the same code.

It is described here: webpack/webpack#8426

Basically, when using splitEntryChunks(), the split filenames would change whenever a new entry required that split content - even if NOTHING else changed. The fix is simple: to set splitChunks.name = false, which causes the split chunk names to look like ajax split chunk names - e.g. 0.js.

@weaverryan weaverryan merged commit a8b6725 into symfony:master Nov 29, 2018
weaverryan added a commit that referenced this pull request Nov 29, 2018
…ing too often. (weaverryan)

This PR was squashed before being merged into the master branch (closes #462).

Discussion
----------

Always used named chunks AND prevent split chunks from changing too often.

Fixes #461

But, this does not expose the entry names internally in the code (as these are used instead of auto-incremet ids). I don't think there's a way around that.

Also, I'm still tracking down a somewhat related but that causes a related issue (meaningless id's changing in generated code) under very specific conditions. In fact, you can see it in this test case just by changing all the 3 of the entries to an array - e.g.

```js
config.addEntry('main1', ['./js/code_splitting']);
if (includeExtraEntry) {
    config.addEntry('main2', ['./js/eslint']);
}
config.addEntry('main3', ['./js/no_require']);
```

That doesn't need to block this PR, but I need to figure out the issue (it's Webpack behavior) and see if it affects versioning (i.e. if the contents change but the file hashes do NOT change, this is a BIG problem, otherwise, it's more of a minor, performance problem as filenames would just be changing too often).

Commits
-------

a8b6725 Making how the splitting works more consistent
4de5536 Fixing tests
13e07c6 linking to issue
7c96476 Fixing a bug where split filenames might change too often
a426b8c Always used named chunks to avoid caching problems
@stof
Copy link
Member

stof commented Nov 29, 2018

@weaverryan are the split chunks named 0.js or something like 0-[hash].js ? If there is no hash, it breaks long-term caching

@Lyrkan
Copy link
Collaborator

Lyrkan commented Nov 29, 2018

@stof I did a quick check and it seems to be fine.

If the option that defines how chunks are named (output.chunkFilename) is not set it takes the value of output.filename... which now contains [name].[contenthash:8].js when versioning is enabled (#463).

For instance, when adding Encore.enableVersioning() to the "Use splitChunks in production mode" test, it creates the following files:

  • /build/runtime.6cf710cd.js
  • /build/0.241ffa77.js
  • /build/1.b31df8bf.js
  • /build/main.a3f15efa.js
  • /build/1.a60ee57d.css

@stof
Copy link
Member

stof commented Nov 29, 2018

OK, then things are fine.

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

Successfully merging this pull request may close these issues.

3 participants