Skip to content

Commit 9f976b3

Browse files
committed
fix: module
1 parent 624da29 commit 9f976b3

File tree

5 files changed

+488
-11482
lines changed

5 files changed

+488
-11482
lines changed

package.json

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
{
22
"name": "react-animated-heart",
3-
"version": "0.0.7",
3+
"version": "0.0.8-beta.6",
44
"description": "Simple Twitter-like animated heart",
5-
"main": "dist/index.js",
5+
"main": "dist/cjs/index.js",
6+
"module": "dist/esm/index.js",
7+
"files": [
8+
"dist"
9+
],
10+
"types": "dist/index.d.ts",
611
"private": false,
712
"repository": "git@github.com:ShaunLWM/react-animated-heart.git",
813
"author": "ShaunLWM",
@@ -16,40 +21,22 @@
1621
"exploding button"
1722
],
1823
"dependencies": {
19-
"goober": "^2.1.9",
20-
"react": "^17.0.2",
21-
"react-dom": "^17.0.2",
22-
"react-scripts": "4.0.3"
24+
"goober": "^2.1.13",
25+
"react": "^18.2.0",
26+
"react-dom": "^18.2.0",
27+
"typescript": "^4.7.4"
2328
},
2429
"scripts": {
25-
"start": "react-scripts start",
26-
"build": "react-scripts build",
27-
"test": "react-scripts test",
28-
"eject": "react-scripts eject",
29-
"publish:npm": "rm -rf dist && mkdir dist && babel src/components -d dist --copy-files"
30-
},
31-
"eslintConfig": {
32-
"extends": "react-app"
33-
},
34-
"browserslist": {
35-
"production": [
36-
">0.2%",
37-
"not dead",
38-
"not op_mini all"
39-
],
40-
"development": [
41-
"last 1 chrome version",
42-
"last 1 firefox version",
43-
"last 1 safari version"
44-
]
30+
"rollup": "rollup -c",
31+
"prepublishOnly": "npm run rollup"
4532
},
4633
"devDependencies": {
47-
"@babel/cli": "^7.13.14",
48-
"@babel/preset-react": "^7.13.13"
49-
},
50-
"babel": {
51-
"presets": [
52-
"@babel/preset-react"
53-
]
34+
"@rollup/plugin-commonjs": "^21.0.1",
35+
"@rollup/plugin-node-resolve": "^13.0.6",
36+
"@rollup/plugin-typescript": "^8.3.0",
37+
"@types/react": "^18.0.38",
38+
"rollup": "^2.60.0",
39+
"rollup-plugin-dts": "^4.0.1",
40+
"tslib": "^2.5.0"
5441
}
5542
}

rollup.config.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import resolve from "@rollup/plugin-node-resolve";
2+
import commonjs from "@rollup/plugin-commonjs";
3+
import typescript from "@rollup/plugin-typescript";
4+
import dts from "rollup-plugin-dts";
5+
6+
const packageJson = require("./package.json");
7+
8+
// eslint-disable-next-line import/no-anonymous-default-export
9+
export default [
10+
{
11+
input: "src/index.tsx",
12+
output: [
13+
{
14+
file: packageJson.main,
15+
format: "cjs",
16+
sourcemap: true,
17+
},
18+
{
19+
file: packageJson.module,
20+
format: "esm",
21+
sourcemap: true,
22+
},
23+
],
24+
plugins: [
25+
resolve(),
26+
commonjs(),
27+
typescript({ tsconfig: "./tsconfig.json" }),
28+
],
29+
},
30+
{
31+
input: "dist/esm/index.d.ts",
32+
output: [{ file: "dist/index.d.ts", format: "esm" }],
33+
plugins: [dts()],
34+
},
35+
];
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
import React from "react";
1+
import { createElement } from "react";
22
import { setup, styled } from "goober";
33

4-
setup(React.createElement);
4+
setup(createElement);
55

6-
const HeartUI = styled('div')(({ isClick, styles }) => [
6+
export interface HeartProp {
7+
isClick: boolean;
8+
styles?: any;
9+
onClick: () => void;
10+
}
11+
12+
const HeartUI = (styled('div') as any)(({ isClick, styles }: Partial<HeartProp>) => [
713
{
814
width: '100px',
915
height: '100px',
@@ -18,6 +24,6 @@ const HeartUI = styled('div')(({ isClick, styles }) => [
1824
styles
1925
]);
2026

21-
export default function Heart({ isClick, onClick, styles }) {
27+
export default function Heart({ isClick, onClick, styles }: HeartProp) {
2228
return <HeartUI isClick={isClick} onClick={onClick} styles={styles} />;
2329
}

tsconfig.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"esModuleInterop": true,
5+
"forceConsistentCasingInFileNames": true,
6+
"strict": true,
7+
"skipLibCheck": true,
8+
"jsx": "react-jsx",
9+
"module": "ESNext",
10+
"declaration": true,
11+
"declarationDir": "types",
12+
"sourceMap": true,
13+
"outDir": "dist",
14+
"moduleResolution": "node",
15+
"allowSyntheticDefaultImports": true,
16+
"emitDeclarationOnly": true,
17+
}
18+
}

0 commit comments

Comments
 (0)