Skip to content

Conversation

@nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Mar 6, 2023

Q                       A
Fixed Issues?
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

The main reason for this PR is to reduce the output difference between Babel 8 and Babel 7, which is quite annoying (I noticed it while reviewing #15068)

As mentioned in #14976 (comment), this change is only about how we present the log and I don't think it counts as a breaking change.

Users can already use options like "exclude": ["transform-class-static-blocks"] (even if technically the npm package name uses -proposal-), so it's ok to also use it in the debug logs. Most users should only use the preset and not the individual packages anyway, and this hides from them the distinction between "transform" and "proposal that become Stage 4 since when the plugin was released", which is just historical and doesn't matter in practice.

@nicolo-ribaudo nicolo-ribaudo added PR: Polish 💅 A type of pull request used for our changelog categories pkg: preset-env labels Mar 6, 2023
@babel-bot
Copy link
Collaborator

babel-bot commented Mar 6, 2023

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/54237/

@nicolo-ribaudo nicolo-ribaudo changed the title Log transform- instead of proposal- in `preset-env- debug Log transform- instead of proposal- in preset-env debug Mar 7, 2023
Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think changing logs here will be confusing to end users. Take proposal-optional-chaining for example:

  • We haven't published @babel/plugin-transform-optional-chaining yet
  • There aren't docs for @babel/plugin-transform-optional-chaining on our website, and we don't have redirection rule to the proposal-* transform

So users will have to mentally match some transform-* debug output to the exact proposal-* one. They probably won't know which transform-* is actually proposal-* until when they hit a npm 404 error, which seems more like a Babel bug to them than a polish to us...

As for fixture changes, I think we may have to duplicate all debug fixtures to babel 8.

Can we start the renaming process gradually? We can publish transform-* in the next minor and make proposal-* an alias to the transform-* plugins, then we archive the proposal-* plugins and have preset-env directly using transform-* plugins, so the debug log is consistent.

@nicolo-ribaudo
Copy link
Member Author

That plan sounds good 👍 Wdyt if I update this PR to only unify the fixtures (without actually changing what our users see), while working on the rename in parallel? I'd like to avoid duplicating the fixtures, because in practice it means that we have to run the tests twice every time we want to update snapshots (which is easy to forget, until you see the error on CI).

@nicolo-ribaudo nicolo-ribaudo removed the PR: Polish 💅 A type of pull request used for our changelog categories label Mar 8, 2023
@nicolo-ribaudo nicolo-ribaudo changed the title Log transform- instead of proposal- in preset-env debug (tests only) Log transform- instead of proposal- in preset-env debug Mar 8, 2023
@nicolo-ribaudo nicolo-ribaudo force-pushed the env-log-proposal-to-transform branch from 4f3c010 to cd9cede Compare March 30, 2023 14:07
// the output logs so that we don't have to duplicate all the debug fixtures for
// the two different Babel versions.
// TODO(Babel 8): Remove this.
result = result.replace(/(\s+)proposal-/gm, "$1transform-");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The normalizeOutput is also applied to the transformed code. Can we make a new flag, e.g. normalizePresetEnvDebug like we did for normalizePathSeparator? Then we can enable this flag only when we are validating logs, preferably from preset-env only. So the fixture runner won't accidentally replace proposal- to transform- out of the preset-env scope.

@nicolo-ribaudo nicolo-ribaudo force-pushed the env-log-proposal-to-transform branch from cd9cede to fae1e27 Compare April 5, 2023 09:45
@nicolo-ribaudo nicolo-ribaudo changed the title (tests only) Log transform- instead of proposal- in preset-env debug (tests) Log transform- instead of proposal- in preset-env Apr 5, 2023
@nicolo-ribaudo nicolo-ribaudo merged commit 83d9ba4 into babel:main Apr 5, 2023
@nicolo-ribaudo nicolo-ribaudo deleted the env-log-proposal-to-transform branch April 5, 2023 10:03
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jul 6, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: preset-env

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants