Minifier breaks library
See original GitHub issueI just came a cross an interesting problem when deploying an Angular SSR application where I kept getting this error:
Uncaught (in promise) TypeError: StaticInjectorError[InjectionToken Application Initializer -> InjectionToken DocumentToken]:
StaticInjectorError(Platform: core)[InjectionToken Application Initializer -> InjectionToken DocumentToken]:
Right-hand side of 'instanceof' is not an object
at _t (VM10 worker.js:73658)
at yt (VM10 worker.js:73649)
at ir (VM10 worker.js:75978)
at ze.insertToken (VM10 worker.js:73618)
at VM10 worker.js:73777
at Ot (VM10 worker.js:73778)
at Ke (VM10 worker.js:73504)
at Object.parse (VM10 worker.js:73454)
at Object.t.createDocument (VM10 worker.js:63806)
at Object.t.createWindow (VM10 worker.js:63830)
After a lot of digging it turned out that some parent instanceof impl.HTMLTemplateElement
failed because impl.HTMLTemplateElement
was undefined.
After some more digging I found that elements are defined like this:
ctor: function HTMLTemplateElement(doc, localName, prefix) {
HTMLElement.call(this, doc, localName, prefix);
this._contentFragment = doc._templateDoc.createDocumentFragment();
},
The name of the function is used for the key in the elements
object.
Unfortunately some minifiers remove those names to further decrease size, so the name cannot be used anymore by the library and it breaks completely. I’ve found that Mozilla even warns about exactly that problem.
I suggest to pass the name as a regular string rather than using the function’s name for sake of reliability 😃
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:5
Top Results From Across the Web
JS library breaks when minified - support - HUGO
I am trying to use Hugo's asset pipeline to minify (unminified) list.js , but turns out that it is breaking the library(code, artifacts...
Read more >Minification breaks certain libraries · Issue #9711 - GitHub
We're using a library in our Android RN app. It works fine in dev, but breaks once minified. Is there a way to...
Read more >Minified Javascript doesn't work when combined in one file
I have 3 JS libraries that I use that are in their own separate files. They are commented with the code minified in...
Read more >Minify CSS breaks the whole site - WordPress.org
Im trying to speed up my website with LiteSpeed Cache plugin and when trying to minify the css file, my whole site breask,...
Read more >Adding assets (CSS, JS) to a Drupal module via *.libraries.yml
Asset libraries can contain one or more CSS assets, one or more JS assets and ... minified will indicate to the compiler that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As the project seems to be sleeping at the moment, I published a build with this fix on npm https://www.npmjs.com/package/domino-ext. But I would like to see it applied here on the original.
I’m waiting for #151 to be cleaned up so it is possible to apply it. Generally speaking, a broken minifier is not a bug in domino.