Unverified Commit 7bb7d706 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Polyfill `Object.assign` by Default (#9369)

* Polyfill `Object.assign` by Default

* fix formatting
parent 6bf87b35
var assign = Object.assign.bind(Object)
module.exports = assign
module.exports.default = module.exports
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()
module.exports = function() {
return Object.assign
}
module.exports = function() {
return Object.assign
}
...@@ -60,11 +60,27 @@ function getOptimizedAliases(isServer: boolean): { [pkg: string]: string } { ...@@ -60,11 +60,27 @@ function getOptimizedAliases(isServer: boolean): { [pkg: string]: string } {
} }
const stubWindowFetch = path.join(__dirname, 'polyfills', 'fetch.js') 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 { return {
// Polyfill: Window#fetch
__next_polyfill__fetch: require.resolve('whatwg-fetch'), __next_polyfill__fetch: require.resolve('whatwg-fetch'),
unfetch$: stubWindowFetch, unfetch$: stubWindowFetch,
'isomorphic-unfetch$': stubWindowFetch, 'isomorphic-unfetch$': stubWindowFetch,
'whatwg-fetch$': 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'),
} }
} }
......
import '__next_polyfill__fetch' import '__next_polyfill__fetch'
Object.assign = require('__next_polyfill__object_assign')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment