Polyfill Object.assign by Default (#9369)

* Polyfill `Object.assign` by Default

* fix formatting
This commit is contained in:
Joe Haddad 2019-11-10 20:48:11 -08:00 committed by GitHub
parent 6bf87b356d
commit 7bb7d70650
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 38 additions and 0 deletions

View file

@ -0,0 +1,3 @@
var assign = Object.assign.bind(Object)
module.exports = assign
module.exports.default = module.exports

View file

@ -0,0 +1 @@
// noop

View file

@ -0,0 +1 @@
module.exports = Object.assign

View file

@ -0,0 +1,10 @@
var assign = Object.assign.bind(Object)
function g() {
return assign
}
Object.defineProperties(g(), {
implementation: { get: g },
shim: { value: g },
getPolyfill: { value: g },
})
module.exports = g()

View file

@ -0,0 +1,3 @@
module.exports = function() {
return Object.assign
}

View file

@ -0,0 +1,3 @@
module.exports = function() {
return Object.assign
}

View file

@ -60,11 +60,27 @@ function getOptimizedAliases(isServer: boolean): { [pkg: string]: string } {
}
const stubWindowFetch = path.join(__dirname, 'polyfills', 'fetch.js')
const stubObjectAssign = path.join(__dirname, 'polyfills', 'object-assign.js')
const shimAssign = path.join(__dirname, 'polyfills', 'object.assign')
return {
// Polyfill: Window#fetch
__next_polyfill__fetch: require.resolve('whatwg-fetch'),
unfetch$: stubWindowFetch,
'isomorphic-unfetch$': stubWindowFetch,
'whatwg-fetch$': stubWindowFetch,
// Polyfill: Object.assign
__next_polyfill__object_assign: require.resolve('object-assign'),
'object-assign$': stubObjectAssign,
'@babel/runtime-corejs2/core-js/object/assign': stubObjectAssign,
// Stub Package: object.assign
'object.assign/auto': path.join(shimAssign, 'auto.js'),
'object.assign/implementation': path.join(shimAssign, 'implementation.js'),
'object.assign$': path.join(shimAssign, 'index.js'),
'object.assign/polyfill': path.join(shimAssign, 'polyfill.js'),
'object.assign/shim': path.join(shimAssign, 'shim.js'),
}
}

View file

@ -1 +1,2 @@
import '__next_polyfill__fetch'
Object.assign = require('__next_polyfill__object_assign')