未验证 提交 7bb7d706 编写于 作者: J Joe Haddad 提交者: GitHub

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

* Polyfill `Object.assign` by Default

* fix formatting
上级 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 } {
}
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'),
}
}
......
import '__next_polyfill__fetch'
Object.assign = require('__next_polyfill__object_assign')
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册