-
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
be9d735
commit 4734c5f
Showing
36 changed files
with
10,996 additions
and
6,015 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,7 @@ | |
/dist | ||
/types | ||
/ignore | ||
/docs | ||
/docs | ||
/esm | ||
/cjs | ||
/umd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ jobs: | |
cache: 'yarn' | ||
|
||
- name: Install packages | ||
run: yarn --prefer-offline | ||
run: yarn install | ||
|
||
- name: Lint | ||
run: yarn lint | ||
|
@@ -34,7 +34,7 @@ jobs: | |
run: yarn build | ||
|
||
- name: ESCheck | ||
run: yarn escheck | ||
run: yarn check | ||
|
||
- name: Publish to Codecov | ||
uses: codecov/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,21 @@ | ||
# Javascript | ||
coverage | ||
node_modules | ||
|
||
/umd | ||
/cjs | ||
/esm | ||
|
||
dist | ||
types | ||
ignore | ||
.vscode/settings.json | ||
package-lock.json | ||
coverage | ||
# Random | ||
/ignore | ||
*.log | ||
|
||
# Vscode | ||
.vscode/* | ||
!.vscode/launch.json | ||
|
||
# Npm & Yarn | ||
package-lock.json | ||
.yarn/* | ||
!.yarn/releases | ||
!.yarn/plugins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,8 @@ | |
!package.json | ||
!tsconfig*.json | ||
|
||
!/src/** | ||
!/dist/** | ||
!/umd/** | ||
!/cjs/** | ||
!/esm/** | ||
|
||
!/examples/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,13 @@ node_modules | |
/ignore | ||
/coverage | ||
/dist | ||
/umd | ||
/cjs | ||
/esm | ||
/types | ||
/tsconfig.json | ||
|
||
.yarn | ||
|
||
changelog.md | ||
CHANGELOG.md |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
enableGlobalCache: true | ||
|
||
nodeLinker: node-modules | ||
|
||
plugins: | ||
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs | ||
spec: '@yarnpkg/plugin-version' | ||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs | ||
spec: '@yarnpkg/plugin-interactive-tools' | ||
|
||
yarnPath: .yarn/releases/yarn-3.1.1.cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script is used to build the project. | ||
# It is intended to be run from the project's root directory. | ||
|
||
echo "\nStarting build...\n" | ||
|
||
rm -rf cjs/ esm/ umd/ | ||
|
||
echo "Target cleared...\n" | ||
|
||
webpack --config build/webpack.config.js & | ||
tsc -p build/tsconfig.cjs.json & | ||
tsc -p build/tsconfig.esm.json & | ||
|
||
wait | ||
|
||
echo "\nBuild done!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env bash | ||
|
||
# This script is used to check the umd's ecmascript compatibility. | ||
# It is intended to be run from the project's root directory. | ||
|
||
echo "\nStarting checking...\n" | ||
|
||
es-check es5 umd/es5.min.js & | ||
es-check es6 umd/es6.min.js & | ||
|
||
wait | ||
|
||
echo "\nCheck done!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"module": "CommonJS", | ||
"target": "ES2017", | ||
"outDir": "../cjs" | ||
}, | ||
"include": ["../src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"module": "ESNext", | ||
"target": "ES2017", | ||
"outDir": "../esm" | ||
}, | ||
"include": ["../src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"compilerOptions": { | ||
"module": "ESNext", // webpack converts to UMD | ||
"target": "ESNext", | ||
"outDir": "../umd", | ||
|
||
// No declaration | ||
"declaration": false, | ||
"declarationMap": false | ||
}, | ||
"include": ["../src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
//@ts-check | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
|
||
const path = require('path'); | ||
const TerserWebpackPlugin = require('terser-webpack-plugin'); | ||
|
||
const root = (...p) => path.resolve(__dirname, '..', ...p); | ||
|
||
/** | ||
* @param {{ | ||
* output: string; | ||
* entry: string; | ||
* esTarget: string; | ||
* }} options | ||
* @returns {import('webpack').Configuration} | ||
*/ | ||
const config = ({ output, esTarget, entry }) => ({ | ||
mode: 'production', | ||
|
||
entry: root('src', entry), | ||
|
||
output: { | ||
path: root(), | ||
globalObject: `typeof self === 'undefined' ? this : self`, | ||
filename: output + '.js', | ||
sourceMapFilename: output + '.map', | ||
library: { | ||
type: 'umd', | ||
name: 'AxiosCacheInterceptor' | ||
}, | ||
chunkFormat: 'module' | ||
}, | ||
|
||
target: esTarget, | ||
|
||
resolve: { | ||
extensions: ['.ts', '.js'] | ||
}, | ||
|
||
devtool: 'source-map', | ||
|
||
module: { | ||
rules: [ | ||
{ | ||
include: root('src'), | ||
test: /\.(ts|js)$/, | ||
loader: 'ts-loader', | ||
options: { | ||
configFile: root('build', 'tsconfig.umd.json'), | ||
compilerOptions: { | ||
target: esTarget | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
|
||
optimization: { | ||
minimize: true, | ||
minimizer: [new TerserWebpackPlugin({ parallel: true })] | ||
} | ||
}); | ||
|
||
module.exports = [ | ||
config({ | ||
esTarget: 'es2015', //es6 | ||
entry: 'index.ts', | ||
output: 'umd/es6.min' | ||
}), | ||
config({ | ||
esTarget: 'es5', | ||
entry: 'index.ts', | ||
output: 'umd/es5.min' | ||
}) | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/.yarn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,15 @@ yarn add axios axios-cache-interceptor | |
``` | ||
|
||
```js | ||
// CommonJS | ||
const { setupCache } = require('axios-cache-interceptor'); | ||
import { setupCache } from 'axios-cache-interceptor'; | ||
|
||
// ES Modules | ||
import { setupCache } from 'axios-cache-interceptor/esm'; | ||
|
||
// Universal | ||
const { setupCache } = require('axios-cache-interceptor/umd'); | ||
``` | ||
|
||
## With CDNs | ||
|
@@ -36,37 +43,19 @@ import { setupCache } from 'axios-cache-interceptor'; | |
const { setupCache } = window.AxiosCacheInterceptor; | ||
``` | ||
|
||
<!-- https://www.jsdelivr.com/package/npm/axios-cache-interceptor?path=dist --> | ||
|
||
```html | ||
<!-- Replace latest with the desired version --> | ||
|
||
<!-- Development for ES2020+ (~30.0KB) --> | ||
<script | ||
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.development.js" | ||
integrity="sha256-oEvQQcJv78S8QSJOY6XQ2uJ2dGwnnhAsYLDeXx0DHWA=" | ||
crossorigin="anonymous" | ||
></script> | ||
|
||
<!-- Production for ES6+ (~11.3KB) --> | ||
<script | ||
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.min.js" | ||
integrity="sha256-vtHJnEYMjzfFDDPBAic56ppjVrN6ze2qi7wXM9a/BSM=" | ||
crossorigin="anonymous" | ||
src="https://cdn.jsdelivr.net/npm/[email protected]/umd/es6.min.js" | ||
crossorigin | ||
></script> | ||
|
||
<!-- Production for ES5+ (~18.2KB) --> | ||
<!-- Production for ES5+ (~18.2KB) (Needs polyfill) --> | ||
<script | ||
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.es5.min.js" | ||
integrity="sha256-R/q1PnksvXhveo9qidplrGvGGsmFDAsal9M6bUfnNS4=" | ||
crossorigin="anonymous" | ||
></script> | ||
|
||
<!-- Production for ES2020+ (~9.2KB) --> | ||
<script | ||
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.es2020.min.js" | ||
integrity="sha256-amiYeGe9088KbQ+4xF0/9tNP+ks4Ze5LF6cZ7aiow3Q=" | ||
crossorigin="anonymous" | ||
src="https://cdn.jsdelivr.net/npm/[email protected]/umd/es5.min.js" | ||
crossorigin | ||
></script> | ||
``` | ||
|
||
|
@@ -75,7 +64,11 @@ const { setupCache } = window.AxiosCacheInterceptor; | |
You can import any [CDN Url](#with-cdns) and use it in your code. **UMD Compatible** | ||
|
||
```js | ||
import { setupCache } from 'https://cdn.jsdelivr.net/npm/[email protected]/dist/index.es2020.min.js'; | ||
// ESM with Skypack CDN (Preferred!) | ||
import { setupCache } from 'https://cdn.skypack.dev/[email protected]?dts'; | ||
|
||
// UMD bundled code | ||
import { setupCache } from 'https://cdn.jsdelivr.net/npm/[email protected]/umd/index.min.js'; | ||
``` | ||
|
||
## Support List | ||
|
Oops, something went wrong.