Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

efineday is not a function error when using w/ ember-cli-stencil in production builds #95

Open
tomwayson opened this issue May 26, 2020 · 7 comments

Comments

@tomwayson
Copy link
Member

tomwayson commented May 26, 2020

Getting Uncaught (in promise) TypeError: a.efineday is not a function errors when using this w/
ember-cli-stencil (specifically w/ calcite-components), but only in production builds. Example:

https://coronavirus-response-alaska-dhss.hub.arcgis.com/datasets/covid-cases-out-of-state/data?uiVersion=5f51dc80921ca7850742e54353752c7a591cbdd6

image

The issue appears to be that we've added an exception to the regex for customElements.define(), but in a production build this addon is operating on the uglified code, so this statement:

customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1
        /* isElementConstructor */
        ))

is now a.define(c, he(u, r, 1)))

Maybe we can instruct the ember build to run this before uglify? That might cause other errors. (see #95 (comment))

@tomwayson
Copy link
Member Author

A cheesy fix for this could be just to do: customElements.efineday = customElements.define before vendor.js is loaded.

@tomwayson
Copy link
Member Author

Or maybe specifying some uglify options to preserve customElements in the output.

@trescube
Copy link

trescube commented May 27, 2020

Dumb question: what does efineday do?

@tomwayson
Copy link
Member Author

@tomwayson
Copy link
Member Author

I tried disabling ember-cli-uglify but customElements was still getting mangled. I then remembered that ember-auto-import applies babel transforms, so I tried:

      skipBabel: [{
        // needed for ember-esri-loader
        package: '@esri/calcite-components',
        semverRange: '*'
      }],

But that had no effect either.

Then I thought, "oh, it's skipping babel but then getting uglified." So I tried both together. No dice.

At this point I'm not sure what's transforming that file (for reference, this is the file in question, line 2070). It feels like skipBabel didn't get applied.

@tomwayson
Copy link
Member Author

FWIW - adding the following to the index.html files (app and test) before the vendor.js script tag seems to work.

    <script>
      // see: https://github.com/Esri/ember-esri-loader/issues/95#issuecomment-634392591
      customElements.efineday = customElements.define;
    </script>

😞

@tomwayson
Copy link
Member Author

FYI - that does not work in IE, we get a 'customElements' is undefined error:

image

I could check for customElements before executing that line, but I think we'll end up running into the original error later when the someone uses a stencil component.

I think that would need to run after the custom elements polyfill is added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants