-
Notifications
You must be signed in to change notification settings - Fork 11
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
WinterCG Common key proposal #5
Comments
Why does the key need to change? Wouldn't the key remain the same ( Something like: {
"engines": {
"wintercg": ">=2023"
}
} |
Hey 👋 I'm working on Nitro with @pi0. We often face the issue where libraries are packaged to assume that the Ideally I'd like to see a different export condition that can describe an environment with access to Web APIs but not necessarily a browser ( Naturally, I think WinterCG would be a good place to discuss and start to build consensus on this. Could we use the common key in subpath exports? {
"name": "pkg",
"exports": {
".": {
"node": "./dist/pkg.node.mjs",
"wintercg": "./dist/pkg.worker.mjs",
"import": "./dist/pkg.mjs"
}
}
} Having said that, adoption is crucial for this if it will be adopted by library maintainers, and I worry that Thoughts very welcome. |
I've been thinking about the scenario of how the key may be used in the I've come to the conclusion that this feels like a non-problem. Tooling currently doesn't support multiple exports for different runtime versions. And in the wild, when there's a major difference in a library based on the runtime version (lets say Node.js v14 vs Node.js v20), then the library will maintain two release lines (usually two major versions of the library itself) that have two distinct source branches too. So really |
MDN just announced Baseline which is basically a minimum common API for the web. I wonder if there is any insight we can glean from their solution that could help here. Seems like there are planning to use years as versions like Baseline 2024. |
Introduction
As runtime keys have begun being adopted for individual platforms, some developers have asked for some kind of common key indicating a package is compatible with the WinterCG Minimum Common API, and thus the package will work in any framework that is also compatible with the Minimum Common API.
The simplest solution is to add a
"wintercg"
key that indicates Minimum Common API compliance. However, this solution is incomplete.Since the Minimum Common API specification can change overtime, discrepancies can form between frameworks and packages that both claim to be compliant with the standard. For example, consider ECMAScript. When a developer uses ES2020 features in their code, but the target system can only handle ES6 code, their project simply wont work. To parallel that to the Minimum Common API, imagine if the standard was to change and add a new interface. A developer then uses that new interface in their project, and expects to be able to run their project on any framework that indicates its
"wintercg"
compatible. Lets assume a framework hasn't been able to add that new interface yet. This developer's project will not work in that particular framework.Proposed Solution
There are multiple pieces to this problem
How can frameworks reliably indicate they comply with the Minimum Common API?
Browser have had a solution to this for a long time, web platform tests. If we create a similar test suite for the Minimum Common API (and maybe even use the existing WPT), frameworks can automatically test themselves against it and report the results to a public tool such as caniuse.com.
How can a library or application author indicate their thing is compatible with any framework that complies with the Minimum Common API?
Given the usage example in the Runtime Keys specification, libraries and applications can use the
"engines"
fields inpackage.json
to indicate what framework version (or version range) they can be used in. By introducing a"wintercg"
key as well as versioning methodology for that represents compliance with the Minimum Common API, projects could specify exactly what version of the specification they are compliant with.How can tools check at build-time and run-time that a given library or application is compatible with current framework?
Incorporating the versioning methodology into the test suite compliance tool, build-time and run-time tooling can be instrumented to compare values between what specified in a project’s configuration file (like
package.json
) with what has been publicly recorded and verify if the given project is supported.Versioning Methodology
Option 1: Annual versioning
wintercg-2023
andwintercg-next
engines
, they may be used like"wintercg": "2023"
insteadOption 2: semver
wintercg-1.0.0
andwintercg-2.3.4
"wintercg": "1.0.0"
Next Steps
Thank you for reading this proposal. Please comment your thoughts and feedback in this issue thread or in the WinterCG Matrix channel. We will discuss this proposal at the next WinterCG call on May 4th, 2023. It will also be presented during my talk at Open Source Summit on May 10th. 🚀
The text was updated successfully, but these errors were encountered: