Skip to content
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

feat: optional chaining and nullish coalescing #9615

Merged
merged 1 commit into from
Dec 8, 2019
Merged

feat: optional chaining and nullish coalescing #9615

merged 1 commit into from
Dec 8, 2019

Conversation

mrsvt
Copy link
Contributor

@mrsvt mrsvt commented Dec 4, 2019

Resolves #9381

Copy link
Member

@lfades lfades left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you @sayuti-daniel 💯

@timneutkens Are tests required for this change?

@ijjk
Copy link
Member

ijjk commented Dec 4, 2019

Stats from current PR

Default Server Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary sayuti-daniel/next.js canary Change
buildDuration 13.9s 14.2s ⚠️ +245ms
nodeModulesSize 45.5 MB 45.5 MB ⚠️ +16.5 kB
Client Bundles (main, webpack, commons)
zeit/next.js canary sayuti-daniel/next.js canary Change
main-HASH.js 18.2 kB 18.2 kB
main-HASH.js gzip 6.42 kB 6.42 kB
webpack-HASH.js 1.53 kB 1.53 kB
webpack-HASH.js gzip 746 B 746 B
16b1a7225520..10012f496.js 20 kB 20 kB
16b1a7225520..f496.js gzip 7.42 kB 7.42 kB
4952ddcd88e7..49d7903c2.js 9.61 kB 9.61 kB
4952ddcd88e7..03c2.js gzip 3.77 kB 3.77 kB
commons.HASH.js 10.4 kB 10.4 kB
commons.HASH.js gzip 3.91 kB 3.91 kB
de003c3a9d30..a5a0ede39.js 21.2 kB 21.2 kB
de003c3a9d30..de39.js gzip 8.19 kB 8.19 kB
framework.HASH.js 126 kB 126 kB
framework.HASH.js gzip 39.5 kB 39.5 kB
Overall change 207 kB 207 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary sayuti-daniel/next.js canary Change
main-HASH.module.js 14.2 kB 14.2 kB
main-HASH.module.js gzip 5.36 kB 5.36 kB
webpack-HASH.module.js 1.53 kB 1.53 kB
webpack-HASH..dule.js gzip 746 B 746 B
16b1a7225520..e5.module.js 21.2 kB 21.2 kB
16b1a7225520..dule.js gzip 8.18 kB 8.18 kB
4952ddcd88e7..cc.module.js 11.9 kB 11.9 kB
4952ddcd88e7..dule.js gzip 4.42 kB 4.42 kB
de003c3a9d30..80.module.js 15 kB 15 kB
de003c3a9d30..dule.js gzip 6.15 kB 6.15 kB
framework.HASH.module.js 126 kB 126 kB
framework.HA..dule.js gzip 39.4 kB 39.4 kB
Overall change 189 kB 189 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary sayuti-daniel/next.js canary Change
polyfills-HASH.js 15.3 kB 15.3 kB
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 15.3 kB 15.3 kB
Client Pages
zeit/next.js canary sayuti-daniel/next.js canary Change
_app.js 2.93 kB 2.93 kB
_app.js gzip 1.33 kB 1.33 kB
_error.js 13.2 kB 13.2 kB
_error.js gzip 5.11 kB 5.11 kB
hooks.js 1.92 kB 1.92 kB
hooks.js gzip 943 B 943 B
index.js 318 B 318 B
index.js gzip 222 B 222 B
link.js 6.78 kB 6.78 kB
link.js gzip 2.89 kB 2.89 kB
routerDirect.js 413 B 413 B
routerDirect.js gzip 285 B 285 B
withRouter.js 423 B 423 B
withRouter.js gzip 284 B 284 B
Overall change 26 kB 26 kB
Client Pages Modern
zeit/next.js canary sayuti-daniel/next.js canary Change
_app.module.js 1.53 kB 1.53 kB
_app.module.js gzip 745 B 745 B
_error.module.js 10.3 kB 10.3 kB
_error.module.js gzip 4.24 kB 4.24 kB
hooks.module.js 651 B 651 B
hooks.module.js gzip 371 B 371 B
index.module.js 276 B 276 B
index.module.js gzip 212 B 212 B
link.module.js 5.45 kB 5.45 kB
link.module.js gzip 2.46 kB 2.46 kB
routerDirect.module.js 386 B 386 B
routerDirect..dule.js gzip 275 B 275 B
withRouter.module.js 396 B 396 B
withRouter.m..dule.js gzip 274 B 274 B
Overall change 19 kB 19 kB
Client Build Manifests
zeit/next.js canary sayuti-daniel/next.js canary Change
_buildManifest.js 244 B 244 B
_buildManifest.js gzip 200 B 200 B
_buildManifest.module.js 251 B 251 B
_buildManife..dule.js gzip 209 B 209 B
Overall change 495 B 495 B
Rendered Page Sizes
zeit/next.js canary sayuti-daniel/next.js canary Change
index.html 4.06 kB 4.06 kB
index.html gzip 1.04 kB 1.04 kB
link.html 4.58 kB 4.58 kB
link.html gzip 1.11 kB 1.11 kB
withRouter.html 4.59 kB 4.59 kB
withRouter.html gzip 1.1 kB 1.1 kB
Overall change 13.2 kB 13.2 kB

