-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Polyfill missing std lib fns for module browsers #17083
Conversation
This comment has been minimized.
This comment has been minimized.
if (!('description' in Symbol.prototype)) { | ||
Object.defineProperty(Symbol.prototype, 'description', { | ||
get: function get() { | ||
return /\((.+)\)/.exec(this)[1] | ||
}, | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you send a PR to fix it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I can open a PR to fix the issue on Edge 44 with a small change
Object.defineProperty(Symbol.prototype, 'description', {
get: function get() {
const result = /\((.+)\)/.exec(this)[1];
return result ? result[1] : undefined;
},
})
However, this still doesn't handle the other issue with Safari 11 (#17825). Core-js es.symbol.description
polyfill seems to be more complete (handling all browser) but I'm not sure if we want to bring all that code into Next.js. I would suggest that we remove this problematic polyfill from Next.js. Whoever needs it can polyfill it manually.
@Timer WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Core-js does not polyfill symbol.description, it polyfills Symbols themselves (in their entirety). This works:
if (!('description' in Symbol.prototype)) {
Object.defineProperty(Symbol.prototype, 'description', {
get: function get() {
return /\((.+)\)/.exec(this.toString())[1]
},
})
}
This pull request creates a new
@next/polyfill-module
that fills in the missing gaps between variousnomodule
browsers.It supports:
String#trimStart
/String#trimEnd
Symbol#description
Array#flat
/Array#flatMap
Promise#finally
(previously polyfilled, now relocated)Fixes #11173