Skip to content

Make target browsers configurable - #1249

Closed
gaearon wants to merge 2 commits into
react:masterfrom
gaearon:target-browsers
Closed

gaearon wants to merge 2 commits into
react:masterfrom
gaearon:target-browsers

Conversation

@gaearon

@gaearon gaearon commented Dec 12, 2016

Copy link
Copy Markdown
Contributor

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

gaearon commented Dec 12, 2016

Copy link
Copy Markdown
Contributor Author

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

@hzoo

hzoo commented Dec 12, 2016

Copy link
Copy Markdown

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

ai commented Dec 12, 2016 •

Copy link
Copy Markdown
Contributor

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

gaearon commented Dec 12, 2016

Copy link
Copy Markdown
Contributor Author

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

gaearon commented Dec 12, 2016

Copy link
Copy Markdown
Contributor Author

@hzoo

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

@hzoo

hzoo commented Dec 12, 2016

Copy link
Copy Markdown

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

gaearon commented Dec 12, 2016

Copy link
Copy Markdown
Contributor Author

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

@ai

ai commented Dec 12, 2016

Copy link
Copy Markdown
Contributor

development/production environment are planned too with same ETA 😊

@gaearon

gaearon commented Dec 12, 2016

Copy link
Copy Markdown
Contributor Author

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

lydell commented Dec 12, 2016

Copy link
Copy Markdown

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

ai commented Dec 12, 2016

Copy link
Copy Markdown
Contributor

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

@gaearon

gaearon commented Dec 12, 2016

Copy link
Copy Markdown
Contributor Author

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

nelix commented Dec 15, 2016

Copy link
Copy Markdown

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

@gaearon

gaearon commented Dec 15, 2016

Copy link
Copy Markdown
Contributor Author

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

ai commented Dec 19, 2016

Copy link
Copy Markdown
Contributor

@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

ai commented Dec 21, 2016

Copy link
Copy Markdown
Contributor

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

ai commented Dec 23, 2016

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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

zikaari commented Oct 26, 2017

Copy link
Copy Markdown
Contributor

@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