-
Notifications
You must be signed in to change notification settings - Fork 30
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
Rework variants to reduce bundle size #83
Conversation
With the current changes, we're at 182.0 kB packed, 1.1 MB unpacked. Still quite heavy... npm pack
|
fyi, renaming, moving or removing different files/variants can cause a breaking change and would need a major change as ppl can depend on choosing their own variant to do the job |
I know, that's why I added a "semver-major" label. 😁 |
29d80e9
to
4551f90
Compare
Down to 119 KB packaged, 638.8 KB unpacked. I'm now using code splitting on the ESM bundles, so npm pack
|
could the polyfill load the ponyfill instead? Meaning ponyfill would just be as tiny as loading the ponyfill and assigning it to the global namespace... |
No it can't. Polyfill would need to synchronously import the ponyfill. It'd be neat if a single UMD build could polyfill when loaded in browser, and ponyfill when loaded as CJS. Windows 11 won't ship IE. Are ES5 builds really needed? This is looking pretty good already. |
Probably not. It wouldn't work in browsers. And Node.js |
IE11 is pretty much dead already... down at 0.57% https://gs.statcounter.com
Agree, but still think there is room for improvements, but don't know how. How about minifying all files? |
could be replaced with https://nodejs.org/api/packages.html#packages_subpath_exports. And |
Thanks for the suggestions! 🙂 Indeed, I cannot have the UMD polyfill load the UMD ponyfill like I did with ESM, because there's no general/reliable way to do that. I don't know if people expect ESM bundles to be human readable? Anyway, I can turn on minification unconditionally. The company I work for also uses this polyfill, and we still support IE11... 😬 I'll check if we can make the polyfill ES6-only and set up some transpilation on our I've got an experiment branch that uses package entry points instead. I want to first check if bundlers like Webpack and Rollup handle these correctly before I commit to it. |
Doesn't matter to me so much. At least when it comes to spec'ed apis Other packages yes. Then it is nice with readable code. Minified code loads/parse faster and and have the potential for code optimization that makes it run faster. So I'm +1 for minification |
Just speculation. But could the typing reference (or extend) the Dom implementation so d.ts could be reduced? |
Apparently that's not possible. From the npm docs:
So
That requires a Looks like they're trying to tackle this by extracting the type definitions shared between Node and DOM into a separate file: microsoft/TypeScript#43972. That would solve the problem. |
Working a bit with deno nowdays... guess full urls don't work with microsofts own typescript yet /// <reference lib="https://github.com/MattiasBuelens/web-streams-polyfill/blob/36c08de41aa3a5699afab717b0e64af13dada56f/x.d.ts" /> the alternative is hosting types at @types |
Minification is now enabled across the board. We're now at 87.0 kB packed, 401.8 kB unpacked. npm pack
Package entry points seem to work fine in the latest versions of Rollup and Webpack, so I made the switch. For my own sanity, I've added tests for both bundlers and for |
What do |
They can register with an AMD module loader (like RequireJS through Do I expect anyone to actually be using this? Not really... 😛 |
I made the ES6 ponyfill the default variant. If we're going to make breaking changes, we're going to really break things. 😛 Still not sure about the name of the polyfill variant though: There's not much of a difference in the package size: 86.2 kB packed, 397.0 kB unpacked. npm pack
|
Hmm, now that the polyfill variant does not |
Found a workaround for the type definitions using Even better: it will now augment TypeScript's built-in I would have liked to make Still not sure about the name of that entry point though. I've come up with a few alternatives:
|
"browser" is unnecessary if it's equal to "main".
2b124c4
to
d7f5595
Compare
5dadd34
to
3e1d1e8
Compare
Released version 4.0.0-beta.1, see release notes. Looking forward to your feedback! 😀 |
Cool! Want to test it now, but guess i will do it tomorrow instead (22:23) here now. |
|
This removes some variants and build artifacts to reduce the total download size of the npm package.
ReadableStream.prototype[Symbol.asyncIterator]
won't correctly inherit from%AsyncIteratorPrototype%
, but nobody cares about that. 😛Fixes #82.
To do:
Would it make sense to haveponyfill.mjs
import fromponyfill.js
and re-export the CommonJS module as an ES module, as documented here?