Skip to content

Commit b198da0

Browse files
committed
chore: pkg type module and add umd lib
1 parent 946b974 commit b198da0

File tree

3 files changed

+58
-7
lines changed

3 files changed

+58
-7
lines changed

.npmignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
.DS_Store
55

6-
/dist
76
/src
87
tests
98
coverage

package.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22
"name": "@axios-use/vue",
33
"version": "0.2.1",
44
"description": "A Vue composition utilities for Axios.",
5-
"main": "lib/index.js",
5+
"type": "module",
6+
"main": "lib/index.cjs",
67
"module": "esm/index.js",
78
"types": "lib/index.d.ts",
9+
"unpkg": "dist/axios-use-vue.umd.js",
810
"scripts": {
9-
"build": "rm -rf ./lib/* ./esm/* && yarn build:cjs && yarn build:es",
10-
"build:cjs": "tsc",
11-
"build:es": "tsc -m ESNext --outDir ./esm",
11+
"build": "rimraf lib esm dist; npm run build:js; npm run build:type",
12+
"build:js": "vite build",
13+
"build:type": "tsc --outDir ./esm --emitDeclarationOnly",
1214
"test": "vitest",
1315
"test:coverage": "vitest run --coverage",
1416
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --ignore-path .gitignore",
15-
"lint:fix": "yarn lint --fix",
17+
"lint:fix": "npm run lint --fix",
1618
"format": "prettier --write '**/*' --config ./.prettierrc",
1719
"postinstall": "node ./demi/postinstall.js",
18-
"prepare": "yarn build"
20+
"prepare": "npm run build"
1921
},
2022
"author": "wangcch <[email protected]>",
2123
"license": "MIT",
@@ -39,6 +41,7 @@
3941
},
4042
"devDependencies": {
4143
"@rushstack/eslint-patch": "^1.2.0",
44+
"@vitejs/plugin-vue": "^4.4.1",
4245
"@vitest/coverage-c8": "^0.29.8",
4346
"@vue/compiler-dom": "^3.2.47",
4447
"@vue/eslint-config-prettier": "^7.1.0",
@@ -51,7 +54,9 @@
5154
"jsdom": "^21.1.1",
5255
"msw": "^1.1.0",
5356
"prettier": "^2.8.4",
57+
"rimraf": "^5.0.5",
5458
"typescript": "^4.9.5",
59+
"vite": "^4.5.0",
5560
"vitest": "^0.29.8",
5661
"vue": "^3.2.47",
5762
"vue2": "npm:[email protected]"

vite.config.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { resolve } from "path";
2+
3+
import { defineConfig } from "vite";
4+
import vue from "@vitejs/plugin-vue";
5+
6+
const externals = {
7+
vue: "Vue",
8+
axios: "Axios",
9+
};
10+
11+
// https://vitejs.dev/config/
12+
export default defineConfig({
13+
plugins: [vue()],
14+
build: {
15+
emptyOutDir: false,
16+
target: ["es2015"],
17+
lib: {
18+
entry: {
19+
index: resolve(__dirname, "src/index.ts"),
20+
},
21+
},
22+
rollupOptions: {
23+
external: Object.keys(externals),
24+
output: [
25+
{
26+
format: "cjs",
27+
dir: "lib",
28+
preserveModules: true,
29+
},
30+
{
31+
format: "es",
32+
dir: "esm",
33+
preserveModules: true,
34+
},
35+
{
36+
globals: externals,
37+
format: "umd",
38+
dir: "dist",
39+
name: "AxiosUseVue",
40+
preserveModules: false,
41+
entryFileNames: "axios-use-vue.umd.js",
42+
sourcemap: true,
43+
},
44+
],
45+
},
46+
},
47+
});

0 commit comments

Comments
 (0)