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

Adopt object spread and polyfill Object.assign #8283

Open
mourner opened this issue May 24, 2019 · 4 comments
Open

Adopt object spread and polyfill Object.assign #8283

mourner opened this issue May 24, 2019 · 4 comments

Comments

@mourner
Copy link
Member

mourner commented May 24, 2019

Currently we use a custom extend utility function because Object.assign isn't supported in IE11.

However, if we polyfilled Object.assign in IE, we could switch to object spread ({...obj}) syntax across the code base, which provides many benefits:

  • An easier to read, more concise syntax.
  • When we ditch IE11 support in future and start providing an untranspiled build, we'll get better performance for free because native spreads are faster than Object.assign.
  • Strictly typing extend and all code that uses it in Flow is really hard, which I discovered while working on Start adopting Flow strict mode #8281. It's much easier with spreads because it syntactically indicates the full shape of an object from the start — no type conversions/refinements need to happen to transform an object through multiple extensions.
@asheemmamoowala
Copy link
Contributor

Isn't this already done automatically in our rollup configuration at :

buble({transforms: {dangerousForOf: true}, objectAssign: "Object.assign"}),

@mourner
Copy link
Member Author

mourner commented May 29, 2019

@asheemmamoowala what this does is tell Buble to transpile object spreads to Object.assign calls. But this will break IE11 because it doesn't have Object.assign. To make this work, we need to include a polyfill in the bundle.

@karimnaaji karimnaaji mentioned this issue Dec 8, 2020
@karimnaaji
Copy link
Contributor

Addressed as part of the IE11 deprecation in v2.

@ryanhamley
Copy link
Contributor

ryanhamley commented Jan 26, 2022

The issue here is no longer IE11 since GL JS no longer supports it, but some build systems fail when encountering the Object spread notation. See #11266 for an example. We probably don't need to polyfill Object.assign either.

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