From 59ab559386273a185be18857a12ab0305b753e50 Mon Sep 17 00:00:00 2001 From: Daniel Lopretto Date: Wed, 16 Dec 2020 03:25:06 -0500 Subject: [PATCH] Update dev dependencies (#3401) - Everything still works as expected. - Remove bundlesize - It still uses libtorb which is deprecated and broken on Win and requires a full suite of build tools on Mac. Keeping it in the package makes it difficult for anyone filing issues to run tests. - See: #3396 - Update grunt and it's plugins - Update karma to v4...so much faster! - Changed the karma config. Better changes: #3394 - Update Webpack - Uses terser over uglify - Update eslint - Caused an error in util.js from the `global` directive so the directive is removed (it was not needed). - Update typescript - The old version of tsc didn't know about new features in @types/node (like `asserts value`). Co-authored-by: Jay --- karma.conf.js | 46 ++++++++++++++++------------------------------ lib/utils.js | 2 -- package.json | 33 +++++++++++++++------------------ webpack.config.js | 25 +++++-------------------- 4 files changed, 36 insertions(+), 70 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 5525421d0d..5bd7760af5 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -15,10 +15,11 @@ function createCustomLauncher(browser, version, platform) { module.exports = function(config) { var customLaunchers = {}; var browsers = []; + var sauceLabs; if (process.env.SAUCE_USERNAME || process.env.SAUCE_ACCESS_KEY) { customLaunchers = {}; - + var runAll = true; var options = [ 'SAUCE_CHROME', @@ -107,6 +108,15 @@ module.exports = function(config) { } browsers = Object.keys(customLaunchers); + + sauceLabs = { + recordScreenshots: false, + connectOptions: { + // port: 5757, + logfile: 'sauce_connect.log' + }, + public: 'public' + }; } else if (process.env.TRAVIS_PULL_REQUEST && process.env.TRAVIS_PULL_REQUEST !== 'false') { console.log( 'Cannot run on Sauce Labs as encrypted environment variables are not available to PRs. ' + @@ -115,9 +125,9 @@ module.exports = function(config) { browsers = ['Firefox']; } else { console.log('Running locally since SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables are not set.'); - browsers = ['Firefox', 'Chrome', 'Safari', 'Opera']; + browsers = ['Firefox', 'Chrome']; } - + config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) basePath: '', @@ -154,7 +164,7 @@ module.exports = function(config) { // available reporters: https://npmjs.org/browse/keyword/karma-reporter // Disable code coverage, as it's breaking CI: // reporters: ['dots', 'coverage', 'saucelabs'], - reporters: ['dots', 'saucelabs'], + reporters: ['progress'], // web server port @@ -192,28 +202,14 @@ module.exports = function(config) { // Webpack config webpack: { + mode: 'development', cache: true, devtool: 'inline-source-map', - // Disable code coverage, as it's breaking CI - // module: { - // postLoaders: [ - // { - // test: /\.js$/, - // exclude: /(node_modules|test)/, - // loader: 'istanbul-instrumenter' - // } - // ] - // }, externals: [ { './adapters/http': 'var undefined' } ], - plugins: [ - new webpack.DefinePlugin({ - 'process.env.NODE_ENV': JSON.stringify('test') - }) - ] }, webpackServer: { @@ -230,17 +226,7 @@ module.exports = function(config) { subdir: '.' }, - - // SauceLabs config - sauceLabs: { - recordScreenshots: false, - connectOptions: { - // port: 5757, - logfile: 'sauce_connect.log' - }, - public: 'public' - }, - + sauceLabs: sauceLabs, customLaunchers: customLaunchers }); }; diff --git a/lib/utils.js b/lib/utils.js index 83eb1c6282..28ccfff3c0 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -2,8 +2,6 @@ var bind = require('./helpers/bind'); -/*global toString:true*/ - // utils is a library of generic helper functions non-specific to axios var toString = Object.prototype.toString; diff --git a/package.json b/package.json index f3e412d7e7..90702ccd64 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Promise based HTTP client for the browser and node.js", "main": "index.js", "scripts": { - "test": "grunt test && bundlesize", + "test": "grunt test", "start": "node ./sandbox/server.js", "build": "NODE_ENV=production grunt build", "preversion": "npm test", @@ -32,41 +32,38 @@ }, "homepage": "https://github.com/axios/axios", "devDependencies": { - "bundlesize": "^0.17.0", "coveralls": "^3.0.0", "es6-promise": "^4.2.4", - "grunt": "^1.0.2", + "grunt": "^1.3.0", "grunt-banner": "^0.6.0", "grunt-cli": "^1.2.0", "grunt-contrib-clean": "^1.1.0", "grunt-contrib-watch": "^1.0.0", - "grunt-eslint": "^20.1.0", - "grunt-karma": "^2.0.0", + "grunt-eslint": "^23.0.0", + "grunt-karma": "^4.0.0", "grunt-mocha-test": "^0.13.3", "grunt-ts": "^6.0.0-beta.19", - "grunt-webpack": "^1.0.18", + "grunt-webpack": "^4.0.2", "istanbul-instrumenter-loader": "^1.0.0", "jasmine-core": "^2.4.1", - "karma": "^1.3.0", - "karma-chrome-launcher": "^2.2.0", - "karma-coverage": "^1.1.1", - "karma-firefox-launcher": "^1.1.0", + "karma": "^5.2.3", + "karma-chrome-launcher": "^3.1.0", + "karma-firefox-launcher": "^2.1.0", "karma-jasmine": "^1.1.1", "karma-jasmine-ajax": "^0.1.13", - "karma-opera-launcher": "^1.0.0", "karma-safari-launcher": "^1.0.0", - "karma-sauce-launcher": "^1.2.0", "karma-sinon": "^1.0.5", - "karma-sourcemap-loader": "^0.3.7", - "karma-webpack": "^1.7.0", + "karma-sourcemap-loader": "^0.3.8", + "karma-webpack": "^4.0.2", "load-grunt-tasks": "^3.5.2", "minimist": "^1.2.0", - "mocha": "^5.2.0", + "mocha": "^8.2.1", "sinon": "^4.5.0", - "typescript": "^2.8.1", + "terser-webpack-plugin": "^4.2.3", + "typescript": "^4.0.5", "url-search-params": "^0.10.0", - "webpack": "^1.13.1", - "webpack-dev-server": "^1.14.1" + "webpack": "^4.44.2", + "webpack-dev-server": "^3.11.0" }, "browser": { "./lib/adapters/http.js": "./lib/adapters/xhr.js" diff --git a/webpack.config.js b/webpack.config.js index 1a3e5b5317..9dba880a72 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,12 +1,13 @@ +const TerserPlugin = require('terser-webpack-plugin'); var webpack = require('webpack'); var config = {}; function generateConfig(name) { - var uglify = name.indexOf('min') > -1; + var compress = name.indexOf('min') > -1; var config = { entry: './index.js', output: { - path: 'dist/', + path: __dirname + '/dist/', filename: name + '.js', sourceMapFilename: name + '.map', library: 'axios', @@ -15,25 +16,9 @@ function generateConfig(name) { node: { process: false }, - devtool: 'source-map' + devtool: 'source-map', + mode: compress ? 'production' : 'development' }; - - config.plugins = [ - new webpack.DefinePlugin({ - 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) - }) - ]; - - if (uglify) { - config.plugins.push( - new webpack.optimize.UglifyJsPlugin({ - compressor: { - warnings: false - } - }) - ); - } - return config; }