Skip to content

Commit fd04b9d

Browse files
committed
build fix
1 parent b178288 commit fd04b9d

File tree

3 files changed

+58
-73
lines changed

3 files changed

+58
-73
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"url": "https://github.com/ChrisUser/react-usage-bar.git"
1414
},
1515
"scripts": {
16-
"build": "rollup -c",
16+
"build": "rm -rf dist && rollup -c && tsc --emitDeclarationOnly",
1717
"lint": "standard",
1818
"format": "prettier-standard --format",
1919
"test": "jest --coverage",

rollup.config.js

Lines changed: 49 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,52 @@
1-
import dts from 'rollup-plugin-dts'
2-
import esbuild from 'rollup-plugin-esbuild'
3-
import typescript from "rollup-plugin-typescript2"
4-
import commonjs from "rollup-plugin-commonjs"
5-
import external from "rollup-plugin-peer-deps-external"
6-
import resolve from "rollup-plugin-node-resolve"
7-
import postcss from "rollup-plugin-postcss"
8-
import { terser } from "rollup-plugin-terser"
1+
import typescript from "rollup-plugin-typescript2";
2+
import commonjs from "rollup-plugin-commonjs";
3+
import external from "rollup-plugin-peer-deps-external";
4+
import resolve from "rollup-plugin-node-resolve";
5+
import postcss from "rollup-plugin-postcss";
6+
import { terser } from "rollup-plugin-terser";
97

10-
const name = require('./package.json').main.replace(/\.js$/, '')
8+
import pkg from "./package.json";
119

12-
const bundle = config => ({
13-
...config,
14-
input: 'src/index.ts',
15-
external: id => !/^[./]/.test(id),
16-
})
17-
18-
export default [
19-
bundle({
20-
plugins: [esbuild()],
21-
output: [
22-
{
23-
file: `${name}.js`,
24-
format: 'cjs',
25-
sourcemap: true,
26-
},
27-
{
28-
file: `${name}.mjs`,
29-
format: 'es',
30-
sourcemap: true,
31-
},
32-
],
33-
}),
34-
bundle({
35-
plugins: [dts()],
36-
output: {
37-
file: `${name}.d.ts`,
38-
format: 'es',
10+
export default {
11+
input: "src/index.ts",
12+
output: [
13+
{
14+
file: pkg.main,
15+
format: "cjs",
16+
exports: "named",
17+
sourcemap: true,
3918
},
40-
}),
41-
bundle({
42-
plugins: [,
43-
resolve(),
44-
postcss({
45-
extensions: [".css"],
46-
extract: true,
47-
}),
48-
external(),
49-
typescript({
50-
rollupCommonJSResolveHack: true,
51-
exclude: ["**/__tests__/**", "**/*.stories.tsx"],
52-
clean: true,
53-
}),
54-
terser(),
55-
commonjs({
56-
include: ["node_modules/**"],
57-
namedExports: {
58-
"node_modules/react/react.js": [
59-
"Children",
60-
"Component",
61-
"PropTypes",
62-
"createElement",
63-
],
64-
"node_modules/react-dom/index.js": ["render"],
65-
},
66-
}),
67-
]
68-
})
69-
]
19+
{
20+
file: pkg.module,
21+
format: "es",
22+
exports: "named",
23+
sourcemap: true,
24+
},
25+
],
26+
plugins: [
27+
resolve(),
28+
postcss({
29+
extensions: [".css"],
30+
extract: true,
31+
}),
32+
external(),
33+
typescript({
34+
rollupCommonJSResolveHack: true,
35+
exclude: ["**/__tests__/**", "**/*.stories.tsx"],
36+
clean: true,
37+
}),
38+
terser(),
39+
commonjs({
40+
include: ["node_modules/**"],
41+
namedExports: {
42+
"node_modules/react/react.js": [
43+
"Children",
44+
"Component",
45+
"PropTypes",
46+
"createElement",
47+
],
48+
"node_modules/react-dom/index.js": ["render"],
49+
},
50+
}),
51+
],
52+
};

tsconfig.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
2-
"include": ["src/**/*"],
3-
"exclude": ["node_modules"],
4-
"compilerOptions": {
5-
"jsx": "react"
6-
}
7-
}
2+
"include": ["src/**/*"],
3+
"exclude": ["node_modules", "**/*.stories.tsx"],
4+
"compilerOptions": {
5+
"jsx": "react",
6+
"declaration": true,
7+
"declarationDir": "./build"
8+
}
9+
}

0 commit comments

Comments
 (0)