Skip to content
This repository was archived by the owner on Mar 16, 2025. It is now read-only.

Commit 9d207cb

Browse files
committed
Generate type definitions with @proc7ts/rollup-plugin-flat-dts
1 parent f3f4425 commit 9d207cb

11 files changed

Lines changed: 36 additions & 34 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ package-lock.json
2828
/dist
2929

3030
# Type definitions
31-
/d.ts
31+
*.d.ts
32+
*.d.ts.map

.npmignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,5 @@ node_modules
3333
!/dist
3434

3535
# Include type definitions
36-
!/d.ts
37-
# ...but exclude implementations
38-
/d.ts/**/impl
39-
/d.ts/**/*.impl.*
36+
!*.d.ts
37+
!*.d.ts.map

core/index.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"main": "../dist/hatsy.core.cjs",
33
"module": "../dist/hatsy.core.js",
4-
"types": "index.d.ts"
4+
"types": "./index.d.ts"
55
}

index.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
"url": "https://github.com/hatsyjs/hatsy/issues"
2525
},
2626
"type": "module",
27-
"main": "dist/hatsy.cjs",
28-
"module": "dist/hatsy.js",
29-
"types": "index.d.ts",
27+
"main": "./dist/hatsy.cjs",
28+
"module": "./dist/hatsy.js",
29+
"types": "./index.d.ts",
3030
"exports": {
3131
".": {
3232
"import": "./dist/hatsy.js",
@@ -51,8 +51,8 @@
5151
}
5252
},
5353
"dependencies": {
54-
"@hatsy/hten": "^1.1.1",
55-
"@hatsy/http-header-value": "^3.5.1",
54+
"@hatsy/hten": "^1.1.2",
55+
"@hatsy/http-header-value": "^3.5.2",
5656
"@proc7ts/primitives": "^1.5.1"
5757
},
5858
"engines": {
@@ -61,6 +61,7 @@
6161
"devDependencies": {
6262
"@proc7ts/eslint-config": "^2.0.5",
6363
"@proc7ts/rollup-helpers": "^1.1.1",
64+
"@proc7ts/rollup-plugin-flat-dts": "^1.1.0",
6465
"@rollup/plugin-commonjs": "^16.0.0",
6566
"@rollup/plugin-node-resolve": "^10.0.0",
6667
"@types/jest": "^26.0.15",
@@ -88,7 +89,7 @@
8889
"all": "run-z build,lint,test",
8990
"build": "run-z +z --then rollup --config ./rollup.config.js",
9091
"ci:all": "run-z all +test/--ci/--runInBand",
91-
"clean": "run-z +z --then shx rm -rf d.ts dist target",
92+
"clean": "run-z +z --then shx rm -rf index.d.ts '*/index.d.ts' dist target",
9293
"doc": "run-z +z --then typedoc",
9394
"doc:publish": "run-z doc --then gh-pages --dist target/typedoc --dotfiles",
9495
"lint": "run-z +z --then eslint . --ext .js,.ts",

rollup.config.js

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { externalModules } from '@proc7ts/rollup-helpers';
2+
import flatDts from '@proc7ts/rollup-plugin-flat-dts';
23
import commonjs from '@rollup/plugin-commonjs';
34
import nodeResolve from '@rollup/plugin-node-resolve';
45
import path from 'path';
@@ -19,40 +20,51 @@ export default {
1920
typescript,
2021
tsconfig: 'tsconfig.main.json',
2122
cacheRoot: 'target/.rts2_cache',
22-
useTsconfigDeclarationDir: true,
2323
}),
2424
nodeResolve(),
2525
sourcemaps(),
2626
],
2727
external: externalModules(),
2828
manualChunks(id) {
29-
if (id.startsWith(path.join(__dirname, 'src', 'testing') + path.sep)) {
29+
if (id.startsWith(path.resolve('src', 'testing') + path.sep)) {
3030
return 'hatsy.testing';
3131
}
32-
if (id.startsWith(path.join(__dirname, 'src', 'core') + path.sep)) {
32+
if (id.startsWith(path.resolve('src', 'core') + path.sep)) {
3333
return 'hatsy.core';
3434
}
35-
if (id.startsWith(path.join(__dirname, 'src', 'impl') + path.sep)) {
35+
if (id.startsWith(path.resolve('src', 'impl') + path.sep)) {
3636
return 'hatsy.impl';
3737
}
3838
return 'hatsy';
3939
},
4040
output: [
4141
{
42+
dir: 'dist',
4243
format: 'cjs',
4344
sourcemap: true,
44-
dir: './dist',
4545
entryFileNames: '[name].cjs',
46-
chunkFileNames: `_[name].cjs`,
47-
hoistTransitiveImports: false,
46+
chunkFileNames: '_[name].cjs',
4847
},
4948
{
49+
dir: '.',
5050
format: 'esm',
5151
sourcemap: true,
52-
dir: './dist',
53-
entryFileNames: '[name].js',
54-
chunkFileNames: `_[name].js`,
55-
hoistTransitiveImports: false,
52+
entryFileNames: 'dist/[name].js',
53+
chunkFileNames: 'dist/_[name].js',
54+
plugins: [
55+
flatDts({
56+
tsconfig: 'tsconfig.main.json',
57+
lib: true,
58+
entries: {
59+
core: {
60+
file: 'core/index.d.ts',
61+
},
62+
testing: {
63+
file: 'testing/index.d.ts',
64+
},
65+
},
66+
}),
67+
],
5668
},
5769
],
5870
};

testing/index.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

testing/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"main": "../dist/hatsy.testing.cjs",
33
"module": "../dist/hatsy.testing.js",
4-
"types": "index.d.ts"
4+
"types": "./index.d.ts"
55
}

tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"forceConsistentCasingInFileNames": true,
1212
"importsNotUsedAsValues": "error",
1313
"importHelpers": true,
14-
"isolatedModules": true,
1514
"noEmitHelpers": true,
1615
"lib": [
1716
"DOM",

0 commit comments

Comments
 (0)