berry icon indicating copy to clipboard operation
berry copied to clipboard

build: use more explicit node version

Open paul-soporan opened this issue 3 years ago • 4 comments

What's the problem this PR addresses?

When building things, we set the ESBuild target to node14, which requires the output to be compatible with all Node versions >=14.0.0, but we only support Node >=14.15.0.

How did you fix it?

Changed the target to node14.15.0.

This makes ESBuild stop transpiling optional chaining and nullish coalescing, improving the bundle size.

CLI bundle size:

  • Before: 2813589 bytes
  • After: 2808903 bytes
  • Improvement: -4.57 KiB / 0.16%

Checklist

  • [X] I have set the packages that need to be released for my changes to be effective.
  • [X] I will check that all automated PR checks pass before the PR gets reviewed.

paul-soporan avatar Jul 31 '22 15:07 paul-soporan

This makes ESBuild stop transpiling optional chaining and nullish coalescing

It's odd that it transpiled them in the first place since both of them are supported since Node.js 14.0.0. However optional chaining is buggy in Node.js <16.9 so it should be transpiled anyways, which newer versions of ESBuild handle, nullish coalescing is fine though. https://github.com/kangax/compat-table/pull/1708

merceyz avatar Jul 31 '22 15:07 merceyz

:thinking: Indeed, didn't know that. Since searching for ?.(... doesn't yield anything in the codebase I'd just consider this ESBuild bug a feature and avoid updating for now. :sweat_smile:

Or perhaps ESBuild could detect optional function calls followed by the spread operator separately and only transpile those (I'll open a feature request later).

paul-soporan avatar Aug 01 '22 12:08 paul-soporan

Yeah, should be fine.

Or perhaps ESBuild could detect optional function calls followed by the spread operator separately and only transpile those (I'll open a feature request later).

Indeed, ESBuild having something like Babel's bugfixes would be nice. Ref https://github.com/babel/babel/pull/13009

merceyz avatar Aug 01 '22 12:08 merceyz

Could we keep this version in a single place? Perhaps a .node-build-version at the root?

arcanis avatar Aug 01 '22 13:08 arcanis

I'll close this since the output is identical in [email protected].

merceyz avatar Dec 29 '22 17:12 merceyz