const { join } = require('path')
const { cache_path: cachePath } = require('../config')
const { nodeEnv } = require('../env')

// Compile standard ES features for JS in node_modules with Babel.
module.exports = {
  test: /\.(js|mjs)$/,
  exclude: /@babel(?:\/|\\{1,2})runtime/,
  use: [
    {
      loader: 'babel-loader',
      options: {
        babelrc: false,
        presets: [['@babel/preset-env', { modules: false }]],
        cacheDirectory: join(cachePath, 'babel-loader-node-modules'),
        cacheCompression: nodeEnv === 'production',
        compact: false,
        sourceMaps: false
      }
    }
  ]
}

const { join } = require('path')
const { cache_path: cachePath } = require('../config')
const { nodeEnv } = require('../env')

// Compile standard ES features for JS in node_modules with Babel.
module.exports = {
  test: /\.(js|mjs)$/,
  include: /node_modules/,
  exclude: /@babel(?:\/|\\{1,2})runtime/,
  use: [
    {
      loader: 'babel-loader',
      options: {
        babelrc: false,
        presets: [['@babel/preset-env', { modules: false }]],
        cacheDirectory: join(cachePath, 'babel-loader-node-modules'),
        cacheCompression: nodeEnv === 'production',
        compact: false,
        sourceMaps: false
      }
    }
  ]
}

Configure the nodeModules loader to do what its name suggests
Configure the nodeModules loader to do what its name suggests

Fixes #1892
Closes #1893
