2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-20 20:00:40 +03:00

Replaced webpack with rollup; (#4596)

Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
Dmitriy Mozgovoy
2022-05-03 19:53:02 +03:00
committed by GitHub
parent a41f129acf
commit fe2563060d
3 changed files with 75 additions and 15 deletions
+7 -15
View File
@@ -29,18 +29,6 @@ module.exports = function(grunt) {
all: {} all: {}
}, },
usebanner: {
all: {
options: {
banner: '<%= meta.banner %>',
linebreak: false
},
files: {
src: ['dist/*.js']
}
}
},
eslint: { eslint: {
target: ['lib/**/*.js'] target: ['lib/**/*.js']
}, },
@@ -77,7 +65,11 @@ module.exports = function(grunt) {
} }
}, },
webpack: require('./webpack.config.js') shell: {
rollup: {
command: 'rollup -c -m'
}
}
}); });
grunt.registerMultiTask('package2bower', 'Sync package.json to bower.json', function() { grunt.registerMultiTask('package2bower', 'Sync package.json to bower.json', function() {
@@ -104,6 +96,6 @@ module.exports = function(grunt) {
}); });
grunt.registerTask('test', 'Run the jasmine and mocha tests', ['eslint', 'mochaTest', 'karma:single']); grunt.registerTask('test', 'Run the jasmine and mocha tests', ['eslint', 'mochaTest', 'karma:single']);
grunt.registerTask('build', 'Run webpack and bundle the source', ['clean', 'webpack', 'usebanner']); grunt.registerTask('build', 'Run rollup and bundle the source', ['clean', 'shell:rollup']);
grunt.registerTask('version', 'Sync version info for a release', ['usebanner', 'package2bower', 'package2env']); grunt.registerTask('version', 'Sync version info for a release', ['package2bower', 'package2env']);
}; };
+8
View File
@@ -31,6 +31,11 @@
}, },
"homepage": "https://axios-http.com", "homepage": "https://axios-http.com",
"devDependencies": { "devDependencies": {
"@rollup/plugin-babel": "^5.3.0",
"@rollup/plugin-commonjs": "^15.1.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-multi-entry": "^4.0.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"abortcontroller-polyfill": "^1.7.3", "abortcontroller-polyfill": "^1.7.3",
"coveralls": "^3.1.1", "coveralls": "^3.1.1",
"dtslint": "^4.2.1", "dtslint": "^4.2.1",
@@ -44,6 +49,7 @@
"grunt-eslint": "^24.0.0", "grunt-eslint": "^24.0.0",
"grunt-karma": "^4.0.2", "grunt-karma": "^4.0.2",
"grunt-mocha-test": "^0.13.3", "grunt-mocha-test": "^0.13.3",
"grunt-shell": "^3.0.1",
"grunt-webpack": "^5.0.0", "grunt-webpack": "^5.0.0",
"istanbul-instrumenter-loader": "^3.0.1", "istanbul-instrumenter-loader": "^3.0.1",
"jasmine-core": "^2.4.1", "jasmine-core": "^2.4.1",
@@ -60,6 +66,8 @@
"load-grunt-tasks": "^5.1.0", "load-grunt-tasks": "^5.1.0",
"minimist": "^1.2.6", "minimist": "^1.2.6",
"mocha": "^8.2.1", "mocha": "^8.2.1",
"rollup": "^2.67.0",
"rollup-plugin-terser": "^7.0.2",
"sinon": "^4.5.0", "sinon": "^4.5.0",
"terser-webpack-plugin": "^4.2.3", "terser-webpack-plugin": "^4.2.3",
"typescript": "^4.6.3", "typescript": "^4.6.3",
+60
View File
@@ -0,0 +1,60 @@
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import {terser} from "rollup-plugin-terser";
import json from '@rollup/plugin-json';
const lib = require("./package.json");
const outputFileName = 'axios';
const name = "axios";
const input = './lib/axios.js';
const buildConfig = (config) => {
const build = ({minified}) => ({
input,
...config,
output: {
...config.output,
file: `${config.output.file}.${minified ? "min.js" : "js"}`
},
plugins: [
json(),
resolve({browser: true}),
commonjs(),
minified && terser(),
...(config.plugins || []),
]
});
return [
build({minified: false}),
build({minified: true}),
];
};
export default async () => {
const year = new Date().getFullYear();
const banner = `// ${lib.name} v${lib.version} Copyright (c) ${year} ${lib.author}`;
return [
...buildConfig({
output: {
file: `dist/${outputFileName}`,
name,
format: "umd",
exports: "default",
banner
}
}),
...buildConfig({
output: {
file: `dist/esm/${outputFileName}`,
format: "esm",
preferConst: true,
exports: "named",
banner
}
})
]
};