- The lack of a clear, standard indicator of when a library incorporates experimental language features
- The inability to consciously opt in to using these features
In this post I'll outline my proposals for addressing these issues.
This idea is lifted from Composer, which has
minimum-stability property for projects. My idea is as follows:
- Libraries indicate if they are using experimental language features and from what stage
- Project authors specify the lowest proposal stage they're comfortable with
npm installwarns if you are installing a library with features newer than desired
For example, if you only want "finished" (Stage 4) or higher features in your project, you add the following to your
"minimum-proposal-stage" : 4
Aurelia would indicate that it incorporates a Stage 2 proposed/experimental feature (decorators) by adding the following to its
"lowest-proposal-stage" : 2
Upon attempting to install Aurelia, npm would warn you that the library's
lowest-proposal-stage is lower than your
minimum-proposal-stage. Basically: "hey! You're about to install a library with language features more experimental than you might be comfortable with!"
- More granularity: This solution allows me to say "I am comfortable with Stage 4 (finalized, but not yet released) features, but nothing below that."
- Requires users to learn more about the TC39 feature proposal process (perhaps this is actually a "pro"?)
- Would require libraries to update their
lowest-proposal-stageproperty as features are adopted into the language
This is like above, but pegged to ECMAScript versions.
Example: in my project, I don't want code newer than ES7 (the current released standard at the time of this writing), i.e. I don't want unreleased features:
"maximum-ecmascript-version" : 7
In the library's package file, they indicate that the library incorporates features that do not exist in any current version of ECMAScript:
"ecmascript-version" : "experimental"
npm would warn me before installing this package. This one, on the other hand, would install without complaint:
"ecmascript-version" : 5
ecmascript-version is lower than my maximum.
- Simpler, easier to understand
- Released ES versions do not change, no need to update
ecmascript-versionif it's set to a released version
- Not possible to allow some proposal stages but forbid others with this system
The two systems could also be used in conjunction with one another; I won't go into that possibility here.
Add badges to
README.md files to indicate whether experimental features are used in the library. Here are some sample badges that use the proposal stage names rather than numbers:
(Please excuse the largeness of these badges)
Alternately, the language version could be used:
- Does not require tooling (npm) updates—authors can start doing this right away
- Human readable
- Not machine readable: npm cannot alert you if you attempt to install something with features less stable than you prefer
- Allow users to consciously opt-in to using experimental language features
- Allow those who prioritize stability to opt-out of using experimental language features
Please let me know what you think with a comment (below) or on hackernews.