Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@AndrewJakubowicz
Copy link
Contributor

Fixes: #4047 (comment)

Issue: #189
RFC: lit/rfcs#21
Full prototype PR: #3984

Why

@rictic pointed out an oversight that the naive logic of minifying empty comments could match and miscompile code if these empty comments were used elsewhere.

Example

The code:

<style>
  div::before {
    content: '<!---->';
  }
  div::after {
    content: '<!--?-->';
  }
</style>
<div>Hello world</div>

Renders: <!---->Hello world<!--?-->.

However when compiled without this fix, the compiled code would result in <?>Hello world<?> rendering.

Fix

Only minify marker comments by matching on <!--lit$12345$--> and converting them to <?>. It's then far less likely to result in a collision.

Test

Added a regression golden test case.

@changeset-bot
Copy link

changeset-bot bot commented Jul 27, 2023

🦋 Changeset detected

Latest commit: a5915c0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

@github-actions
Copy link
Contributor

github-actions bot commented Jul 27, 2023

📊 Tachometer Benchmark Results

Summary

A summary of the benchmark results will show here once they finish.

Results

The full results of your benchmarks will show here once they finish.

tachometer-reporter-action v2 for Benchmarks

@AndrewJakubowicz AndrewJakubowicz changed the title [lit-labs/compiler] Only compress marker comments [lit-labs/compiler] only compress marker comments Jul 27, 2023
Copy link
Member

@augustjk augustjk left a comment

Choose a reason for hiding this comment

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

Nice!

@AndrewJakubowicz AndrewJakubowicz merged commit 5f6f1ef into main Jul 28, 2023
@AndrewJakubowicz AndrewJakubowicz deleted the compiler-only-minify-marker-comments branch July 28, 2023 20:54
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