Unverified Commit 6988a2e0 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Use builtins for React transform (#10207)

* Disable core-js on Next.js core files as it's not transforming anything important

* Move babel options to taskr plugin

* Disable transform-runtime for pages dir

* Disable correctly

* Disable corejs for core files

* Temporarily check if this fixes the error

* Use builtIns and exclude async-to-generator

* Update index.test.js
parent 4a2236da
...@@ -138,7 +138,7 @@ export function makePublicRouterInstance(router: Router): NextRouter { ...@@ -138,7 +138,7 @@ export function makePublicRouterInstance(router: Router): NextRouter {
for (const property of urlPropertyFields) { for (const property of urlPropertyFields) {
if (typeof _router[property] === 'object') { if (typeof _router[property] === 'object') {
instance[property] = { ..._router[property] } // makes sure query is not stateful instance[property] = Object.assign({}, _router[property]) // makes sure query is not stateful
continue continue
} }
......
...@@ -15,10 +15,15 @@ const babelClientOpts = { ...@@ -15,10 +15,15 @@ const babelClientOpts = {
esmodules: true, esmodules: true,
}, },
loose: true, loose: true,
exclude: ['transform-typeof-symbol'], // This is handled by the Next.js webpack config that will run next/babel over the same code.
exclude: [
'transform-typeof-symbol',
'transform-async-to-generator',
'transform-spread',
],
}, },
], ],
'@babel/preset-react', ['@babel/preset-react', { useBuiltIns: true }],
], ],
plugins: [ plugins: [
// workaround for @taskr/esnext bug replacing `-import` with `-require(` // workaround for @taskr/esnext bug replacing `-import` with `-require(`
...@@ -31,7 +36,7 @@ const babelClientOpts = { ...@@ -31,7 +36,7 @@ const babelClientOpts = {
const babelServerOpts = { const babelServerOpts = {
presets: [ presets: [
'@babel/preset-typescript', '@babel/preset-typescript',
'@babel/preset-react', ['@babel/preset-react', { useBuiltIns: true }],
[ [
'@babel/preset-env', '@babel/preset-env',
{ {
......
...@@ -81,7 +81,7 @@ describe('Production response size', () => { ...@@ -81,7 +81,7 @@ describe('Production response size', () => {
) )
// These numbers are without gzip compression! // These numbers are without gzip compression!
const delta = responseSizeKilobytes - 235 const delta = responseSizeKilobytes - 233
expect(delta).toBeLessThanOrEqual(0) // don't increase size expect(delta).toBeLessThanOrEqual(0) // don't increase size
expect(delta).toBeGreaterThanOrEqual(-1) // don't decrease size without updating target expect(delta).toBeGreaterThanOrEqual(-1) // don't decrease size without updating target
}) })
...@@ -101,7 +101,7 @@ describe('Production response size', () => { ...@@ -101,7 +101,7 @@ describe('Production response size', () => {
) )
// These numbers are without gzip compression! // These numbers are without gzip compression!
const delta = responseSizeKilobytes - 203 const delta = responseSizeKilobytes - 202
expect(delta).toBeLessThanOrEqual(0) // don't increase size expect(delta).toBeLessThanOrEqual(0) // don't increase size
expect(delta).toBeGreaterThanOrEqual(-1) // don't decrease size without updating target expect(delta).toBeGreaterThanOrEqual(-1) // don't decrease size without updating target
}) })
......
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