Register runtime as dependency if found#48
Merged
Conversation
kadamwhite
requested changes
Aug 11, 2022
Collaborator
kadamwhite
left a comment
There was a problem hiding this comment.
One process question and two style nits
| $handles = []; | ||
|
|
||
| if ( is_css( $asset_uri ) ) { | ||
| // Don't set runtime JS as dependency of a CSS file. |
Collaborator
There was a problem hiding this comment.
Could we call is_css( $asset_uri ) again up above, and use that as the condition for looking up the runtime, instead of having to undo it later? Something like,
if ( $runtime && ! is_css( $asset_uri ) ) {Co-authored-by: K Adam White <kadamwhite@users.noreply.github.com>
Co-authored-by: K Adam White <kadamwhite@users.noreply.github.com>
Member
Author
|
Feedback addressed. |
kadamwhite
approved these changes
Aug 17, 2022
Collaborator
kadamwhite
left a comment
There was a problem hiding this comment.
Thanks @mattheu !
Can we add this to the changelog? We'll need to document this magic somewhere too but the docs generally are a bit bare rn
kadamwhite
requested changes
Aug 26, 2022
| $asset_version = Manifest\get_version( $asset_uri, $manifest_path ); | ||
| $is_asset_css = is_css( $asset_uri ); // Note returns false for the CSS dev JS fallback. | ||
|
|
||
|
|
Collaborator
There was a problem hiding this comment.
It's a small thing, but the double-spacing here is breaking linting.
kadamwhite
reviewed
Feb 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Something we have faced when updating
@humanmade/webpack-helpersto Webpack v5 is that hot reloading does not work correctly when you have multiple JS files emitted by a single webpack configuration and loaded on a page at the same time.The issue is caused by the fact that each file emitted has the webpack runtime included. The fix for this is to split that into a separate file by setting
optimization: { runtimeChunk: 'single' }in your webpack dev config. This spits out a new JS fileruntime.jsthat needs to be loaded once per page.What does this PR do? It detects if
runtime.jsis present in the manifest, and if so it registers that script and sets it as a dependency of the asset being loaded. This ensures it is always loaded, but only once, on the page