fix: read the parse goal an embedded JavaScript body is handed out with - #726
Open
alexander-akait wants to merge 1 commit into
Open
fix: read the parse goal an embedded JavaScript body is handed out with#726alexander-akait wants to merge 1 commit into
alexander-akait wants to merge 1 commit into
Conversation
`as` names which production of JavaScript a body is written in, the way it already names which production of CSS a `style=""` holds. The four built-in JavaScript minimizers now read it as their own `module` option, so a module script is not read as a classic one — and none of their engines is handed a word it would reject outright.
🦋 Changeset detectedLatest commit: 9c1b9fc The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #726 +/- ##
==========================================
+ Coverage 94.91% 95.00% +0.08%
==========================================
Files 4 4
Lines 1120 1120
Branches 391 391
==========================================
+ Hits 1063 1064 +1
+ Misses 50 49 -1
Partials 7 7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
asnames which production of a language an embedded body is written in — astyle=""arrives ascsswithas: "block-contents". JavaScript has two productions too, but the word reached the minimizer's options untranslated, and every built-in JavaScript engine rejects an unknown key outright: terser and uglify-js answer`as` is not a supported option, swcunknown fieldas``, esbuildTransform failed. So `as` could not be sent for JavaScript at all, and an inline `<script type="module">` was read as a classic script — a top-level `await` then being a build error rather than something to minify.The four built-in JavaScript minimizers now read
asas their ownmoduleoption and strip it, so a module script is read as one and no engine is handed the word. A minify function of your own claimingjavascriptstill receives it, as one claimingcssdoes today.What kind of change does this PR introduce?
fix
Did you add tests for your changes?
Yes —
test/embedded-protocol.test.jsgains adescribecovering all four built-ins: a body handed out as a module is minified by each, one handed out as a classic script is reported as the syntax error it is (rather than as an unsupported option), and one handed out with no goal named is left to the minimizer's own default.Does this PR introduce a breaking change?
No.
aspreviously threw for JavaScript, so nothing depended on the old behaviour.If relevant, what needs to be documented once your changes are merged or what have you already documented?
Documented in this PR — the Embedded source section of
README.mdgains the JavaScript half of theasparagraph.Use of AI
Claude Code was used, driven by me. It read the four option builders and the
renderEmbeddedSourcedispatcher, measured each engine's response toasand tomodulebefore and after the change, wrote the tests and the README paragraph, and rannpm run lintand the full suite (579 tests, 825 snapshots, green). I reviewed the diff and the measurements.Generated by Claude Code