Skip to content

Commit 4bcfdb3

Browse files
committed
include bundle type definitions alongside bundles
1 parent 492633a commit 4bcfdb3

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
!package.json
55
!*.js
66
!*.js.map
7-
!*.d.ts
7+
!index.d.ts

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"parcel": "^1.12.4",
2222
"prettier": "^2.0.2",
2323
"rollup": "^1.1.0",
24+
"rollup-plugin-copy": "^3.3.0",
2425
"rollup-plugin-typescript2": "^0.26.0",
2526
"rollup-plugin-uglify": "^6.0.1",
2627
"trash-cli": "^3.0.0",

rollup.config.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,43 @@
11
import typescript from "rollup-plugin-typescript2";
22
import {uglify} from "rollup-plugin-uglify";
3+
import copy from "rollup-plugin-copy";
34

45
const bundles = [
56
{
67
name: "blobs",
78
entry: "public/legacy.ts",
8-
output: "index.js",
9+
types: "public/legacy.d.ts",
10+
output: ".",
911
},
1012
{
1113
name: "blobs",
1214
entry: "public/legacy.ts",
13-
output: "v1/index.js",
15+
types: "public/legacy.d.ts",
16+
output: "v1",
1417
},
1518
{
1619
name: "blobs2",
1720
entry: "public/blobs.ts",
18-
output: "v2/index.js",
21+
types: "public/blobs.d.ts",
22+
output: "v2",
1923
},
2024
];
2125

2226
export default bundles.map((bundle) => ({
2327
input: bundle.entry,
2428
output: {
25-
file: bundle.output,
29+
file: bundle.output + "/index.js",
2630
format: "umd",
2731
name: bundle.name,
2832
sourcemap: true,
2933
},
30-
plugins: [typescript({cacheRoot: "./node_modules/.cache/rpt2"}), uglify()],
34+
plugins: [
35+
typescript({cacheRoot: "./node_modules/.cache/rpt2"}),
36+
uglify(),
37+
copy({
38+
hook: "writeBundle",
39+
targets: [{src: bundle.types, dest: bundle.output, rename: "index.d.ts"}],
40+
verbose: true,
41+
}),
42+
],
3143
}));

0 commit comments

Comments
 (0)