axios-shadow
A wrapper for axios to code splitting.
Installation
npm i axios-shadow
Usage
Init with a splitting axios
With dynamic imports we can split axios
from the main bundle.
import axios from 'axios-shadow';
axios.getModule = () => import('axios');
axios.getInstance = () => import('axios').then(({default: axios}) => {
axios.defaults.baseURL = 'https://api.example.com';
return axios;
});
Use a shadow instance
import {create} from 'axios-shadow';
const axios = create();
axios.getInstance = () => import('axios').then(m => m.default.create());
export default axios;
Use axios shadow for request
import axios from 'axios-shadow';
import axios from './axios';
axios(url).then(response => {});
axios.get(url).then(response => {});
Compatibility Note
This lib support these browsers or devices with these methods or APIs pollyfilled.
Workflow
npm start
npm run build
npm test
npm run commit
npm publish