Fun with Stamps. Episode 20. Stampit v4
3 min readNov 9, 2017
Hello. I’m developer Vasyl Boroviak and welcome to the twentieth episode of Vasyl Boroviak presents Fun with Stamps.
TL;DR
To migrate to stampit v4 most likely you won’t need to do any changes to your codebase. Also, stampit min.js
bundle got twice smaller.
Please note that NPM registry do not have stampit v4.0.0, instead use v4.0.2. Sorry about that. The v4.0.0 npm bundle was missing a file.
BRAKING CHANGES
- Removed the previously deprecated
refs
. Please, useprops
instead.
(Please note, if you are migrating from stampit v2 to v4 you would need to renameprops
->deepProps
, and thenrefs
->props
. Sorry for the inconvenience. But it looks like the last rename in stampit’s life.) - Removed
stampit/*
utility functions.
Please use@stamp/is/stamp
instead ofstampit/isStamp
,@stamp/is/composable
instead ofstampit/isComposable
, and@stamp/compose
instead ofstampit/compose
. - The composers are now stored in
Stamp.compose.composers
metadata instead ofStamp.compose.deepConfiguration.composers
.
Should you care? Probably not. Good thing is — this makes stampit fully compatible with@stamp/*
modules ecosystem.
Other notable changes
- Stampit is fully compatible with
@stamp/*
modules ecosystem now. - The
.min.js
bundle is now twice smaller (2.7KB), the gzipped size is 40% smaller — 1.3KB. - We run tests in browsers now too.
- Fixed a bug: none of the
stampit.FUNC
were working in browsers. - Stampit was rewritten in ES5 which allowed the three items above.
- Updated all the documentations we have in this repo.
Difference between stampit
v4 and @stamp/it v1
The stampit
and @stamp/it
have same API. Do we need both?
Porque no los dos? :)
stampit
is mainly for browsers. It has both node and browser builds. Whereas@stamp/it
is node CommonJS only.stampit
is 2.7KB min.js (1.3KB gzipped). It is what most of people need in browsers. Whereas@stamp/it
don’t even have a minified bundle.stampit
source code is unreadable due to various size optimisations. Whereas@stamp/it
source code is easy to read and understand.
Latest download stats from NPM
Find the graphs here.
Have fun with stamps!
- Episode 1. Stamp basics
- Episode 2. Dependency injection in FP
- Episode 3. Comparing with the ES2015 classes
- Episode 4. Implementing stamps yourself in 30 LOC
- Episode 5. Composition design pattern
- Episode 6. Statics — properties on stamps
- Episode 7. Early and late dependency injection
- Episode 8. Tracking and overriding composition
- Episode 9. Detaching compose()
- Episode 10. My stamp mental model
- Episode 11. Interfering composition
- Episode 12. New @stamp home
- Episode 13. Method collision control
- Episode 14. New @stamp/it as a replacement of Stampit
- Episode 15. The @stamp/ modules ecosystem
- Episode 16. TypeScript mix-in classes vs Stamps
- Episode 17. Easy 100% unit test coverage in JS
- Episode 18. Dependency injection paradise
- Episode 19. Java/C# abstract methods in JavaScript
- Episode 20. Stampit v4 (this article)
- Episode 21. Private data in JavaScript. 4 ways using stamps
- Episode 22. JavaScript instanceof as composable stamp
- Episode 23. New stampit.js.org with all the docs
- Episode 24. New “name” feature