| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
The alternative is to write these calls explicitly: let somePrinter: Printer | undefined;
function createSomePrinter(): Printer {
return somePrinter ??= createPrinter();
}I did scan the repo and there was only one other top level memoize usage in services, on which @__PURE__ does nothing. |
Sorry, something went wrong.
|
Did you validate locally that this is smaller? |
Sorry, something went wrong.
|
I did, yep: $ git diff --diff-filter=AM --no-index ./built/local-old/typingsInstaller.js ./built/local/typingsInstaller.js --numstat
1 5648 ./built/{local-old => local}/typingsInstaller.js
|
Sorry, something went wrong.
|
Its interesting that this is not tree shaked out ? i thought you said things are getting removed if not used. I dont see why typingInstaller needs printer. But thats a separate question i guess.. |
Sorry, something went wrong.
|
It's not tree shaken because the arrow function (which references createPrinter) is passed to another function (memoize), and it doesn't know that memorize doesn't immediately call the function or something. So it can't eliminate the memoize call because it could have a side effect. |
Sorry, something went wrong.
|
I would absolutely love a way to mark certain functions themselves as side-effect free, but that doesn't seem to be a thing that bundlers support (they all seem to do it at the function call site instead, which is a shame). |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
#52382 added a few new top-level variables to emitter.ts; but, I noticed in dcad07f (which pulled this change into release-5.0) that typingsInstaller grew by 5000+ lines.
This is because the memoize function isn't seen as pure (it could reasonably call the function it accepts immediately). I don't want to totally throw off the bundle size, so just mark the new things as pure to restore the old size.