Skip to content

Fully support Closure compiler including ADVANCED_OPTIMIZATIONS - #307

Merged
sorvell merged 1 commit into
lit:closure-advancedfrom
rickcnagy:master
Dec 14, 2018
Merged

sorvell merged 1 commit into
lit:closure-advancedfrom
rickcnagy:master

Conversation

@rickcnagy

Copy link
Copy Markdown

Currently, compiling lit-element with the Closure compiler results in a
clean build but a number of hard JS errors due to a few issues:

  • static methods being collapsed (i.e. removed entirely)
  • Object.hasOwnPropertyName() looking for static properties that have
    been rewritten by the compiler
  • static property initializers not being run when @exported

The last issue is a compiler bug being tracked internally, but all three
need to be worked around before this will compile and run cleanly.

This includes all of the necessary fixes, including addressing the last
issue by moving the Object.hasOwnPropertyName('_classProperties') check
to _finalize(). This is necessary to ensure that _classProperties is
defined before it's iterated in observedProperties on an element that
has no properties.

Another option for making _finalized and _classProperties public would
be to move to checking this._finalized and this._classProperties and not
needing to access them by name - I thought that was out of scope for
this but would be happy to change to that style if reviewers prefer.

Currently, compiling lit-element with the Closure compiler results in a
clean build but a number of hard JS errors due to a few issues:
- static methods being collapsed (i.e. removed entirely)
- Object.hasOwnPropertyName() looking for static properties that have
been rewritten by the compiler
- static property initializers not being run when @exported

The last issue is a compiler bug being tracked internally, but all three
need to be worked around before this will compile and run cleanly.

This includes all of the necessary fixes, including addressing the last
issue by moving the Object.hasOwnPropertyName('_classProperties') check
to _finalize(). This is necessary to ensure that _classProperties is
defined before it's iterated in observedProperties on an element that
has no properties.

Another option for making _finalized and _classProperties public would
be to move to checking this._finalized and this._classProperties and not
needing to access them by name - I thought that was out of scope for
this but would be happy to change to that style if reviewers prefer.
@rictic

rictic commented Nov 16, 2018

Copy link
Copy Markdown
Contributor

The most surprising change is the static property initializers. Apparently static fields don't consistently inherit after optimization in closure compiler

@sorvell
sorvell changed the base branch from master to closure-advanced December 14, 2018 22:57
@sorvell

sorvell commented Dec 14, 2018

Copy link
Copy Markdown
Member

We're going to need to slightly change the way _classProperties is done to ensure that decorators work correctly. This is a little tricky to explain in review, so going to merge this to a branch and make the changes from there.

@sorvell
sorvell merged commit cded396 into lit:closure-advanced Dec 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants