Skip to content

Commit

Permalink
refactor: extract only module
Browse files Browse the repository at this point in the history
  • Loading branch information
JB AUBREE committed Oct 19, 2024
1 parent 31df62e commit 7a67608
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 51 deletions.
4 changes: 1 addition & 3 deletions build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ export default defineBuildConfig({
entries: [
'src/index',
],
declaration: true,
declaration: 'node16',
clean: true,
externals: require('./constants.ts').EXTERNAL_LIBRARIES,
rollup: {
esbuild: {
minify: true,
},
emitCJS: true,
},
})
9 changes: 0 additions & 9 deletions constants.ts

This file was deleted.

25 changes: 14 additions & 11 deletions dts.config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
const DEFAULT_CONFIG = {
filePath: './dist/index.d.ts',
noCheck: true,
libraries: {
inlinedLibraries: require('./constants.ts').EXTERNAL_LIBRARIES,
},
}

const config = {
compilationOptions: {
preferredConfigPath: './tsconfig.json',
},
entries: [
{ ...DEFAULT_CONFIG, outFile: './dist/index.d.ts' },
{ ...DEFAULT_CONFIG, outFile: './dist/index.d.mts' },
{ ...DEFAULT_CONFIG, outFile: './dist/index.d.cts' },
{
filePath: './dist/index.mts',
noCheck: true,
libraries: {
inlinedLibraries: [
'joi',
'superstruct',
'valibot',
'yup',
'zod',
],
},
outFile: './dist/index.d.mts',
},
],
}

Expand Down
40 changes: 28 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,18 @@
"sideEffects": false,
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
"types": "./dist/index.d.mts",
"import": "./dist/index.mjs"
}
},
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"types": "./dist/index.d.mts",
"typesVersions": {
"*": {
"*": [
"./dist/*",
"./dist/index.d.ts"
"./dist/index.d.mts"
]
}
},
Expand All @@ -48,7 +47,29 @@
"prepare": "simple-git-hooks"
},
"peerDependencies": {
"vue": "^3.5.12"
"joi": "^17.13.3",
"superstruct": "^2.0.2",
"valibot": "^0.42.1",
"vue": "^3.5.12",
"yup": "^1.4.0",
"zod": "^3.23.8"
},
"peerDependenciesMeta": {
"joi": {
"optional": true
},
"superstruct": {
"optional": true
},
"valibot": {
"optional": true
},
"yup": {
"optional": true
},
"zod": {
"optional": true
}
},
"devDependencies": {
"@antfu/eslint-config": "^3.7.3",
Expand All @@ -61,18 +82,13 @@
"eslint": "^9.12.0",
"esno": "^4.8.0",
"happy-dom": "^15.7.4",
"joi": "^17.13.3",
"lint-staged": "^15.2.10",
"pnpm": "^9.12.1",
"simple-git-hooks": "^2.11.1",
"superstruct": "^2.0.2",
"typescript": "^5.6.3",
"unbuild": "^2.0.0",
"valibot": "^0.42.1",
"vite": "^5.4.9",
"vitest": "^2.1.3",
"yup": "^1.4.0",
"zod": "^3.23.8"
"vitest": "^2.1.3"
},
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged"
Expand Down
30 changes: 15 additions & 15 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ export default defineConfig({
test: {
environment: 'happy-dom',
coverage: {
exclude: [
'coverage/**',
'dist/**',
'**\/*.d.ts',
'test?(s)/**',
'**/*.config.?(c|m)[jt]s?(x)',
],
enabled: true,
reporter: ['json-summary'],
reporter: ['json-summary', 'text'],
},
},
})

0 comments on commit 7a67608

Please sign in to comment.