question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

packaging improvements

See original GitHub issue

Hi ✋ Whilist using kv-asset-handler I’ve seen some points of improvement worth to share. Would be happy to discuss on each, making sub-issues or going with some PRs to address.

Unnecessary files published inside npm package

Checking unpkg files like tsconfig.json or .github are published which increase install size. You may use files field in package.json to whitelist only dist (or also src)

Legacy dist

I can understand that cloudflare workers support (at least partial) of ES6 so we may keep things like await syntax which may help reduce final worker size (and probably more v8 optimization by using modern syntax). Using tsc, you may use ESNext but also careful not using unsupported features like optional chaining. Or using a modern tool like siroc (/cc @danielroe) or directly esbuild. (benefit of using siroc would be to also generate .mjs output that allows final compiler to do better tree-shaking, publishing public types.

Using full version of mime

mime has a lite entry (25 kB vs 9 kB) which is containing all of standard mimes. This can significantly reduce bundle size. You may import from mime/lite

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:7
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
xtuccommented, Nov 26, 2020

I don’t think performance is a consider when using async/await vs Promise. It won’t have any noticeable impact in your worker. I would privilege the one that’s easier to write/maintain.

On the other hand size is a concern, webpack should be able to swap out mime full for the lite version at build time. I’m concerned that using the lite version by default would break existing users.

1reaction
SukkaWcommented, Nov 25, 2020

so we may keep things like await syntax which may help reduce final worker size (and probably more v8 optimization by using modern syntax)

Yes, I do agree on the polyfill for async/await is not necessary since Cloudflare Workers already provides the support for it. But IMHO I prefer kv-asset-handler to be written in traditional Promise instead of async/await: although v8 improves the performance of async/await quite a lot, it is still slower than traditional Promise.

mime has a lite entry (25 kB vs 9 kB) which is containing all of standard mimes. This can significantly reduce bundle size. You may import from mime/lite

Although full mime is a bit large, the bundle size will not affect so much since Cloudflare has the 1 MiB size limit for the script.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Steal This Idea: Focus on Packaging Improvements
Steal This Idea: Focus on Packaging Improvements. Be sustainable, retain food quality and temperature Mar. 15, 2022. Facebook · Twitter · LinkedIn ·...
Read more >
Sustainable Packaging Sees Improvements in Functionality
Mars and Berry Global are driving positive societal impact through new M&M's, Skittles and Starburst packaging made with 15% recycled ...
Read more >
5 Ways to Improve Your Packaging Process - PakFactory Blog
Focus on Ergonomic Packaging · Test and Optimize your Packaging · Create the Right Packing Area for Efficiency · Opt for Sustainable Materials ......
Read more >
Improving Packaging - About Amazon
We work to reinvent and simplify our sustainable packaging options using a science-based approach that combines lab testing, machine learning, materials science ...
Read more >
The drive toward sustainable packaging | McKinsey
Handling has been improved with a plastic sleeve that fits snugly inside a rectangular cardboard package. In addition, this hybrid mix of ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found