From 5fdb4d3fb01b9d8a4c2dff71ed9cddb2f8feefb0 Mon Sep 17 00:00:00 2001 From: Teddy Katz Date: Fri, 15 Mar 2019 08:49:56 -0400 Subject: [PATCH] Build: compile deps to ES5 when generating browser file (fixes #11504) (#11505) * Build: compile deps to ES5 when generating browser file (fixes #11504) * Don't compile lodash --- Makefile.js | 19 ++++++++++++++++--- webpack.config.js | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Makefile.js b/Makefile.js index e2ddd2ab259..bd6f4652461 100644 --- a/Makefile.js +++ b/Makefile.js @@ -25,7 +25,8 @@ const lodash = require("lodash"), semver = require("semver"), ejs = require("ejs"), loadPerf = require("load-perf"), - yaml = require("js-yaml"); + yaml = require("js-yaml"), + CLIEngine = require("./lib/cli-engine"); const { cat, cd, cp, echo, exec, exit, find, ls, mkdir, pwd, rm, test } = require("shelljs"); @@ -440,8 +441,7 @@ function lintMarkdown(files) { * @returns {Object} Output from each formatter */ function getFormatterResults() { - const CLIEngine = require("./lib/cli-engine"), - stripAnsi = require("strip-ansi"); + const stripAnsi = require("strip-ansi"); const formatterFiles = fs.readdirSync("./lib/formatters/"), cli = new CLIEngine({ @@ -580,6 +580,19 @@ target.test = function() { target.webpack(); + const browserFileLintOutput = new CLIEngine({ + useEslintrc: false, + ignore: false, + allowInlineConfig: false, + baseConfig: { parserOptions: { ecmaVersion: 5 } } + }).executeOnFiles([`${BUILD_DIR}/eslint.js`]); + + if (browserFileLintOutput.errorCount > 0) { + echo(`error: Failed to lint ${BUILD_DIR}/eslint.js as ES5 code`); + echo(CLIEngine.getFormatter("stylish")(browserFileLintOutput.results)); + errors++; + } + lastReturn = exec(`${getBinFile("karma")} start karma.conf.js`); if (lastReturn.code !== 0) { errors++; diff --git a/webpack.config.js b/webpack.config.js index 4ba329837f4..1a6a2986a01 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -15,12 +15,12 @@ module.exports = { module: { rules: [ { - test: /\.js$/u, + test: /\.m?js$/u, loader: "babel-loader", options: { presets: ["@babel/preset-env"] }, - exclude: /node_modules/u + exclude: /node_modules\/lodash/u } ] },