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
IE 11 not supported #1951
Comments
We are running Sinon in IE11 in our own browser tests. IE11 does not support Ecmascript Modules, so it makes no sense to use the sinon-esm build. Just use the Sinon.js bundle. Works everywhere. |
@fatso83 The issue we are hitting with the |
@fatso83 I don't understand, there is always a way to make it work. My point is with the community convention. As far as I have seen this in the wild, library authors are providing esm version of their library so people can leverage tree shaking. It's not about targeting evergreen browsers (ES6+). |
@oliviertassinari, I get that, but if you are consuming an Ecmascript module you shouldn't expect it to be ES5 to begin with (as it's not). You will require some sort of transpilation step in your build pipeline if you build a bundle from ES modules, as this is not valid ES5, but it IS a ES module: I suspect that your webpack config excludes node_modules from undergoing Babel transpilation, so you either need to selectively include Sinon or just import the non-esm bundle instead. Chances are I just had the same issue with the Material UI React lib (what are the chances, Olivier!), so you could employ my fix: https://stackoverflow.com/q/53154986/200987 |
But I do agree that it would be wise to make the most common thing as easy as possible, so if a simple config change can produce a valid ESM that will not cause problems in most builds, we will accept that PR. |
What should I expect it to be, can it have ES2018 syntax?
I would love to know more about it. Right now the target with Material-UI is to have 3 outputs.
Thanks for the link, @eps1lon is letting Babel transpile Sinon to solve the problem on our side. |
I used the module build because it's easier to investigate since everything is in one place. This issue stays the same if I tell webpack to use the The modules used are of no concern for the generated bundle. @fatso83 If I have to transpile node_modules anyway then you can't state that it supports IE 11. That's not how this works. Please consider reopening this or at direct me to a working configuration that uses sinon in IE 11. |
This discussion doesn't seem very fruitful. I'll try to explain the Sinon.JS teams view: To begin with, the statement from our latest API documentation page is what we feel bound to. It sais
The listed runtimes are
Obviously, these statements are made regarding the standard Sinon.JS distribution, as it is downloadable from our web page and distributed via npm. The links provided above show the successful runs of our test suite on IE 11, among other browsers. We provide an ESM bundle for environments where ESM is supported, to make it possible to consume Sinon in these environments. ESM is not supported by IE 11. Now, what you're asking for is to make an ESM version of Sinon for a target environment that doesn't support ESM. This is out of the scope of this project. What @fatso83 was trying to explain is, that if you have a need like this, you're most likely transpiling your code anyway, since IE 11 does not support ESM out of the box. We're therefore asking you to take the regular Sinon build, which does support IE 11, and wrap it in an ESM bundle yourself, just as you're most likely doing it with other resources. We will not re-open this, as it's not an issue with Sinon. I hope you understand. |
@mantoni Please read my comment again and consider that |
@eps1lon @oliviertassinari I am not against the ESM version of Sinon being ESM + ES5.1, if that solves problems for people. Would you care to submit a pull request to scratch your itch? |
Just to be perfectly clear the commonJS version isn't ES5.1 either which should be showcased with https://github.com/eps1lon/sinon-ie11 The issue is that you have a transitive dependency to the $ npm ls has-flag
sinon-ie-11@1.0.0 C:\Development\src\js\sinon-ie-11
`-- sinon@7.1.1
`-- supports-color@5.5.0
`-- has-flag@3.0.0 This is fixable by setting mainFields to I'm going to check if I can fix your esm build with a similar approach but I have to investigate if rollup allows mainFields configuration. Edit: |
The CommonJS version is ES5.1. You can search through the Again, if you're using Sinon in a browser, use the browser package. If you want the browser package within an ESM, you're invited to send a PR to produce a new ESM + ES5.1 bundle for Sinon. The current bundle does not need fixing. It's not broken. |
@mantoni I wish I never mentioned the esm build. It has nothing to do with the issue. It's however troubling that you only consider your code as part of the package and not dependencies. I hope you don't have a similar attitude towards security issues in dependencies. |
We do consider dependencies as part of our library. We also take security very seriously and watch security alerts on the repository and npm audit closely. Let me try again, without using the word esm: I understand that you're loading the Sinon sources into IE 11. You're obviously not loading the browser version, because the browser version does not have the issues you're referring to. You should be loading the browser version if you want to use Sinon in a browser. Currently, only the |
People in this thread might be interested in knowing that @Feiyang1 implemented a fix for this by adding a There should be no additional configuration needed for Webpack/Babel builds after this has shipped. |
Describe the bug
IE 11 environment is not supported with regards to syntax and methods. For example sinon has transitive dependencies to
has-flag
which is an arrow function and usesString.prototype.startsWith
. Missing syntax support wouldn't be as bad since it can be included in babel-loader but adding polyfills is kind of rough since this would also mean that it wouldn't warn us if we usestartsWith
. Maybe there is also an option to only include polyfills for certain node_modules but both points can't really be attributed to IE 11 support.To Reproduce
Steps to reproduce the behavior:
sinon-esm.js
hasFlag
which is an arrow function and usesstartsWith
Expected behavior
Support for IE 11 out of the box.
Screenshots
None
Context (please complete the following information):
We're trying run unit tests for our react components in IE 11.
I guess enzyme will be another bottleneck which requires
airbnb-browser-shims
anyway and I couldn't find a solution to provide polyfills only to certain dependencies.The text was updated successfully, but these errors were encountered: