<h2 dir="auto">Bug Report</h2>
<p dir="auto"><strong>Current Behavior</strong><br>
Currently babel-loader throws an error (<em>look title of this issue</em>) when the presets are defined inside Webpack configuration file.<br>
The problem does not occurs in version <code class="notranslate">7.0.0-beta.49</code> of <code class="notranslate">@babel/plugin-syntax-decorators</code> and <code class="notranslate">@babel/preset-env</code>.</p>
<p dir="auto"><strong>Babel Configuration (webpack.config.ts)</strong></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
    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,
                },
            ],
        ],
    },
},"><pre class="notranslate"><span class="pl-kos">{</span>
    <span class="pl-c1">loader</span>: <span class="pl-s">'babel-loader'</span><span class="pl-kos">,</span>
    <span class="pl-c1">options</span>: <span class="pl-kos">{</span>
        <span class="pl-c1">babelrc</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
        <span class="pl-c1">plugins</span>: <span class="pl-kos">[</span>
            <span class="pl-s">'@babel/plugin-syntax-typescript'</span><span class="pl-kos">,</span> <span class="pl-kos">[</span><span class="pl-s">'@babel/plugin-syntax-decorators'</span><span class="pl-kos">,</span> <span class="pl-kos">{</span>
                <span class="pl-c1">legacy</span>: <span class="pl-c1">true</span>
            <span class="pl-kos">}</span><span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-c">// Without this legacy:true throws another error that the decorators are not supported yet</span>
            <span class="pl-s">'@babel/plugin-syntax-jsx'</span><span class="pl-kos">,</span>
            ...<span class="pl-c1">!</span><span class="pl-s1">isProduction</span> ? <span class="pl-kos">[</span>
                <span class="pl-s">'react-hot-loader/babel'</span><span class="pl-kos">,</span>
            <span class="pl-kos">]</span> : <span class="pl-kos">[</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
        <span class="pl-kos">]</span><span class="pl-kos">,</span>
        <span class="pl-c">// works when I remove presets</span>
        <span class="pl-c1">presets</span>: <span class="pl-kos">[</span>
            <span class="pl-kos">[</span>
                <span class="pl-s">'@babel/preset-env'</span><span class="pl-kos">,</span>
                <span class="pl-kos">{</span>
                    <span class="pl-c1">targets</span>: <span class="pl-s">'last 2 versions, ie 11'</span><span class="pl-kos">,</span>
                    <span class="pl-c1">modules</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
                <span class="pl-kos">}</span><span class="pl-kos">,</span>
            <span class="pl-kos">]</span><span class="pl-kos">,</span>
        <span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span><span class="pl-kos">,</span></pre></div>
<p dir="auto"><strong>Environment</strong></p>
<ul dir="auto">
<li>Babel version(s): ^7.0.0-beta.51</li>
<li>Node/npm version: Node 10.4.1 / npm 6.1.0</li>
<li>OS: Windows 10</li>
<li>How you are using Babel: loader</li>
</ul>
<p dir="auto"><strong>Additional context/Screenshots</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    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: &quot;D:\\Projects\\TheAifam5-GitHub\\fontcore\\node_modules\\@babel\\preset-env\\lib\\index.js&quot;)
        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 (&lt;anonymous&gt;)
        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 (&lt;anonymous&gt;)
        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 &quot;index.html&quot;:
         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."><pre class="notranslate"><code class="notranslate">    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 (&lt;anonymous&gt;)
        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 (&lt;anonymous&gt;)
        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.
</code></pre></div>
<p dir="auto">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:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    at semverifyTarget (/&lt;SNIP&gt;/node_modules/@babel/preset-env/lib/targets-parser.js:148:11)
...more stack trace omitted"><pre lang="Error:" class="notranslate"><code class="notranslate">    at semverifyTarget (/&lt;SNIP&gt;/node_modules/@babel/preset-env/lib/targets-parser.js:148:11)
...more stack trace omitted
</code></pre></div>
<p dir="auto">I've traced it down to my config being:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="presets: [
    ['@babel/preset-env', { &quot;targets&quot;: &quot;last 2 versions, ie 11&quot;, &quot;modules&quot;: false }]
]"><pre class="notranslate"><code class="notranslate">presets: [
    ['@babel/preset-env', { "targets": "last 2 versions, ie 11", "modules": false }]
]
</code></pre></div>
<p dir="auto">rather than:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="presets: [
    ['@babel/preset-env', { &quot;targets&quot;: {&quot;browsers&quot;: &quot;last 2 versions, ie 11&quot;}, &quot;modules&quot;: false }]
]"><pre class="notranslate"><code class="notranslate">presets: [
    ['@babel/preset-env', { "targets": {"browsers": "last 2 versions, ie 11"}, "modules": false }]
]
</code></pre></div>
<p dir="auto">Presumably this failure is a result of the new validation introduced here: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="326167888" data-permission-text="Title is private" data-url="https://github.com/babel/babel/issues/8031" data-hovercard-type="pull_request" data-hovercard-url="/babel/babel/pull/8031/hovercard" href="https://github.com/babel/babel/pull/8031">#8031</a> by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/sun1x/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/sun1x">@sun1x</a></p>
<p dir="auto">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)?</p>