Polyfill Object.assign
by Default (#9369)
* Polyfill `Object.assign` by Default * fix formatting
This commit is contained in:
parent
6bf87b356d
commit
7bb7d70650
8 changed files with 38 additions and 0 deletions
3
packages/next/build/polyfills/object-assign.js
Normal file
3
packages/next/build/polyfills/object-assign.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
var assign = Object.assign.bind(Object)
|
||||
module.exports = assign
|
||||
module.exports.default = module.exports
|
1
packages/next/build/polyfills/object.assign/auto.js
Normal file
1
packages/next/build/polyfills/object.assign/auto.js
Normal file
|
@ -0,0 +1 @@
|
|||
// noop
|
|
@ -0,0 +1 @@
|
|||
module.exports = Object.assign
|
10
packages/next/build/polyfills/object.assign/index.js
Normal file
10
packages/next/build/polyfills/object.assign/index.js
Normal 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()
|
3
packages/next/build/polyfills/object.assign/polyfill.js
Normal file
3
packages/next/build/polyfills/object.assign/polyfill.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
module.exports = function() {
|
||||
return Object.assign
|
||||
}
|
3
packages/next/build/polyfills/object.assign/shim.js
Normal file
3
packages/next/build/polyfills/object.assign/shim.js
Normal file
|
@ -0,0 +1,3 @@
|
|||
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'),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
import '__next_polyfill__fetch'
|
||||
Object.assign = require('__next_polyfill__object_assign')
|
||||
|
|
Loading…
Reference in a new issue