title: Dynamically import webpack in Node.js
body: <p>I´m trying to dynamically import webpack in Node.js</p>
  
  <pre><code>if (condition) {
    import('webpack').then(webpack =&gt; webpack);
  }
  </code></pre>
  
  <p>However in my terminal I see the following error:</p>
  
  <pre><code>    C:\Users\myUser\react\node_modules\@babel\core\lib\transformation\normalize-file.js:209
          throw err;
          ^
  
      SyntaxError: C:\Users\myUser\react\server\index.js: Support for the experimental syntax 'dynamicImport' isn't currently enabled (23:3):
  
  
        19 |
        20 | if (condition) {
      &gt; 21 |   import('webpack').then(webpack =&gt; webpack);
           |   ^
        22 |
  
  Add @babel/plugin-syntax-dynamic-import (https://git.io/vb4Sv) to the 'plugins' section of your Babel config to enable parsing.
  </code></pre>
  
  <p>I have @babel/plugin-syntax-dynamic-import installed and in my .babelrc</p>
  
  <pre><code>{
    "presets": ["@babel/preset-env", "@babel/preset-react"],
    "plugins": [
      "@babel/plugin-syntax-dynamic-import",
      "@babel/plugin-proposal-class-properties"
    ]
  }
  </code></pre>
  
  <p>I even tried to add it to the webpack conf file under the rule for .js with loader "babel-loader".</p>
  
  <p>I´m trying to avoid CmJS</p>
  
  <pre><code>const webpack = require('webpack');
  </code></pre>
  
  <p>In any case I receive the same error and I cannot find a solution. Did anyone go through this? Thanks</p>