Open hzoo opened 4 years ago
I really like that idea. It builds on the pattern I strive to follow in every dependency anyways: all breaking changes are just toggling the default of an option, but you can always opt in to the new default early, or opt out of it later.
Didn't want to spam our release issue too much so just writing this here as well.
There are a lot of concerns (I have them too) around what a major version bump would look like for the ecosystem. What else can we do in addition to a upgrade guide for the end user (good errors, clear explanation of changes, workaround/migration)?
What about dependencies of dependencies? Especially if you aren't using Babel directly (see issues from v6 to v7). We ended up with slow approach of essentially a year of alphas/betas/rc so that by the time it was out, most things were already updated and you could say it was relatively smooth compared to v5 to v6. But then again it took forever and there was a long process of versioning.
Idea
Use an environment variable (currently
BABEL_8_BREAKING
), which includes all breaking changes. Essentially a "feature flag" that we introduce (and continue to add onto) in Babel 7 patch versions.Enables opt-ing into breaking changes without needing to change versions or dependencies.
So as a library author, you could do a dry-run and update accordingly. Or make PRs that run against the flag so that you can update the package ahead of release as we land changes. (hopefully we don't prolong this more than needed).
For the Babel codebase, ideally we do it in a way that makes this easy to automate away with a codemod. Babel 8 diff would be removing the flags (this is good because we aren't trying to introduce new features in the major version, we just do it in the minor)
Tests?
We'll need to run tests for both "versions" to not break anything.
One approach: based on file extension: if the flag is enabled and it's a
v7
test OR if the flag isn't enable and it's av8
test, then skip the test?Test renaming:
output.v7.js
,options.v7.json
output.v8.js
,options.v8.json
.v7.
files, rename.v8.
files to normalIssues
BABEL_8_BREAKING babel a.js
instead of something likeBABEL_BREAKING babel a.js
process.env
vs. config option? It seems easier since we don't need to pass options between packages (config, plugin, parser option). Also there's no access to options in our interations like CRA.next-8-dev
branch that has merged some PRs into it. Ideally we would be able to just port all breaking change PRs tomaster
under the flag and ignorenext-8-dev
.Todo