Skip to content
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

Make target browsers configurable #1249

Closed
wants to merge 2 commits into from

Conversation

gaearon
Copy link
Contributor

@gaearon gaearon commented Dec 12, 2016

Proof of concept for #892.
Doesn't work with ejecting yet.

Both autoprefixer and Babel are driven by a config like this in package.json:

  "browsers": {
    "development": [
      "last 1 chrome version"
    ],
    "production": [
      ">1%",
      "last 4 versions",
      "Firefox ESR",
      "not ie < 9"
    ]
  }

Currently I throw if it doesn't exist since I could generate a reasonable config by default (e.g. "last two versions" for development) in new projects and ask old projects to include it during migration. In a way this would be "configuration" but actually sensible one. I don't have a strong opinion here though.

@gaearon gaearon added this to the 0.9.0 milestone Dec 12, 2016
@gaearon gaearon modified the milestones: 1.0.0, 0.9.0 Dec 12, 2016
@gaearon
Copy link
Contributor Author

gaearon commented Dec 12, 2016

TODO: this likely requires switching to Babili. https://github.com/babel/babili
Because otherwise targeting too modern browsers in prod would crash Uglify.

@hzoo
Copy link

hzoo commented Dec 12, 2016

Similarly had an issue with webpack 1 since it's using an older version of acorn for async - forgot about that (babel/babel-preset-env#66)

@ai
Copy link
Contributor

ai commented Dec 12, 2016

Note, that I am planning to add package.json support to Browserslist in next month. But I will use browserslist key.

The only issue with this CRA browsers key, that other tools added by user (Stylelint, doiuse, cssnext) will not get it. But CRA feature anyway will be faster than Browserslist fix, so we could start from it and then move to browserslist config key (I prefer global standard instead of CRA-only).

@gaearon
Copy link
Contributor Author

gaearon commented Dec 12, 2016

My only concern with browserslist is that we still need a way to separate development from production configuration. If it will support this, I’m happy to use it.

@gaearon
Copy link
Contributor Author

gaearon commented Dec 12, 2016

@hzoo

Alternatively we could add uglify and webpack targets to document their minimally supported environments.

@hzoo
Copy link

hzoo commented Dec 12, 2016

Yeah totally true, didn't even think of that! Could just alias it to node 0.10/0.12 although diff for webpack 2

@gaearon
Copy link
Contributor Author

gaearon commented Dec 12, 2016

Another todo: make sure builds are reproducible
https://twitter.com/brian_d_vaughn/status/808143454739959808

@ai
Copy link
Contributor

ai commented Dec 12, 2016

development/production environment are planned too with same ETA 😊

@gaearon
Copy link
Contributor Author

gaearon commented Dec 12, 2016

Sounds great. This is a bit of a longer term project so I’m in no rush. It’ll take a while to work out most issues and get this to a stable state.

@lydell
Copy link

lydell commented Dec 12, 2016

Please enlighten me! Why different browsers in development and production? Is it because of easier-to-read compiled code? What about when I need to fix those nasty IE 11 or Safari 9 bugs (which require certain vendor prefixes, for instance)?

@ai
Copy link
Contributor

ai commented Dec 12, 2016

@lydell I asked for feedback in Autoprefixer twitter. Maybe some user have good use cases for environments (maybe not only development/production).

@gaearon
Copy link
Contributor Author

gaearon commented Dec 12, 2016

I think it's up to developers to decide for themselves. Personally I'd use a lighter setting in development for better compiled output and errors, especially in code heavy with async/await or generators. But I’m the kind of person to test features with production settings before merging. It’s not safe if you don’t do this kind of testing so I’d make them match by default and document it somewhere that it is possible to loosen it up if you know what you’re doing.

@nelix
Copy link

nelix commented Dec 15, 2016

It would be nice if this config also loaded required core-js poly and ideally inlined them via babel-runtime

@gaearon
Copy link
Contributor Author

gaearon commented Dec 15, 2016

It would be nice if this config also loaded required core-js poly and ideally inlined them via babel-runtime

👍 Yeah, that's the plan.

@ai
Copy link
Contributor

ai commented Dec 19, 2016

@gaearon browserslist master got env and package.json support. @hzoo do you need node queries in package.json on this step? Or we could release new Browserslist?

@ai
Copy link
Contributor

ai commented Dec 21, 2016

Browserslist 1.5 was released with production/development and package.json support.

@hzoo I really need your feedback. Please do not ignore my messages :).

@ai
Copy link
Contributor

ai commented Dec 23, 2016

Autoprefixer 6.6 is out with package.json support https://github.com/postcss/autoprefixer/releases/tag/6.6.0

// We always include this plugin regardless of environment
// because of a Babel bug that breaks object rest/spread without it:
// https://github.com/babel/babel/issues/4851
require.resolve('babel-plugin-transform-es2015-parameters'),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this was fixed in babel@6.22.0.

@zikaari
Copy link
Contributor

zikaari commented Oct 26, 2017

@Timer Timer closed this Sep 21, 2018
@lock lock bot locked and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants