cramforce / splittable

Module bundler with support for code splitting, ES6 & CommonJS modules.
Apache License 2.0
945 stars 34 forks source link

Doesn't work with globals that closure is not aware of #7

Closed matthewp closed 7 years ago

matthewp commented 7 years ago
class MyWidget extends HTMLElement {
  connectedCallback(){
    console.log("hello world");
  }
}

customElements.define('my-widget', MyWidget);

It's fine with the HTMLElement global but not customElements.

index.js:7: WARNING - Cannot access property define of non-object type undefined.
customElements.define('my-widget', MyWidget);
^

0 error(s), 1 warning(s), 97.0% typed

Sorry for all of the bug reports, will stop for now.

matthewp commented 7 years ago

Should note that while there is only a warning above, it rewrites the code to replace customElements.define with customElements.a which doesn't exist on the global. Trying other variants like window.customElements.define and self.customElements.define doesn't help.

cramforce commented 7 years ago

Thanks for the reports!

For now, you can use window['customElements']['define']

matthewp commented 7 years ago

Ok, I promise this is the last one, related to this, https://github.com/cramforce/splittable/issues/8

cramforce commented 7 years ago

Closing as WAI.