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
Revert "feat(build): Transpile assuming higher version of runtime" #10233
Conversation
)" This reverts commit 6b87b2b.
Stats from current PRDefault Server Mode (Decrease detected ✓)General Overall decrease ✓
Client Bundles (main, webpack, commons)
Client Bundles (main, webpack, commons) Modern
Legacy Client Bundles (polyfills)
Client Pages
Client Pages Modern
Client Build Manifests
Rendered Page Sizes
Serverless Mode (Decrease detected ✓)General Overall decrease ✓
Client Bundles (main, webpack, commons)
Client Bundles (main, webpack, commons) Modern
Legacy Client Bundles (polyfills)
Client Pages
Client Pages Modern
Client Build Manifests
Serverless bundles
Commit: 94ee7b4 |
Stats from current PRDefault Server Mode (Decrease detected ✓)General Overall decrease ✓
Client Bundles (main, webpack, commons)
Client Bundles (main, webpack, commons) Modern
Legacy Client Bundles (polyfills)
Client Pages
Client Pages Modern
Client Build Manifests
Rendered Page Sizes
Serverless Mode (Decrease detected ✓)General Overall decrease ✓
Client Bundles (main, webpack, commons)
Client Bundles (main, webpack, commons) Modern
Legacy Client Bundles (polyfills)
Client Pages
Client Pages Modern
Client Build Manifests
Serverless bundles
Commit: c7e0b90 |
|
Transform runtime will only attempt to polyfill Since the default is below the above tested range, they're never polyfilled even if used:
This is referring specifically to the above behavior, that Next.js wouldn't polyfill the Read on: Unfortunately, transform runtime is a very ineffective/inefficient means of polyfilling. We're in process of eliminating this transform entirely, and enabling Math would increase the global polyfills we'd need to ship by default. We'll (maybe) polyfill Math eventually, but using a custom Babel plugin, along these lines: // Incomplete
export default ({ types: t }) => {
function getName(path) {
path = path.resolve();
if (t.isMemberExpression(path)) {
return getName(path.get('object')) +'.'+ getName(path.get('property'));
}
return t.isIdentifier(path) && path.node.name;
}
return {
visitor: {
'MemberExpression|Identifier'(path) {
const name = getName(path);
const m = name.match(/^(?:(?:window|top|self)\.)*Math\.(\w+)$/);
if (!m) return;
const ident = path.scope.generateUidIdentifier(m[1]);
// todo: import helper lib
path.replaceWith(ident);
}
}
};
}; Also, the reasons for adding this property were argued to be a "observable size reduction". However, this is never observed. See the diff bot shows absolutely zero difference in output with this option applied: |
Reverts #9511
This removes the polyfillying of the
Math
object.This has never been polyfilled previously, nor in a stable.