BrightspaceUI / core

A collection of accessible, free, open-source web components for building Brightspace applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

dlockhart opened this issue · comments

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