title: Creating a library with webpack/babel 7, and getting Module build failed: Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.0". upon import
body: <p>I'm trying to build a library using webpack 4/babel 7, I'm able to export everything properly to a new create-react-app as it uses babel 7.
  But when I'm importing the library to a repository that uses babel 6 I get this </p>
  
  <h2>error</h2>
  
  <p>"Module build failed: Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.0". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel.
      at Array.map ()"</p>
  
  <p>Is there a way to make this work without having the proper babel version for the project that will be importing specific utils from this library?</p>
  
  <p>Shouldn't the build process use babel7 to compile everything so the importing library can use it even with other versions of babel?  </p>
  
  <h2>webpack.config.js</h2>
  
  <pre><code>const path = require("path");
  
  module.exports = {
    entry: "./src/index.js",
    module: {
      rules: [
        {
          test: /\.(js|jsx)$/,
          exclude: /node_modules/,
          use: {
            loader: "babel-loader",
          },
        },
      ],
    },
    output: {
      path: path.resolve(__dirname, "dist"),
      filename: "Utils.js",
      library: "Utils",
      libraryTarget: "umd",
    },
    target: "node",
    externals: {},
  };
  </code></pre>
  
  <h2>.babelrc</h2>
  
  <pre><code>{
    "presets": ["@babel/preset-env", "@babel/preset-react"],
    "plugins": ["@babel/plugin-proposal-class-properties"]
  }
  </code></pre>
  
  <h2>dev dependencies of the library</h2>
  
  <pre><code>  "devDependencies": {
      "@babel/core": "^7.2.2",
      "@babel/plugin-proposal-class-properties": "^7.2.3",
      "@babel/preset-env": "^7.2.3",
      "@babel/preset-react": "^7.0.0",
      "babel-eslint": "^10.0.1",
      "babel-loader": "^8.0.4",
  </code></pre>