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

ie11 support #115

Closed
brandynbennett opened this issue Feb 7, 2019 · 14 comments
Closed

ie11 support #115

brandynbennett opened this issue Feb 7, 2019 · 14 comments
Labels

Comments

@brandynbennett
Copy link
Contributor

When trying to use the addon in ie11 our app doesn't load. It looks like index.js is importing microstates/dist/microstates.cjs which isn't transpiled.

@knownasilya
Copy link
Collaborator

knownasilya commented Feb 7, 2019

I think everything should go through babel, so if your config/targets.js includes ie11 then this should be transpiled too. I think..

The default targets only include ie11 in CI and production builds

@brandynbennett
Copy link
Contributor Author

We have ie11 in our targets, but es6+ syntax is showing up in our vendor.js from microstates.

@brandynbennett
Copy link
Contributor Author

brandynbennett commented Feb 7, 2019

May be along a similar vein as embroider-build/ember-auto-import#41

@brandynbennett
Copy link
Contributor Author

I tried adding an ember-auto-import config to point microstates to the microstates.es.js file instead. This fixes our app, but then one of the addon tests breaks:

allows to create a Microstate<Person> using (type "person")
throws an error: TypeError: Class constructor Person cannot be invoked without 'new'

@brandynbennett
Copy link
Contributor Author

Ok seems like this is because the test/dummy app are using es6+ code and the microstates.js library is now using es5 code so microstates is trying to instantiate a class without new because that's how you'd do it in es5 land.

@brandynbennett
Copy link
Contributor Author

Seems related to thefrontside/microstates#136 as well

@brandynbennett
Copy link
Contributor Author

Can't use the UMD version because it only transpiles to Chrome 58 https://github.com/microstates/microstates.js/blob/master/rollup.config.js#L54

@knownasilya
Copy link
Collaborator

@brandynbennett can you comment on thefrontside/microstates#136 to move it back to the top.

@taras
Copy link
Member

taras commented Feb 7, 2019

Yeah, this an irritating part the current situation with transpiration and libraries. Trying to figure this out has been like juggling compromises. I'll comment in
thefrontside/microstates#136 to keep this conversation going.

@taras
Copy link
Member

taras commented Feb 7, 2019

@brandynbennett it looks like there might be a solution in the works for this in ember-auto-import. Once that work is complete we'd need to change this library to use the new API that ember-auto-import would provide.

In the mean time, if this problem is blocking you from using microstates for a production app, then we might need to find a temporary work around. The work around might be to detect the babel target and automatically include a different build.

Let me know if this is blocking you. If it is, I'll prioritize it to introduce a work around ASAP.

@brandynbennett
Copy link
Contributor Author

Thanks @taras. We found a hacky workaround which involved mutating the imported file source in addon/index.js during the npm postinstall hook that got us unblocked. Here it is if it helps others while we wait for ember-auto-import solution

// package.json
scripts: {
  "postinstall": "sed -i'' -e 's|dist/microstates.cjs|dist/microstates.es|g' node_modules/@microstates/ember/addon/index.js"
}

@brandynbennett
Copy link
Contributor Author

brandynbennett commented Feb 7, 2019

@taras I went ahead and made a PR #117 that dynamically picks which build to use based on targets.

@taras
Copy link
Member

taras commented Feb 8, 2019

Released in 0.12.3

Thank you!

@brandynbennett
Copy link
Contributor Author

Thanks so much for the quick release!

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

No branches or pull requests

3 participants