Skip to content

Commit

Permalink
docs(webpack): make webpack docs use es2015 preset for correct libs a…
Browse files Browse the repository at this point in the history
…nd use acorn to test output is valid ES5

Fix #6740
  • Loading branch information
vkarpov15 committed Sep 13, 2018
1 parent 25c305d commit bdd7432
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -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",
Expand Down
19 changes: 17 additions & 2 deletions 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');

Expand All @@ -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']
}
}
]
},
Expand All @@ -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
Expand Down

0 comments on commit bdd7432

Please sign in to comment.