New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Webpack + deps, remove now unnecessary polyfills #2410
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ | |
"license": "MIT", | ||
"ignore": [ | ||
"**/.*", | ||
"*.iml", | ||
"examples", | ||
"lib", | ||
"node_modules", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,21 +3,9 @@ | |
var bind = require('./helpers/bind'); | ||
var isBuffer = require('is-buffer'); | ||
|
||
/*global toString:true*/ | ||
|
||
// utils is a library of generic helper functions non-specific to axios | ||
|
||
var toString = Object.prototype.toString; | ||
|
||
/** | ||
* Determine if a value is an Array | ||
* | ||
* @param {Object} val The value to test | ||
* @returns {boolean} True if value is an Array, otherwise false | ||
*/ | ||
function isArray(val) { | ||
return toString.call(val) === '[object Array]'; | ||
} | ||
var _toString = Object.prototype.toString; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed this to start with It also functions as a callout to potentially hacky / legacy code |
||
|
||
/** | ||
* Determine if a value is an ArrayBuffer | ||
|
@@ -26,7 +14,7 @@ function isArray(val) { | |
* @returns {boolean} True if value is an ArrayBuffer, otherwise false | ||
*/ | ||
function isArrayBuffer(val) { | ||
return toString.call(val) === '[object ArrayBuffer]'; | ||
return _toString.call(val) === '[object ArrayBuffer]'; | ||
} | ||
|
||
/** | ||
|
@@ -102,7 +90,7 @@ function isObject(val) { | |
* @returns {boolean} True if value is a Date, otherwise false | ||
*/ | ||
function isDate(val) { | ||
return toString.call(val) === '[object Date]'; | ||
return _toString.call(val) === '[object Date]'; | ||
} | ||
|
||
/** | ||
|
@@ -112,7 +100,7 @@ function isDate(val) { | |
* @returns {boolean} True if value is a File, otherwise false | ||
*/ | ||
function isFile(val) { | ||
return toString.call(val) === '[object File]'; | ||
return _toString.call(val) === '[object File]'; | ||
} | ||
|
||
/** | ||
|
@@ -122,7 +110,7 @@ function isFile(val) { | |
* @returns {boolean} True if value is a Blob, otherwise false | ||
*/ | ||
function isBlob(val) { | ||
return toString.call(val) === '[object Blob]'; | ||
return _toString.call(val) === '[object Blob]'; | ||
} | ||
|
||
/** | ||
|
@@ -132,7 +120,7 @@ function isBlob(val) { | |
* @returns {boolean} True if value is a Function, otherwise false | ||
*/ | ||
function isFunction(val) { | ||
return toString.call(val) === '[object Function]'; | ||
return _toString.call(val) === '[object Function]'; | ||
} | ||
|
||
/** | ||
|
@@ -155,16 +143,6 @@ function isURLSearchParams(val) { | |
return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams; | ||
} | ||
|
||
/** | ||
* Trim excess whitespace off the beginning and end of a string | ||
* | ||
* @param {String} str The String to trim | ||
* @returns {String} The String freed of excess whitespace | ||
*/ | ||
function trim(str) { | ||
return str.replace(/^\s*/, '').replace(/\s*$/, ''); | ||
} | ||
|
||
/** | ||
* Determine if we're running in a standard browser environment | ||
* | ||
|
@@ -216,7 +194,7 @@ function forEach(obj, fn) { | |
obj = [obj]; | ||
} | ||
|
||
if (isArray(obj)) { | ||
if (Array.isArray(obj)) { | ||
// Iterate over array values | ||
for (var i = 0, l = obj.length; i < l; i++) { | ||
fn.call(null, obj[i], i, obj); | ||
|
@@ -310,7 +288,6 @@ function extend(a, b, thisArg) { | |
} | ||
|
||
module.exports = { | ||
isArray: isArray, | ||
isArrayBuffer: isArrayBuffer, | ||
isBuffer: isBuffer, | ||
isFormData: isFormData, | ||
|
@@ -329,6 +306,5 @@ module.exports = { | |
forEach: forEach, | ||
merge: merge, | ||
deepMerge: deepMerge, | ||
extend: extend, | ||
trim: trim | ||
extend: extend | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,39 +34,37 @@ | |
"devDependencies": { | ||
"bundlesize": "^0.17.0", | ||
"coveralls": "^3.0.0", | ||
"es6-promise": "^4.2.4", | ||
"grunt": "^1.0.2", | ||
"grunt-banner": "^0.6.0", | ||
"grunt-cli": "^1.2.0", | ||
"grunt-contrib-clean": "^1.1.0", | ||
"grunt-contrib-clean": "^2.0.0", | ||
"grunt-contrib-watch": "^1.0.0", | ||
"grunt-eslint": "^20.1.0", | ||
"grunt-karma": "^2.0.0", | ||
"grunt-eslint": "^22.0.0", | ||
"grunt-karma": "^3.0.2", | ||
"grunt-mocha-test": "^0.13.3", | ||
"grunt-ts": "^6.0.0-beta.19", | ||
"grunt-webpack": "^1.0.18", | ||
"istanbul-instrumenter-loader": "^1.0.0", | ||
"grunt-webpack": "^3.1.3", | ||
"istanbul-instrumenter-loader": "^3.0.1", | ||
"jasmine-core": "^2.4.1", | ||
"karma": "^1.3.0", | ||
"karma-chrome-launcher": "^2.2.0", | ||
"karma-coverage": "^1.1.1", | ||
"karma": "^4.3.0", | ||
"karma-chrome-launcher": "^3.1.0", | ||
"karma-coverage": "^2.0.1", | ||
"karma-firefox-launcher": "^1.1.0", | ||
"karma-jasmine": "^1.1.1", | ||
"karma-jasmine": "^2.0.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-sauce-launcher": "^2.0.2", | ||
"karma-sinon": "^1.0.5", | ||
"karma-sourcemap-loader": "^0.3.7", | ||
"karma-webpack": "^1.7.0", | ||
"load-grunt-tasks": "^3.5.2", | ||
"karma-webpack": "^4.0.2", | ||
"load-grunt-tasks": "^5.1.0", | ||
"minimist": "^1.2.0", | ||
"mocha": "^5.2.0", | ||
"sinon": "^4.5.0", | ||
"mocha": "^6.2.0", | ||
"sinon": "^7.4.2", | ||
"typescript": "^2.8.1", | ||
"url-search-params": "^0.10.0", | ||
"webpack": "^1.13.1", | ||
"webpack-dev-server": "^1.14.1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only core webpack is used, so just removing the dev server dep. |
||
"webpack": "^4.40.2" | ||
}, | ||
"browser": { | ||
"./lib/adapters/http.js": "./lib/adapters/xhr.js" | ||
|
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
var webpack = require('webpack'); | ||
var config = {}; | ||
const webpack = require('webpack'); | ||
const TerserPlugin = require('terser-webpack-plugin'); | ||
const config = {}; | ||
|
||
function generateConfig(name) { | ||
var uglify = name.indexOf('min') > -1; | ||
var config = { | ||
return { | ||
mode: 'production', | ||
entry: './index.js', | ||
output: { | ||
path: 'dist/', | ||
path: `${__dirname}/dist`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. absolute path is required for webpack 4 now. per the docs, https://nodejs.org/docs/latest/api/modules.html#modules_dirname |
||
filename: name + '.js', | ||
sourceMapFilename: name + '.map', | ||
library: 'axios', | ||
|
@@ -15,30 +16,21 @@ function generateConfig(name) { | |
node: { | ||
process: false | ||
}, | ||
devtool: 'source-map' | ||
devtool: 'source-map', | ||
optimization: { | ||
minimize: name.includes('min'), | ||
minimizer: [ | ||
// config options documented at https://github.com/webpack-contrib/terser-webpack-plugin#terseroptions | ||
new TerserPlugin({ | ||
sourceMap: true, | ||
}), | ||
], | ||
}, | ||
}; | ||
|
||
config.plugins = [ | ||
new webpack.DefinePlugin({ | ||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) | ||
}) | ||
]; | ||
|
||
if (uglify) { | ||
config.plugins.push( | ||
new webpack.optimize.UglifyJsPlugin({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
per the migration guide, the plugins can simply be removed: https://webpack.js.org/migrate/4/#deprecatedremoved-plugins |
||
compressor: { | ||
warnings: false | ||
} | ||
}) | ||
); | ||
} | ||
|
||
return config; | ||
} | ||
|
||
['axios', 'axios.min'].forEach(function (key) { | ||
config[key] = generateConfig(key); | ||
['axios', 'axios.min'].forEach(outputScript => { | ||
config[outputScript] = generateConfig(outputScript); | ||
}); | ||
|
||
module.exports = config; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved lint warning about anonymous functions being banned by adding a congruent name