[labs/router] Compression mangling error
See original GitHub issueDescription
There is a bug in the way package @lib-labs/router
is bundled, specifically in the way files are being mangled during compression.
In production mode (the default export resolution per package.json), the bundled code at runtime is not equivalent (and incorrect in this case) to its original.
Cause
The cause (intuitively) seems to be that the mangling during compression is done on a per-file basis:
// Routes.js defines t, which represents _childRoutes) as an empty array.
class Routes {
this.t = []; // this._childRoutes = [];
...
}
// Router.js redefines t as the onclick overriding incorrectly the inherited field
class Router extends Routes {
this.t=t=>{...} // this was this._onClick = (e) => {
...
}
Since Router extends Routes
the code is no longer equivalent after compression.
Conclusion
Without looking at the specific processor used to compress the files (wireit
I believe), seems that doing this process by file will create in this (and many other cases) unintended mangling overrides due to the lack of dependencies context.
Unwanted observation:
IMHO I found it odd that the package is being shipped “pre-compressed” as the default, since I believe that should be the responsibility of the consumer, but that’s up to the team to decide the rationale to do so 😃
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Thanks for the quick turnaround! Really appreciate the good work 🙏
Oh I know what @justinfagnani will say, just wanted to poke the bear a little 😹
Fixed in https://github.com/lit/lit/releases/tag/%40lit-labs%2Frouter%400.1.1