Skip to content

Commit 1ea3d2b

Browse files
committed
migrated build to rollup/npm
enabled react-jsx in runtime
1 parent 5e073a9 commit 1ea3d2b

20 files changed

+135
-2262
lines changed

dist/css/styles.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/react-strp-counter.css

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
import { default as default_2 } from 'react';
2-
3-
export declare const STRPCounter: default_2.FC<STRPCounterProps>;
4-
5-
declare type STRPCounterProps = {
1+
import React from 'react';
2+
import './css/styles.css';
3+
export interface STRPCounterProps {
64
value: number | string;
75
fontSize?: string;
86
minLength?: number;
97
rollingMode?: boolean;
108
delimiter?: string | false;
119
decimalSeparator?: string | false;
12-
unitLabel?: string | default_2.ReactNode;
10+
unitLabel?: string | React.ReactNode;
1311
unitLabelPosition?: 'left' | 'right';
1412
stepDuration?: number;
1513
easing?: string | false;
16-
};
17-
18-
export { }
14+
}
15+
declare const STRPCounter: React.FC<STRPCounterProps>;
16+
export default STRPCounter;

dist/types/index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import STRPCounter from './STRPCounter';
2+
export default STRPCounter;
3+
export { STRPCounter };
4+
export type { STRPCounterProps } from './STRPCounter';
5+
export * from './STRPCounter';

package.json

Lines changed: 41 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,48 @@
22
"name": "react-strp-counter",
33
"author": "Arsen Mkrtchyan (stripearmy)",
44
"private": false,
5-
"version": "1.1.0",
5+
"version": "1.1.1",
66
"description": "A lightweight counter that relies on CSS to rearrange numbers and doesn't rerender Elements",
7-
"type": "module",
8-
"main": "dist/react-strp-counter.umd.js",
9-
"module": "dist/react-strp-counter.es.js",
10-
"types": "dist/index.d.ts",
117
"repository": "https://github.com/stripearmy/react-strp-counter.git",
12-
"license": "MIT",
8+
"type": "module",
9+
"exports": {
10+
".": {
11+
"import": "./dist/react-strp-counter.esm.js",
12+
"require": "./dist/react-strp-counter.js",
13+
"types": "./dist/types/index.d.ts"
14+
},
15+
"./css": "./dist/css/index.js",
16+
"./styles.css": "./dist/css/styles.css"
17+
},
18+
"main": "dist/react-strp-counter.js",
19+
"module": "dist/react-strp-counter.esm.js",
20+
"types": "dist/types/index.d.ts",
21+
"files": [
22+
"dist"
23+
],
24+
"scripts": {
25+
"clean": "rm -rf dist",
26+
"build": "npx rollup -c",
27+
"prepare": "npm run build"
28+
},
29+
"peerDependencies": {
30+
"react": ">=16.8.0",
31+
"react-dom": ">=16.8.0"
32+
},
33+
"devDependencies": {
34+
"@rollup/plugin-commonjs": "^24.0.1",
35+
"@rollup/plugin-node-resolve": "^15.0.1",
36+
"@rollup/plugin-terser": "^0.4.3",
37+
"@rollup/plugin-typescript": "^11.0.0",
38+
"@types/node": "^20.11.0",
39+
"@types/react": "^18.0.28",
40+
"@types/react-dom": "^18.0.11",
41+
"rollup": "^3.29.4",
42+
"rollup-plugin-copy": "^3.5.0",
43+
"rollup-plugin-postcss": "^4.0.2",
44+
"tslib": "^2.6.2",
45+
"typescript": "^4.9.5"
46+
},
1347
"keywords": [
1448
"react",
1549
"counter",
@@ -34,47 +68,5 @@
3468
"css odometer",
3569
"react odomteter"
3670
],
37-
"files": [
38-
"dist",
39-
"styles"
40-
],
41-
"exports": {
42-
".": {
43-
"types": "./dist/index.d.ts",
44-
"import": "./dist/react-strp-counter.umd.js"
45-
},
46-
"./css": {
47-
"types": "./dist/index.d.ts",
48-
"import": "./dist/react-strp-counter.css"
49-
}
50-
},
51-
"scripts": {
52-
"dev": "vite",
53-
"build": "tsc -b && vite build",
54-
"lint": "eslint .",
55-
"preview": "vite preview"
56-
},
57-
"peerDependencies": {
58-
"react": ">=16.8.0",
59-
"react-dom": ">=16.8.0"
60-
},
61-
"devDependencies": {
62-
"@eslint/js": "^9.21.0",
63-
"@types/node": "^22.13.10",
64-
"@types/react": "^19.0.10",
65-
"@types/react-dom": "^19.0.4",
66-
"@vitejs/plugin-react": "^4.3.4",
67-
"eslint": "^9.21.0",
68-
"eslint-plugin-react-hooks": "^5.1.0",
69-
"eslint-plugin-react-refresh": "^0.4.19",
70-
"globals": "^15.15.0",
71-
"prettier": "3.5.3",
72-
"typescript": "~5.7.2",
73-
"typescript-eslint": "^8.24.1",
74-
"vite": "^6.2.0",
75-
"vite-plugin-static-copy": "^2.3.0",
76-
"react": "^16.8.0",
77-
"react-dom": "^16.8.0",
78-
"vite-plugin-dts": "^4.5.3"
79-
}
71+
"license": "MIT"
8072
}

