fix(html): keep module scripts with src and inline content in build - #23421
Open
2234839 wants to merge 2 commits into
Open
fix(html): keep module scripts with src and inline content in build#234212234839 wants to merge 2 commits into
2234839 wants to merge 2 commits into
Conversation
Per the HTML spec, a script with both a `src` attribute and inline content must only execute the external script and ignore the content. In buildHtmlPlugin, when a module script had a src that was excluded from bundling (external URL, data URL) or referenced a public file, and the tag also contained text (e.g. a newline), the code fell into the inline-module branch: the whitespace was treated as an inline module and the whole script tag was removed, silently dropping the external script. The dev server already handles this correctly by checking `src` first. Only treat the content as an inline module when the script has no src at all.
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.
Per the HTML spec, a script with both a
srcattribute and inline content must only execute the external script and ignore the content.In buildHtmlPlugin, when a module script had a src that was excluded from bundling (external URL, data URL) or referenced a public file, and the tag also contained text (e.g. a newline), the code fell into the inline-module branch: the whitespace was treated as an inline module and the whole script tag was removed, silently dropping the external script. The dev server already handles this correctly by checking
srcfirst.Only treat the content as an inline module when the script has no src at all.