Skip to content

Restrict the use of passPerPreset #6921

Open

Description

@taion

cc @loganfsmyth

Feature change request

Input Code

N/A

Babel/Babylon Configuration (.babelrc, package.json, cli command)

Anything with passPerPreset

Expected Behavior

The use of passPerPreset should be restricted

Current Behavior

passPerPreset is allowed in user configurations

Possible Solution

Disallow using passPerPreset in user Babel configurations.

Context

The majority of current usages of passPerPreset in user code originally date to a misunderstanding about plugin ordering with Relay. Relay examples now no longer use passPerPreset: facebookarchive/relay-starter-kit#102, and I've opened an issue with the Apollo devs to remove derived usages there as well: apollographql/starwars-server#5.

Correspondingly, there may not be any real use cases for passPerPreset in user code any more. As such, given that this feature has historically not been used very often, and has led to odd interactions between existing presets due to just using a rare code path (e.g. #4162), I think it would make sense to heavily limit its use.

Even in cases where it does arise, it's not the correct scope – the scope instead looks more like "this preset or this plugin should have its own pass", rather than "every preset or plugin in this config (or every plugin in this preset) should have its own pass".

Your Environment

N/A

Activity

  1. babel-bot commented on Nov 27, 2017

    @babel-bot
    Collaborator

    Hey @taion! We really appreciate you taking the time to report an issue. The collaborators
    on this project attempt to help as many people as possible, but we're a limited number of volunteers,
    so it's possible this won't be addressed swiftly.

    If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
    community that typically always has someone willing to help. You can sign-up here
    for an invite.

  2. xtuc commented on Dec 1, 2017

    @xtuc
    Member

    I agree that we should restrict its usage. After a quick search it seems that some users are relying on it GitHub search even if it's not documented.

    We can introduce a warning in Babel 7 and drop it in Babel 8, what do you think?

  3. taion commented on Dec 1, 2017

    @taion
    ContributorAuthor

    You can also see that substantially all those cases are GraphQL-related cases, owing ultimately to that initial Relay thing.

    I think @loganfsmyth mentioned that babel-minify still needed it? Ultimately I think passPerPreset is sort of the wrong concept – like I said above, I can see there being a valuable idea in "this preset runs in its own pass", but ultimately I don't think this option should be exposed to end-users like this.

  4. hzoo commented on Dec 1, 2017

    @hzoo
    Member

    We said we should at least only allow it in a preset (like minify) then end-users wouldn't be able to set it themselves.

  5. taion commented on Dec 1, 2017

    @taion
    ContributorAuthor

    Even for minify, one goal would be to run the entire minify preset after all the earlier presets, no? I feel like there are a couple of different concepts here that are a little bit mixed up:

    • "Run this preset in its own pass"
    • "Run each part of this preset in its own pass"
  6. added this to the Babel 7.next milestone on Dec 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions