Skip to content

Commit

Permalink
Don't transpile to ES5
Browse files Browse the repository at this point in the history
This is meant as a discussion for a future major version of Apollo
Client.

Right now the published package is using TypeScript's downleveling emit
directives to compile to ES5. This *irreversibly* bloats the package
with cruft that most users won't need. Additionally, it affects
performance since native ES features are simulated using clunky
workarounds. This is especially noticeable with async/await where any
async functions compile into a state machine. This also affects nullish
coalescing (`??`), optional chaining (`?.`), arrow functions, and a lot
more.

My suggestion is to publish this package using the code as it was
written and allow the user's bundler to perform transpilation and
minification as configured.

This reduces the size of `apollo-client.min.cjs` from 120kb to 104kb
which is pretty good for a one-line change.
  • Loading branch information
laverdet committed May 18, 2023
1 parent 5ab0563 commit 2f64899
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/calm-pears-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": major
---

Don't downlevel published package
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"sourceMap": true,
"declaration": true,
"declarationMap": true,
"target": "es5",
"target": "esnext",
"module": "es2015",
"esModuleInterop": true,
"experimentalDecorators": true,
Expand Down

0 comments on commit 2f64899

Please sign in to comment.