Issue 1:
Bug Report

Current Behavior

Currently babel-loader throws an error (look title of this issue) when the presets are defined inside Webpack configuration file.

The problem does not occurs in version 7.0.0-beta.49 of @babel/plugin-syntax-decorators and @babel/preset-env.

Babel Configuration (webpack.config.ts)

{
loader: 'babel-loader',
options: {
babelrc: false,
plugins: [
'@babel/plugin-syntax-typescript', ['@babel/plugin-syntax-decorators', {
legacy: true
}], // Without this legacy:true throws another error that the decorators are not supported yet
'@babel/plugin-syntax-jsx',
...!isProduction ? [
'react-hot-loader/babel',
] : [],
],
// works when I remove presets
presets: [
[
'@babel/preset-env',
{
targets: 'last 2 versions, ie 11',
modules: false,
},
],
],
},
},

Environment

Babel version(s): ^7.0.0-beta.51

Node/npm version: Node 10.4.1 / npm 6.1.0

OS: Windows 10

How you are using Babel: loader

Additional context/Screenshots

Hash: 8a6a420cb7f168847c34
Time: 16247ms
Built at: 06/16/2018 7:48:48 PM
2 assets
[10fb5541114836a609ce] ./index.tsx 2.08 KiB {1} [built] [failed] [1 error]
[0] multi @babel/polyfill ./index.tsx 40 bytes {1} [built]
+ 324 hidden modules

ERROR in ./index.tsx
Module build failed (from ../node_modules/babel-loader/lib/index.js):
Error: [BABEL] D:\Projects\TheAifam5-GitHub\fontcore\src\index.tsx: Invalid Option: 'l' is not a valid value for 'targets.0'. (While processing: "D:\\Projects\\TheAifam5-GitHub\\fontcore\\node_modules\\@babel\\preset-env\\lib\\index.js")
at semverifyTarget (D:\Projects\TheAifam5-GitHub\fontcore\node_modules\@babel\preset-env\lib\targets-parser.js:148:11)
at __default (D:\Projects\TheAifam5-GitHub\fontcore\node_modules\@babel\preset-env\lib\targets-parser.js:154:92)
at Object.keys.filter.sort.reduce (D:\Projects\TheAifam5-GitHub\fontcore\node_modules\@babel\preset-env\lib\targets-parser.js:195:43)
at Array.reduce (<anonymous>)
at getTargets (D:\Projects\TheAifam5-GitHub\fontcore\node_modules\@babel\preset-env\lib\targets-parser.js:183:104)
at _default (D:\Projects\TheAifam5-GitHub\fontcore\node_modules\@babel\preset-env\lib\index.js:183:46)
at D:\Projects\TheAifam5-GitHub\fontcore\node_modules\@babel\helper-plugin-utils\lib\index.js:19:12
at loadDescriptor (D:\Projects\TheAifam5-GitHub\fontcore\node_modules\@babel\core\lib\config\full.js:157:14)
at cachedFunction (D:\Projects\TheAifam5-GitHub\fontcore\node_modules\@babel\core\lib\config\caching.js:32:19)
at loadPresetDescriptor (D:\Projects\TheAifam5-GitHub\fontcore\node_modules\@babel\core\lib\config\full.js:227:63)
at config.presets.map.descriptor (D:\Projects\TheAifam5-GitHub\fontcore\node_modules\@babel\core\lib\config\full.js:72:19)
at Array.map (<anonymous>)
at recurseDescriptors (D:\Projects\TheAifam5-GitHub\fontcore\node_modules\@babel\core\lib\config\full.js:70:38)
at loadFullConfig (D:\Projects\TheAifam5-GitHub\fontcore\node_modules\@babel\core\lib\config\full.js:100:6)
at process.nextTick (D:\Projects\TheAifam5-GitHub\fontcore\node_modules\@babel\core\lib\transform.js:28:33)
at process._tickCallback (internal/process/next_tick.js:61:11)
@ multi @babel/polyfill ./index.tsx
Child html-webpack-plugin for "index.html":
1 asset
[145360749f0097b53440] ../node_modules/html-webpack-plugin/lib/loader.js!../public/index.html 571 bytes {0} [built]
+ 3 hidden modules
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Issue 2:
I've just updated to babel 7.0.0-beta.51 (from 7.0.0-beta.49) and I'm now getting an error when I try to build with webpack:

at semverifyTarget (/<SNIP>/node_modules/@babel/preset-env/lib/targets-parser.js:148:11)
...more stack trace omitted

I've traced it down to my config being:

presets: [
['@babel/preset-env', { "targets": "last 2 versions, ie 11", "modules": false }]
]

rather than:

presets: [
['@babel/preset-env', { "targets": {"browsers": "last 2 versions, ie 11"}, "modules": false }]
]

Presumably this failure is a result of the new validation introduced here: #8031 by @sun1x

Does this mean that my previous config was always invalid and was previously failing silently / being ignored, or is this a valid config that should validate correctly in the new version (ie. new version incorrectly fails on a valid config)?