rollup / rollup-starter-lib

Bare-bones example of how to create a library using Rollup
MIT License
962 stars 230 forks source link

Question: why don't we set the target environment settings for `babel-preset-env` part? #3

Closed revelt closed 6 years ago

revelt commented 6 years ago

I'm talking about babel branch specifically.

Correct me if I'm wrong, but the point of babel-preset-env is to automate the Babel settings, specifying only the target platform, like "targets": { "browsers": ["last 2 versions", "ie >= 7"] } or "browsers": "> 5%" and so on. The Babel then knows what level of transpiling is needed. Because maybe, for example, your internal corporate portal is ran by Chrome users only. Or, for example, you can't sort out IE flexbox bugs and block it completely.

For example, .babelrc would have settings for babel-preset-env:

{
  "presets": [
    ["env", {
      "targets": {
        "browsers": ["last 2 versions"]
      }
    }]
  ]
}

Now, I see we set the Babel settings in rollup.config.js:

UMD settings part:

{
        entry: 'src/main.js',
        dest: pkg.browser,
        format: 'umd',
        moduleName: 'howLongUntilLunch',
        plugins: [
            resolve(), // so Rollup can find `ms`
            commonjs(), // so Rollup can convert `ms` to an ES module
            babel({
                exclude: ['node_modules/**']
            })
        ]
    }

My question: why does babel-preset-env have no settings in UMD part for the target environment? Is it because we want to make the module the most universal and therefore we apply the maximum transpiling?

hsingh23 commented 6 years ago

image https://github.com/rollup/rollup-plugin-babel#usage

revelt commented 6 years ago

Hi Harsh, thanks for the link, it still does not answer my question though...

Why does babel-preset-env have no settings (I'm talking about UMD part) for the target environment?

revelt commented 6 years ago

OK, I got what you're saying, it comes from .babelrc in the root. OK.

Will close now. Thanks!