sidewayss / html-elements

Autonomous custom HTML elements with external template files
MIT License
0 stars 0 forks source link

transpiled version: #private to _public for backwards compatibility #9

Closed sidewayss closed 2 weeks ago

sidewayss commented 1 month ago

For this repo it's a straight text substitution: # to _ for all of the private properties and methods. There are no overlapping names.

I have yet to find a clean automated way to do this. Babel does the "accurate" thing and converts private properties to weak maps, but I don't need that here. The public properties perform better and use less code.

The regex for finding # but not when prefixed by & or any kind of quotation mark is (?<!['`"&])[#]. In addition to that I need all the declarations (re)moved, but I can rely on Babel for that.

sidewayss commented 2 weeks ago

I created babel-plugin-private-to-public to solve this, and it's working so far.