Skip to content

Commit 69406b6

Browse files
committed
refactor: remove unecessary path aliases
1 parent fd6e66e commit 69406b6

File tree

10 files changed

+3640
-3598
lines changed

10 files changed

+3640
-3598
lines changed

jest.config.js

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

jest.config.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"roots": ["<rootDir>/src", "<rootDir>/lib"],
3+
"transform": {
4+
"^.+\\.(t|j)sx?$": [
5+
"@swc/jest",
6+
{
7+
"jsc": {
8+
"transform": {
9+
"react": {
10+
"runtime": "automatic"
11+
}
12+
}
13+
}
14+
}
15+
]
16+
},
17+
"setupFilesAfterEnv": ["@testing-library/jest-dom"],
18+
"testEnvironment": "jest-environment-jsdom",
19+
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
20+
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"],
21+
"moduleNameMapper": {
22+
"\\.(css|less)$": "<rootDir>/lib/__mocks__/styleMock.ts"
23+
}
24+
}

lib/__tests__/dynamic-star.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DynamicStar } from "@/main";
1+
import { DynamicStar } from "../main";
22
import { render } from "@testing-library/react";
33

44
describe("Without pass props optional props", () => {

lib/main.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useMemo } from "react";
2-
import { useId } from "@/hooks/useId";
3-
import type { IDynamicStarProps, IStar } from "@/types";
4-
import { calcStarPoints, emptyStar, fillStars } from "@/utils";
2+
import { useId } from "./hooks/useId";
3+
import type { IDynamicStarProps, IStar } from "./types";
4+
import { calcStarPoints, emptyStar, fillStars } from "./utils";
55

66
function DynamicStar({
77
rating,

lib/utils/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { IStar } from "@/types";
1+
import type { IStar } from "../types";
22

33
const fullStar = 1;
44
const emptyStar = 0;

package.json

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "react-dynamic-star",
3-
"version": "0.0.2",
3+
"version": "1.0.0",
44
"description": "Single component to generate dynamic star svg",
55
"main": "./dist/rds.umd.js",
66
"module": "./dist/rds.es.js",
77
"types": "./dist/rds.d.ts",
88
"license": "MIT",
9+
"type": "module",
910
"scripts": {
1011
"dev": "vite",
1112
"build": "tsc && vite build",
@@ -40,28 +41,25 @@
4041
"peerDependencies": {
4142
"react": ">=17.x"
4243
},
43-
"resolutions": {
44-
"@types/react": "17.0.0"
45-
},
4644
"devDependencies": {
4745
"@biomejs/biome": "1.9.4",
4846
"@swc/core": "^1.9.2",
4947
"@swc/jest": "^0.2.37",
50-
"@testing-library/jest-dom": "5.14.1",
51-
"@testing-library/react": "12.1.2",
52-
"@types/jest": "27.0.2",
53-
"@types/node": "16.11.1",
54-
"@types/react": "17.0.0",
55-
"@types/react-dom": "17.0.0",
56-
"@typescript-eslint/eslint-plugin": "5.0.0",
57-
"@typescript-eslint/parser": "5.0.0",
58-
"@vitejs/plugin-react": "1.0.0",
59-
"jest": "27.3.1",
60-
"react": "17.0.2",
61-
"react-dom": "17.0.2",
62-
"typescript": "4.4.4",
63-
"vite": "2.6.4",
64-
"vite-plugin-dts": "0.9.2",
65-
"vite-tsconfig-paths": "3.3.17"
48+
"@testing-library/dom": "^10.4.0",
49+
"@testing-library/jest-dom": "^6.6.3",
50+
"@testing-library/react": "^16.0.1",
51+
"@types/jest": "^29.5.14",
52+
"@types/node": "^22.9.0",
53+
"@types/react": "^18.3.12",
54+
"@types/react-dom": "^18.3.1",
55+
"@vitejs/plugin-react": "^4.3.3",
56+
"jest": "^29.7.0",
57+
"jest-environment-jsdom": "^29.7.0",
58+
"react": "^18.3.1",
59+
"react-dom": "^18.3.1",
60+
"typescript": "^5.6.3",
61+
"vite": "^5.4.11",
62+
"vite-plugin-dts": "^4.3.0",
63+
"vite-tsconfig-paths": "^5.1.2"
6664
}
6765
}

src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22
import "./App.css";
3-
import { DynamicStar } from "react-dynamic-star";
3+
import { DynamicStar } from "../lib/main";
44

55
function Stars() {
66
const [star, setStar] = React.useState({

tsconfig.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"useDefineForClassFields": true,
55
"lib": ["DOM", "DOM.Iterable", "ESNext"],
66
"allowJs": false,
7-
"skipLibCheck": false,
7+
"skipLibCheck": true,
88
"esModuleInterop": true,
99
"allowSyntheticDefaultImports": true,
1010
"strict": true,
@@ -15,12 +15,8 @@
1515
"isolatedModules": true,
1616
"noEmit": true,
1717
"jsx": "react-jsx",
18-
"baseUrl": ".",
19-
"paths": {
20-
"@/*": ["lib/*"],
21-
"react-dynamic-star": ["lib/main.tsx"]
22-
}
18+
"baseUrl": "."
2319
},
2420
"include": ["./src", "./lib"],
25-
"exclude": ["node_modules"]
21+
"exclude": ["node_modules", "./lib/__tests__"]
2622
}

vite.config.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import path from "node:path";
22
import { defineConfig } from "vite";
3-
import tsConfigpaths from "vite-tsconfig-paths";
43
import react from "@vitejs/plugin-react";
54
import dts from "vite-plugin-dts";
65

76
// https://vitejs.dev/config/
8-
export default defineConfig({
7+
export default defineConfig((env) => ({
8+
define:
9+
env.command === "build"
10+
? { "process.env.NODE_ENV": "'production'" }
11+
: undefined,
912
plugins: [
1013
react(),
11-
tsConfigpaths(),
1214
dts({
1315
include: ["lib/main.tsx"],
1416
beforeWriteFile: (filePath, content) => ({
@@ -24,7 +26,16 @@ export default defineConfig({
2426
fileName: (format) => `rds.${format}.js`,
2527
},
2628
rollupOptions: {
27-
external: ["react"],
29+
external: ["react", "react/jsx-runtime", "react-dom"],
30+
output: {
31+
// Provide global variables to use in the UMD build
32+
// for externalized deps
33+
globals: {
34+
react: "react",
35+
"react-dom": "ReactDOM",
36+
"react/jsx-runtime": "react/jsx-runtime",
37+
},
38+
},
2839
},
2940
},
30-
});
41+
}));

0 commit comments

Comments
 (0)