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

Skip to content

Conversation

@AndrewJakubowicz
Copy link
Contributor

@AndrewJakubowicz AndrewJakubowicz commented Jul 26, 2023

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

Note to reviewer: Review this commit by commit – and skip reviewing parse5-utils cause I deleted it after feedback from @43081j.

Context

This PR splits out some initial compiler behavior from the full prototype PR in a reviewable chunk. This PR adds the core functionality that can be built upon in followup changes (and have been de-risked in the prototype).

Features

  • A transformer class, containing two AST traversals. One to locate the templates, and a second one to apply the transformation.
  • Support for compiling ChildParts. Other template parts such as attribute and element parts will be included in a followup.

This is a private only change, and no public entrypoints are being added.

In my opinion, the best place to start the review is at the CompiledTemplatePass.getTransformer() function which contains the high level flow of the transform:

  1. Create a CompiledTemplatePass instance.
  2. Find the templates to compile in the source file.
  3. Rewrite the templates – adding top level CompiledTemplates and replacing html tagged templates with CompiledTemplateResults.

Testing

Tests are contained in the test_files directory. Each *.js or *.ts has a compiled *.golden.js which can be generated via npm run update-goldens, and contains the expected generated output.

The test files included in this change are a subset of the tests in the prototype PR which pass with this change.

Risk

There is minimal risk to merging this PR if GitHub actions succeed. Risk is reduced because lit-labs/compiler is a private package and not published to NPM yet.

Thank you

Note: This implementation has intentionally been simplified to make
reviewing easier. Attribute part handling, uncompiled files, and many
other subtleties have been skipped but will be added in followup.
@changeset-bot
Copy link

changeset-bot bot commented Jul 26, 2023

🦋 Changeset detected

Latest commit: 2c328f5

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 26, 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

Copy link
Collaborator

@rictic rictic left a comment

Choose a reason for hiding this comment

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

Great work, this is looking really good!

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! Just a couple minor notes.

@AndrewJakubowicz
Copy link
Contributor Author

Thank you!

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.

4 participants