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

2.1.0 breaks IE11 #358

Open
davidspiess opened this issue Apr 6, 2020 · 7 comments
Open

2.1.0 breaks IE11 #358

davidspiess opened this issue Apr 6, 2020 · 7 comments

Comments

@davidspiess
Copy link

davidspiess commented Apr 6, 2020

After upgrading to 2.1.0 from 2.0.4 IE11 throws:
"Const must be initialized error"

I think the main culprit is the free-style dependency which uses const in for loops.

https://github.com/blakeembrey/free-style/blob/master/src/index.ts#L257

@davidspiess
Copy link
Author

Free-style ticket for reference: blakeembrey/free-style#82

@davidspiess
Copy link
Author

davidspiess commented Apr 8, 2020

The author from free-style was very kind to release an ES5 compatible build https://github.com/blakeembrey/free-style/releases/tag/v3.2.2
Would it be possible to update typestyle with this version?

@basarat
Copy link
Contributor

basarat commented Apr 22, 2020

Sorry for the late reply. The following will need to be done:

  • update FreeStyle - straightforward
  • there will need to be an additional build created for es5 (there are already two builds Commonjs + ESModule) - straightforward
  • Create code mod that takes the current src and modifies each import from 'free-style' to be from 'free-style/dist.es5' - will require some thought / time

PR would be appreciated 🌹

@teramotodaiki
Copy link

I found a workaround with Webpack. If you want to solve it right now, please refer to it.

  • Upgrade free-style up to v3.2.2. e.g. npm install --save free-style@latest
  • Add resolve.alias field to webpack.config.js.
resolve: {
  alias: {
    'free-style': 'free-style/dist.es5/index.js' // avoid es2015 build
  }
}

@teramotodaiki
Copy link

I'm sorry but above workaround may occur another bug. In my case, typestyle's style() with media() generate same hash even different media queries.

Here is a easy workaround for this bug.

import { style, media } from 'typestyle';

const classA = style(media({ minWidth: 600 }, { display: 'none' }));
const classB = style(media({ maxWidth: 601 }, { display: 'none' })); // === classA
const classC = style(media({ maxWidth: 601 }, { display: 'none', opacity: 100 })); // !== classA

@craigkovatch
Copy link

@basarat would you be opposed to a fix where typestyle just chooses to both consume the es5-compatible free-style artifact and target es5 itself? Seems like that would be easiest for all scenarios until IE11 finishes dying off.

@craigkovatch
Copy link

@basarat friendly reminder a year later :) ^

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

No branches or pull requests

4 participants