Serverless Mode (Increase detected ⚠️)
General Overall increase ⚠️
zeit/next.js canary sayuti-daniel/next.js canary Change
buildDuration 14.2s 14.3s ⚠️ +76ms
nodeModulesSize 45.5 MB 45.5 MB ⚠️ +16.5 kB
Client Bundles (main, webpack, commons)
zeit/next.js canary sayuti-daniel/next.js canary Change
main-HASH.js 18.2 kB 18.2 kB
main-HASH.js gzip 6.42 kB 6.42 kB
webpack-HASH.js 1.53 kB 1.53 kB
webpack-HASH.js gzip 746 B 746 B
16b1a7225520..10012f496.js 20 kB 20 kB
16b1a7225520..f496.js gzip 7.42 kB 7.42 kB
4952ddcd88e7..49d7903c2.js 9.61 kB 9.61 kB
4952ddcd88e7..03c2.js gzip 3.77 kB 3.77 kB
commons.HASH.js 10.4 kB 10.4 kB
commons.HASH.js gzip 3.91 kB 3.91 kB
de003c3a9d30..a5a0ede39.js 21.2 kB 21.2 kB
de003c3a9d30..de39.js gzip 8.19 kB 8.19 kB
framework.HASH.js 126 kB 126 kB
framework.HASH.js gzip 39.5 kB 39.5 kB
Overall change 207 kB 207 kB
Client Bundles (main, webpack, commons) Modern
zeit/next.js canary sayuti-daniel/next.js canary Change
main-HASH.module.js 14.2 kB 14.2 kB
main-HASH.module.js gzip 5.36 kB 5.36 kB
webpack-HASH.module.js 1.53 kB 1.53 kB
webpack-HASH..dule.js gzip 746 B 746 B
16b1a7225520..e5.module.js 21.2 kB 21.2 kB
16b1a7225520..dule.js gzip 8.18 kB 8.18 kB
4952ddcd88e7..cc.module.js 11.9 kB 11.9 kB
4952ddcd88e7..dule.js gzip 4.42 kB 4.42 kB
de003c3a9d30..80.module.js 15 kB 15 kB
de003c3a9d30..dule.js gzip 6.15 kB 6.15 kB
framework.HASH.module.js 126 kB 126 kB
framework.HA..dule.js gzip 39.4 kB 39.4 kB
Overall change 189 kB 189 kB
Legacy Client Bundles (polyfills)
zeit/next.js canary sayuti-daniel/next.js canary Change
polyfills-HASH.js 15.3 kB 15.3 kB
polyfills-HASH.js gzip 4.76 kB 4.76 kB
Overall change 15.3 kB 15.3 kB
Client Pages
zeit/next.js canary sayuti-daniel/next.js canary Change
_app.js 2.93 kB 2.93 kB
_app.js gzip 1.33 kB 1.33 kB
_error.js 13.2 kB 13.2 kB
_error.js gzip 5.11 kB 5.11 kB
hooks.js 1.92 kB 1.92 kB
hooks.js gzip 943 B 943 B
index.js 318 B 318 B
index.js gzip 222 B 222 B
link.js 6.78 kB 6.78 kB
link.js gzip 2.89 kB 2.89 kB
routerDirect.js 413 B 413 B
routerDirect.js gzip 285 B 285 B
withRouter.js 423 B 423 B
withRouter.js gzip 284 B 284 B
Overall change 26 kB 26 kB
Client Pages Modern
zeit/next.js canary sayuti-daniel/next.js canary Change
_app.module.js 1.53 kB 1.53 kB
_app.module.js gzip 745 B 745 B
_error.module.js 10.3 kB 10.3 kB
_error.module.js gzip 4.24 kB 4.24 kB
hooks.module.js 651 B 651 B
hooks.module.js gzip 371 B 371 B
index.module.js 276 B 276 B
index.module.js gzip 212 B 212 B
link.module.js 5.45 kB 5.45 kB
link.module.js gzip 2.46 kB 2.46 kB
routerDirect.module.js 386 B 386 B
routerDirect..dule.js gzip 275 B 275 B
withRouter.module.js 396 B 396 B
withRouter.m..dule.js gzip 274 B 274 B
Overall change 19 kB 19 kB
Client Build Manifests
zeit/next.js canary sayuti-daniel/next.js canary Change
_buildManifest.js 244 B 244 B
_buildManifest.js gzip 200 B 200 B
_buildManifest.module.js 251 B 251 B
_buildManife..dule.js gzip 209 B 209 B
Overall change 495 B 495 B
Serverless bundles
zeit/next.js canary sayuti-daniel/next.js canary Change
_error.js 256 kB 256 kB
_error.js gzip 67.9 kB 67.9 kB
hooks.html 4.19 kB 4.19 kB
hooks.html gzip 1.07 kB 1.07 kB
index.js 256 kB 256 kB
index.js gzip 68 kB 68 kB
link.js 289 kB 289 kB
link.js gzip 77.2 kB 77.2 kB
routerDirect.js 282 kB 282 kB
routerDirect.js gzip 75.2 kB 75.2 kB
withRouter.js 282 kB 282 kB
withRouter.js gzip 75.3 kB 75.3 kB
Overall change 1.37 MB 1.37 MB

