question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Minifier breaks library

See original GitHub issue

I 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:open
  • Created 4 years ago
  • Reactions:3
  • Comments:5

github_iconTop GitHub Comments

4reactions
nidi3commented, Nov 18, 2019

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.

0reactions
cscottcommented, Apr 30, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found