-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
Use Babel 7 & Webpack3 (via blocks) #1334
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"presets": [ | ||
["@babel/preset-env", { | ||
"targets": { | ||
"node": "6.10" | ||
} | ||
}] | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ typings/ | |
coverage/ | ||
test/typescript/axios.js* | ||
sauce_connect.log | ||
dist |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
module.exports = require('./lib/axios'); | ||
module.exports = require('./dist/commonjs/axios'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,11 @@ | |
"scripts": { | ||
"test": "grunt test && bundlesize", | ||
"start": "node ./sandbox/server.js", | ||
"build": "NODE_ENV=production grunt build", | ||
"clean": "rimraf dist", | ||
"cjs": "babel lib --out-dir dist/commonjs", | ||
"browser": "NODE_ENV=production webpack", | ||
"browser:dev": "webpack", | ||
"build": "npm run clean && npm run cjs && npm run browser", | ||
"preversion": "npm test", | ||
"version": "npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json", | ||
"postversion": "git push && git push --tags", | ||
|
@@ -31,6 +35,12 @@ | |
}, | ||
"homepage": "https://github.com/axios/axios", | ||
"devDependencies": { | ||
"@babel/core": "^7.0.0-beta.39", | ||
"@babel/preset-env": "^7.0.0-beta.39", | ||
"@webpack-blocks/babel": "^1.0.0-rc", | ||
"@webpack-blocks/uglify": "^1.1.0", | ||
"@webpack-blocks/webpack": "^1.0.0-rc", | ||
"babel-cli": "^7.0.0-beta.3", | ||
"bundlesize": "^0.5.7", | ||
"coveralls": "^2.11.9", | ||
"es6-promise": "^4.0.5", | ||
|
@@ -60,19 +70,20 @@ | |
"karma-webpack": "^1.7.0", | ||
"load-grunt-tasks": "^3.5.2", | ||
"minimist": "^1.2.0", | ||
"rimraf": "^2.6.2", | ||
"sinon": "^1.17.4", | ||
"webpack": "^1.13.1", | ||
"webpack-dev-server": "^1.14.1", | ||
"url-search-params": "^0.6.1", | ||
"typescript": "^2.0.3" | ||
"webpack": "^3.10.0", | ||
"webpack-dev-server": "^1.16.5" | ||
}, | ||
"browser": { | ||
"./lib/adapters/http.js": "./lib/adapters/xhr.js" | ||
}, | ||
"typings": "./index.d.ts", | ||
"dependencies": { | ||
"follow-redirects": "^1.2.5", | ||
"is-buffer": "^1.1.5" | ||
"is-buffer": "^1.1.5", | ||
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. I don't see this used here, or was it there before ? 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. It's just the comma, as 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. In the utils for now, later on we might get rid of it when moving to lodash |
||
"pkginfo": "^0.4.1" | ||
}, | ||
"bundlesize": [ | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,56 @@ | ||
var webpack = require('webpack'); | ||
var config = {}; | ||
const { | ||
addPlugins, | ||
createConfig, | ||
defineConstants, | ||
entryPoint, | ||
env, | ||
setOutput, | ||
sourceMaps, | ||
resolve | ||
} = require('@webpack-blocks/webpack') | ||
const babel = require('@webpack-blocks/babel') | ||
const uglify = require('@webpack-blocks/uglify') | ||
|
||
function generateConfig(name) { | ||
var uglify = name.indexOf('min') > -1; | ||
var config = { | ||
entry: './index.js', | ||
output: { | ||
path: 'dist/', | ||
filename: name + '.js', | ||
sourceMapFilename: name + '.map', | ||
library: 'axios', | ||
libraryTarget: 'umd' | ||
}, | ||
node: { | ||
process: false | ||
}, | ||
devtool: 'source-map' | ||
}; | ||
const path = require('path') | ||
|
||
config.plugins = [ | ||
new webpack.DefinePlugin({ | ||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) | ||
module.exports = createConfig([ | ||
entryPoint('./lib/axios.js'), | ||
setOutput({ | ||
path: path.resolve(__dirname, 'dist/browser'), | ||
filename: 'bundle.js', | ||
library: 'axios', | ||
libraryTarget: 'var' | ||
}), | ||
defineConstants({ | ||
'process.env.NODE_ENV': process.env.NODE_ENV || 'development', | ||
'process.env.TARGET_ENV': 'browser' | ||
}), | ||
babel({ | ||
presets: [ | ||
['@babel/env', { targets: 'last 2 versions, ie 11', modules: false }] | ||
] | ||
}), | ||
env('production', [ | ||
setOutput({ | ||
filename: 'bundle.min.js' | ||
}), | ||
uglify() | ||
]), | ||
env('development', [ | ||
uglify({ | ||
uglifyOptions: { | ||
output: { | ||
beautify: false, | ||
preserve_line: true | ||
}, | ||
mangle: false | ||
} | ||
}) | ||
]; | ||
|
||
if (uglify) { | ||
config.plugins.push( | ||
new webpack.optimize.UglifyJsPlugin({ | ||
compressor: { | ||
warnings: false | ||
} | ||
}) | ||
); | ||
} | ||
|
||
return config; | ||
} | ||
|
||
['axios', 'axios.min'].forEach(function (key) { | ||
config[key] = generateConfig(key); | ||
}); | ||
|
||
module.exports = config; | ||
]), | ||
// TODO: tree shaking instead of explicit replace | ||
resolve({ | ||
alias: { | ||
'./adapters/http': path.resolve(__dirname, 'lib/adapters/xhr') | ||
} | ||
}) | ||
]) |
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.
Do we need this here?
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.
It was just wrongly sorted in the
package.json
beforehand. The dev dependency can be removed in the Karma branch, as until then the karma config has a dependency on the Webpack dev serverThere 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.
Yes to make the tests run in this PR, will get removed later on