diff --git a/package.json b/package.json index c1ef25f5a0d..07a12430187 100644 --- a/package.json +++ b/package.json @@ -34,10 +34,12 @@ "sliced": "1.0.1" }, "devDependencies": { + "acorn": "5.7.3", "acquit": "1.0.0", "acquit-ignore": "0.1.0", "acquit-require": "0.1.1", "babel-loader": "7.1.4", + "babel-preset-es2015": "6.24.1", "benchmark": "2.1.2", "bluebird": "3.5.0", "chalk": "^2.4.1", diff --git a/test/webpack.test.js b/test/webpack.test.js index 1d312c811cb..ca999a5dd76 100644 --- a/test/webpack.test.js +++ b/test/webpack.test.js @@ -1,6 +1,9 @@ 'use strict'; +const acorn = require('acorn'); const assert = require('assert'); +const fs = require('fs'); +const path = require('path'); const utils = require('../lib/utils'); const semver = require('semver'); @@ -27,8 +30,14 @@ describe('webpack', function() { rules: [ { test: /\.js$/, - exclude: /node_modules/i, - loader: 'babel-loader' + include: [ + /\/mongoose\//i, + /\/kareem\//i + ], + loader: 'babel-loader', + options: { + presets: ['es2015'] + } } ] }, @@ -49,9 +58,15 @@ describe('webpack', function() { webpack(config, utils.tick(function(error, stats) { assert.ifError(error); assert.deepEqual(stats.compilation.errors, []); + // Avoid expressions in `require()` because that scares webpack (gh-6705) assert.ok(!stats.compilation.warnings. find(msg => msg.toString().startsWith('ModuleDependencyWarning:'))); + + const content = fs.readFileSync(`${__dirname}/files/main.js`, 'utf8'); + + acorn.parse(content, { ecmaVersion: 5 }); + done(); })); // acquit:ignore:end