rollup.config.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import path from 'path';
2+
import commonjs from '@rollup/plugin-commonjs';
3+
import resolve from '@rollup/plugin-node-resolve';
4+
import typescript from '@rollup/plugin-typescript';
5+
import postcss from 'rollup-plugin-postcss';
6+
import terser from '@rollup/plugin-terser';
7+
import copy from 'rollup-plugin-copy';
8+
9+
export default {
10+
input: 'src/index.ts',
11+
output: [
12+
{
13+
file: 'dist/react-strp-counter.js',
14+
format: 'cjs',
15+
exports: 'named',
16+
sourcemap: false
17+
},
18+
{
19+
file: 'dist/react-strp-counter.esm.js',
20+
format: 'esm',
21+
exports: 'named',
22+
sourcemap: false
23+
}
24+
],
25+
plugins: [
26+
resolve(),
27+
commonjs(),
28+
typescript({
29+
tsconfig: './tsconfig.json',
30+
jsx: 'react',
31+
declaration: true,
32+
declarationDir: 'dist/types'
33+
}),
34+
postcss({
35+
extract: path.resolve('dist/css/styles.css'),
36+
minimize: true
37+
}),
38+
copy({
39+
targets: [
40+
{
41+
src: 'src/css/index.js',
42+
dest: 'dist/css'
43+
}
44+
]
45+
}),
46+
terser()
47+
],
48+
external: ['react', 'react-dom', 'react/jsx-runtime']
49+
};

src/STRPCounter.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import "./styles/react-strp-counter.css";
21
import type {ReactNode} from "react";
32

43
interface STRPCounterProps {

src/STRPCounter.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, {useEffect, useRef} from 'react';
2+
import './css/styles.css';
23

3-
export type STRPCounterProps = {
4+
export interface STRPCounterProps {
45
value: number | string;
56
fontSize?: string;
67
minLength?: number;
@@ -11,7 +12,7 @@ export type STRPCounterProps = {
1112
unitLabelPosition?: 'left' | 'right';
1213
stepDuration?: number;
1314
easing?: string | false,
14-
};
15+
}
1516

1617
const formatNumber = (
1718
value: number | string,
@@ -66,7 +67,6 @@ const STRPCounter: React.FC<STRPCounterProps> = ({
6667
stepDuration = 0.05,
6768
easing = 'cubic-bezier(0.33,0.81,0.1,1.02)',
6869
}) => {
69-
import('./styles/styles.css');
7070

7171
const formatted = formatNumber(value, minLength, delimiter, decimalSeparator);
7272
const refs = useRef<(HTMLDivElement | null)[]>([]);
File renamed without changes.

src/global.d.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)