Skip to content

Commit

Permalink
fix: support cjs
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrywu committed Aug 9, 2023
1 parent 4646b23 commit 95e2834
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 32 deletions.
69 changes: 43 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,27 @@
"license": "MIT",
"author": "jerrywu001 <57242263@163.com>",
"main": "./dist/index.js",
"module": "./dist/esm/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"typings": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"./*": [
"./*",
"./*.d.ts"
]
},
"typesVersions": {
"*": {
"*": [
"./dist/*",
"./*"
]
}
},
"files": [
"dist",
"package.json",
Expand All @@ -47,42 +65,42 @@
"typecheck": "tsc && vue-tsc"
},
"devDependencies": {
"@babel/core": "^7.22.5",
"@babel/plugin-transform-runtime": "^7.22.5",
"@babel/plugin-transform-typescript": "^7.22.5",
"@babel/preset-env": "^7.22.5",
"@babel/core": "^7.22.10",
"@babel/plugin-transform-runtime": "^7.22.10",
"@babel/plugin-transform-typescript": "^7.22.10",
"@babel/preset-env": "^7.22.10",
"@babel/preset-typescript": "^7.22.5",
"@commitlint/cli": "^17.6.6",
"@commitlint/config-conventional": "^17.6.6",
"@swc/core": "^1.3.67",
"@testing-library/jest-dom": "^5.16.5",
"@typescript-eslint/eslint-plugin": "^5.60.1",
"@typescript-eslint/parser": "^5.60.1",
"@commitlint/cli": "^17.6.7",
"@commitlint/config-conventional": "^17.6.7",
"@swc/core": "^1.3.75",
"@testing-library/jest-dom": "^5.17.0",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"@vitejs/plugin-vue": "^4.2.3",
"@vitest/ui": "^0.32.2",
"@vitest/ui": "^0.34.1",
"@vue/babel-plugin-jsx": "^1.1.5",
"@vue/eslint-config-typescript": "^11.0.3",
"autoprefixer": "^10.4.14",
"babel-loader": "^9.1.2",
"babel-loader": "^9.1.3",
"bumpp": "^9.1.1",
"core-js": "^3.31.0",
"core-js": "^3.32.0",
"esbuild-plugin-babel": "^0.2.3",
"eslint": "^8.44.0",
"eslint": "^8.46.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint-plugin-import": "^2.27.5",
"eslint-config-airbnb-typescript": "^17.1.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-vue": "^9.15.1",
"eslint-plugin-vue": "^9.16.1",
"husky": "^8.0.3",
"jsdom": "^22.1.0",
"lint-staged": "^13.2.3",
"npm": "^9.7.2",
"npm": "^9.8.1",
"rimraf": "^5.0.1",
"tsup": "^7.1.0",
"tsup": "^7.2.0",
"typescript": "^5.1.6",
"vite": "^4.1.5",
"vitest": "^0.32.2",
"vue-tsc": "^1.8.3"
"vite": "^4.4.9",
"vitest": "^0.34.1",
"vue-tsc": "^1.8.8"
},
"peerDependencies": {
"vue": "^3.2.0"
Expand All @@ -93,7 +111,6 @@
}
},
"engines": {
"node": ">=16",
"npm": ">=7"
"node": ">=16"
}
}
1 change: 0 additions & 1 deletion playground/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"skipLibCheck": true,
"strictNullChecks": true,
"esModuleInterop": true,
"suppressImplicitAnyIndexErrors": true,
"allowSyntheticDefaultImports": true,
"noEmit": true,
"strict": true,
Expand Down
2 changes: 1 addition & 1 deletion playground/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default defineConfig({
alias: {
'@/': `${path.resolve(__dirname, 'src')}/`,
'#/': `${path.resolve(__dirname, '../dist')}/`,
'string-to-file': path.resolve(__dirname, process.env.USEPACK === 'true' ? '../dist/esm' : '../src'),
'string-to-file': path.resolve(__dirname, process.env.USEPACK === 'true' ? '../dist' : '../src'),
},
},
build: {
Expand Down
7 changes: 6 additions & 1 deletion tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ export default defineConfig({
entry: [
'./src/index.ts',
],
outExtension({ format }) {
const extension = format === 'esm' ? '.mjs' : '.js';
return {
js: extension,
};
},
target: 'es6',
format: [
'cjs',
Expand All @@ -18,7 +24,6 @@ export default defineConfig({
clean: true,
dts: './src/index.ts',
// sourcemap: true,
legacyOutput: true,
splitting: false,
minify: true,
esbuildPlugins: [
Expand Down
3 changes: 0 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,5 @@ export default defineConfig({
globals: true,
environment: 'jsdom',
setupFiles: ['./setupTests.ts'],
transformMode: {
web: [/.[tj]sx$/],
},
},
});

0 comments on commit 95e2834

Please sign in to comment.