Skip to content

Commit

Permalink
Use builtins for React transform (#10207)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
timneutkens committed Jan 22, 2020
1 parent 4a2236d commit 6988a2e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/next/client/router.ts
Expand Up @@ -138,7 +138,7 @@ export function makePublicRouterInstance(router: Router): NextRouter {

for (const property of urlPropertyFields) {
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
}

Expand Down
11 changes: 8 additions & 3 deletions packages/next/taskfile-babel.js
Expand Up @@ -15,10 +15,15 @@ const babelClientOpts = {
esmodules: 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: [
// workaround for @taskr/esnext bug replacing `-import` with `-require(`
Expand All @@ -31,7 +36,7 @@ const babelClientOpts = {
const babelServerOpts = {
presets: [
'@babel/preset-typescript',
'@babel/preset-react',
['@babel/preset-react', { useBuiltIns: true }],
[
'@babel/preset-env',
{
Expand Down
4 changes: 2 additions & 2 deletions test/integration/size-limit/test/index.test.js
Expand Up @@ -81,7 +81,7 @@ describe('Production response size', () => {
)

// These numbers are without gzip compression!
const delta = responseSizeKilobytes - 235
const delta = responseSizeKilobytes - 233
expect(delta).toBeLessThanOrEqual(0) // don't increase size
expect(delta).toBeGreaterThanOrEqual(-1) // don't decrease size without updating target
})
Expand All @@ -101,7 +101,7 @@ describe('Production response size', () => {
)

// These numbers are without gzip compression!
const delta = responseSizeKilobytes - 203
const delta = responseSizeKilobytes - 202
expect(delta).toBeLessThanOrEqual(0) // don't increase size
expect(delta).toBeGreaterThanOrEqual(-1) // don't decrease size without updating target
})
Expand Down

0 comments on commit 6988a2e

Please sign in to comment.