update browser stuff and browser eslint (#1938)

* Update browser.js

* Update .eslintrc.json

* Update package.json

* Update package.json

* stop doing manually what webpack can do for us

* Update .eslintrc.json

* Update package.json
This commit is contained in:
Gus Caplan
2017-09-24 15:01:47 -05:00
committed by Amish Shah
parent 82841c6ce1
commit 6ce9a8743f
4 changed files with 7 additions and 16 deletions

View File

@@ -7,6 +7,9 @@
"es6": true, "es6": true,
"node": true "node": true
}, },
"overrides": [
{ "files": ["*.browser.js"], "env": { "browser": true } }
],
"rules": { "rules": {
"no-await-in-loop": "warn", "no-await-in-loop": "warn",
"no-compare-neg-zero": "error", "no-compare-neg-zero": "error",

View File

@@ -1,9 +0,0 @@
const browser = typeof window !== 'undefined';
const webpack = !!process.env.__DISCORD_WEBPACK__;
const Discord = require('./');
module.exports = Discord;
if (browser && webpack) window.Discord = Discord; // eslint-disable-line no-undef
// eslint-disable-next-line no-console
else if (!browser) console.warn('Warning: Attempting to use browser version of Discord.js in a non-browser environment!');

View File

@@ -8,7 +8,7 @@
"test": "npm run lint && npm run docs:test", "test": "npm run lint && npm run docs:test",
"docs": "docgen --source src --custom docs/index.yml --output docs/docs.json --jsdoc jsdoc.json", "docs": "docgen --source src --custom docs/index.yml --output docs/docs.json --jsdoc jsdoc.json",
"docs:test": "docgen --source src --custom docs/index.yml --jsdoc jsdoc.json", "docs:test": "docgen --source src --custom docs/index.yml --jsdoc jsdoc.json",
"lint": "eslint src", "lint": "eslint src *.js",
"lint:fix": "eslint --fix src", "lint:fix": "eslint --fix src",
"webpack": "parallel-webpack" "webpack": "parallel-webpack"
}, },

View File

@@ -12,11 +12,6 @@ const createConfig = options => {
const plugins = [ const plugins = [
new webpack.DefinePlugin({ 'global.GENTLY': false }), new webpack.DefinePlugin({ 'global.GENTLY': false }),
new webpack.optimize.ModuleConcatenationPlugin(), new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.DefinePlugin({
'process.env': {
__DISCORD_WEBPACK__: '"true"',
},
}),
]; ];
if (options.minify) { if (options.minify) {
@@ -31,10 +26,12 @@ const createConfig = options => {
const filename = `./webpack/discord${process.env.VERSIONED === 'false' ? '' : '.' + version}${options.minify ? '.min' : ''}.js`; // eslint-disable-line const filename = `./webpack/discord${process.env.VERSIONED === 'false' ? '' : '.' + version}${options.minify ? '.min' : ''}.js`; // eslint-disable-line
return { return {
entry: './browser.js', entry: './src/index.js',
output: { output: {
path: __dirname, path: __dirname,
filename, filename,
library: 'Discord',
libraryTarget: 'window',
}, },
module: { module: {
rules: [ rules: [