Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate transpilation as a pre-publish step to fix optional chaining Polymer issue #1951

Open
dlockhart opened this issue Dec 20, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@dlockhart
Copy link
Member

Currently if we use optional chaining in our JavaScript, projects which will rely on polymer build or polymer test will fail. This is because internally those tools use Babel but they do NOT include any plugins to allow optional chaining.

In general, it's not recommended to transpile published JavaScript, since it could force consumers into supporting older browsers they don't care about, and therefore having your code run less optimally than it otherwise would.

However, due to this issue in Polymer we're essentially transpiling optional chaining code manually (using a ternary operator) and occasionally forget and break something downstream. There's also the likely possibility that optional chaining is just the tip of the iceberg in terms of modern JavaScript features we'd like to use that will break Polymer.

Ideally any transpilation we do would be very narrow -- targeting just the things we need.

Some things to keep in mind:

  • Babel can't transpile in place, so we'd need to move our code into a src directory and transpile to the root
  • That could have a negative impact on the dev experience
  • A tool like Rollup could help with the dev experience, although it may end up being too heavy and optimize other things we don't want it to
  • If we ever move to TypeScript, a compile step will be required anyway
@dlockhart dlockhart added the enhancement New feature or request label Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant