Releases: stampit-org/stampit
v5.0.1
v5.0.0
Modernisation related breaking changes
The previous breaking version 4.0.0 was released EIGHT YEARS AGO. 🤯
The v5.0.0 modernises the codebase and simplifies the code infrastructure. However, the stamps themselves are exactly the same. In other words, stampit v4 and v5 are 100% compatible with each other. They produce identical stamps. ✌️
BREAKING CHANGES:
-
No more CJS or UMD distributable. The package becomes pure ESM.
Thus, only Node v20 and above is supported.
You don't need to change your CJS code at all, the v5require("stampit")works identical to v4. -
There are 19 so called "shortcut" functions. You need to import them differently.
Instead ofconst { props } = require("stampit")do thisconst { props } = require("stampit").default().
Instead ofstampit.props()do thisstampit().props().
The good news is - this feature was rarely used by real people. So, I'm not worried much here. -
Removed the
stampit.version.
It was requested by one person only.
It significantly complicates the development of this module.
It was useful when Stamps themselves were incompatible with each other. Not going to happen any more.
Other changes
- Complete remove all and every build steps! Ship the original stampit.js as the only distributable file.
- Rewrote the code from ES5 to ES6.
- Removed "tests in browser", it doesn't make sense any more.
- This package "type" is "module" now.
- Use different (simpler) modern dev dependencies.
- Use the default prettier across.
- Removed a lot of outdated docs (some were >10 years old!).
- Rewrote unit tests from "tape" to "node:test".
- The stampit.js itself is not maniacally minified any more, I made it super easy to learn and understand. The min.js and min.js.gz are still the same size as before.
- The minified version is not published any more. The
./stampit.min.jsis gone. Minify it yourself please. Like all people do. :)
55 bytes or 4% smaller bundle if Gzipped
Minor but important - improved TypeScript support
This whole release is @PopGoesTheWza work on fixing and improving the d.ts files. See "types": "./types/index.d.ts", line in the package.json and the Pull Requests #348 #350
Getters and Setters built in support
JavaScript getters and setters are now no different to string or Symbol properties. This means that you can have getters in methods, properties, static properties, configuration, etc.
Example:
const HasFullName = compose({
properties: {
firstName: "",
lastName: ""
},
methods: {
get fullName() {
return this.firstName + " " + this.lastName;
},
set fullName(name) {
var words = name.toString().split(" ");
this.firstName = words[0] || "";
this.lastName = words[1] || "";
}
}
});
const developer = HasFullName();
developer.fullName = "Vasyl Boroviak";
console.log(developer.firstName); // "Vasyl"
console.log(developer.lastName); // "Boroviak"
console.log(developer.fullName); // "Vasyl Boroviak"name: "MyStampName" in stampit arguments
Now you can pass "name" property to stampit. It will automatically give your stamp (aka factory) the name. E.g.
const StripeService = stampit({
name: "StripeService",
init(_, {stamp}) {
console.log("Creating an object from the stamp named", stamp.name);
}
});
const SomeStamp = StripeService;
console.log(SomeStamp.name); // "StripeService"See this blog post.
Added stampit.version
The stampit.version is now a string which represents its NPM version. E.g. "4.1.1".
Not so breaking release
To migrate to stampit v4 most likely you won't need to do any changes to your codebase.
Please note that NPM registry do not have stampit v4.0.0, instead use v4.0.2. Sorry about that.
BRAKING CHANGES:
- Removed the previously deprecated
refs. Please, usepropsinstead.
(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/stampinstead ofstampit/isStamp,@stamp/is/composableinstead ofstampit/isComposable, and@stamp/composeinstead ofstampit/compose. - The composers are now stored in
Stamp.compose.composersmetadata 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.jsbundle is now twice smaller (2.7KB), the gzipped size is 40% smaller - 1.3KB. - We run tests in browsers now too.
- Fixed few bugs - #317 #304 #68
- Stampit was rewritten in ES5 which allowed the three items above.
- Updated all the documentations we have in this repo.
Bug in the ES5 compatibility code
The assign implementation didn't work sometimes.
Added support of IE11 and all (old) versions of node.js
Community asked. We replied. Support all ES5-compatible environments!
Basically, we added an internal polyfil to not rely on global Object.assign anymore. This added +100 bytes to the stampit.min.js bundle (or +40 gzipped).