Commit: 7c943c7

@@ -176,6 +176,8 @@ module.exports = (
removeImport: true,
},
],
require('@babel/plugin-proposal-optional-chaining'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong as it'll add the plugins for all files instead of just for typescript. You'll want to use overrides, similarly to @babel/preset-typescript https://github.com/babel/babel/blob/master/packages/babel-preset-typescript/src/index.js#L43-L56

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can use this in JS too, am I wrong?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great to use this in JS too, CRA released for both: https://github.com/facebook/create-react-app/releases/tag/v3.3.0. PR: facebook/create-react-app#7438

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not planning on supporting JS syntax features which are not stage 4, as they're prone to change. TypeScript is different as they've already shipped it unflagged in a stable release.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, thanks for the explanation @Timer 😊

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, but TypeScript allows us to write future JS. For example class properties, I believe it's in stage 3, but TS has support of it. As you said, this syntaxes are shipped unflagged in a stable release. So yeah, I think we could consider to add support of this syntaxes for JS too. What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not add for JS -- it's not future/real syntax yet. I'll likely go stage 4, at which point we can turn on for JS.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just read this https://twitter.com/drosenwasser/status/1202310742436761600?s=19 does this mean we can add it for JS too?

Copy link
Member

@timneutkens timneutkens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As commented it needs a small update, great work though 💯

@timneutkens
Copy link
Member

@timneutkens Are tests required for this change?

Yes definitely 💯

@timneutkens timneutkens merged commit 26a6a37 into vercel:canary Dec 8, 2019
@timneutkens
Copy link
Member

This needs tests though so that we don't break it in the future.

@ScreamZ
Copy link

ScreamZ commented Dec 8, 2019

Guys, in which release is that patch delivered ? Any ideas ? :) Thanks

@jamesmosier
Copy link
Contributor

@ScreamZ current prelease patch with this is v9.1.5-canary.16

@vercel vercel locked as resolved and limited conversation to collaborators Jan 31, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support TS 3.7's new features: Optional chaining and nullish coalescing operator
9 participants