UNPKG

@nx/webpack

Version:

The Nx Plugin for Webpack contains executors and generators that support building applications using Webpack.

35 lines (34 loc) 1.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getTerserEcmaVersion = getTerserEcmaVersion; const path = require("path"); const fs = require("fs"); const browserslist = require("browserslist"); const VALID_BROWSERSLIST_FILES = ['.browserslistrc', 'browserslist']; const ES5_BROWSERS = [ 'ie 10', 'ie 11', 'safari 11', 'safari 11.1', 'safari 12', 'safari 12.1', 'safari 13', 'ios_saf 13.0', 'ios_saf 13.3', ]; function getTerserEcmaVersion(projectRoot) { let pathToBrowserslistFile = ''; for (const browserslistFile of VALID_BROWSERSLIST_FILES) { const fullPathToFile = path.join(projectRoot, browserslistFile); if (fs.existsSync(fullPathToFile)) { pathToBrowserslistFile = fullPathToFile; break; } } if (!pathToBrowserslistFile) { return 2020; } const env = browserslist.loadConfig({ path: pathToBrowserslistFile }); const browsers = browserslist(env); return browsers.some((b) => ES5_BROWSERS.includes(b)) ? 5 : 2020; }