Skip to content

Commit 29f64df

Browse files
committed
feat(vite): move from tsup
1 parent 15eadae commit 29f64df

File tree

11 files changed

+4787
-5282
lines changed

11 files changed

+4787
-5282
lines changed

libs/react-plock/README.md

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

libs/react-plock/jest.config.js

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

libs/react-plock/package.json

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "react-plock",
33
"version": "3.0.2",
4+
"type": "module",
45
"description": "The 1kB Masonry Grid for React",
56
"author": "Renato Pozzi <askides@proton.me>",
67
"homepage": "https://github.com/askides/react-plock#readme",
@@ -19,26 +20,18 @@
1920
"url": "git+https://github.com/askides/react-plock.git"
2021
},
2122
"scripts": {
22-
"test": "jest",
23+
"test": "vitest run",
2324
"lib:bump": "changelogen --bump",
2425
"lib:bump:dev": "changelogen --bump --prerelease dev",
2526
"lib:publish": "changelogen --publish",
2627
"lib:publish:dev": "npm publish react-plock --tag dev",
2728
"lib:release": "semantic-release",
28-
"build": "tsup index.ts --dts --minify"
29+
"build": "vite build"
2930
},
3031
"bugs": {
3132
"url": "https://github.com/askides/react-plock/issues"
3233
},
3334
"peerDependencies": {
3435
"react": "^18.2.0"
35-
},
36-
"devDependencies": {
37-
"@types/jest": "^29.4.0",
38-
"@types/react": "^18.0.28",
39-
"changelogen": "^0.5.5",
40-
"jest": "^29.4.3",
41-
"semantic-release": "^22.0.12",
42-
"ts-jest": "^29.0.5"
4336
}
4437
}

libs/react-plock/src/Plock.spec.tsx

Lines changed: 65 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,78 @@
1-
import { createChunks, createDataColumns } from "./Plock";
1+
import { describe, it, expect } from 'vitest';
2+
import { createChunks, createDataColumns } from './Plock';
23

3-
it("should create chunks", () => {
4-
const data = [1, 2, 3, 4, 5, 6, 7, 8];
5-
const result = createChunks(data, 4);
4+
describe('Plock', () => {
5+
it('should create chunks', () => {
6+
const data = [1, 2, 3, 4, 5, 6, 7, 8];
7+
const result = createChunks(data, 4);
68

7-
expect(result).toEqual([
8-
[1, 2, 3, 4],
9-
[5, 6, 7, 8],
10-
]);
11-
});
12-
13-
it("should create columns", () => {
14-
const result = createDataColumns(
15-
[
9+
expect(result).toEqual([
1610
[1, 2, 3, 4],
1711
[5, 6, 7, 8],
18-
],
19-
4
20-
);
12+
]);
13+
});
2114

22-
expect(result).toEqual([
23-
[1, 5],
24-
[2, 6],
25-
[3, 7],
26-
[4, 8],
27-
]);
28-
});
15+
it('should create columns', () => {
16+
const result = createDataColumns(
17+
[
18+
[1, 2, 3, 4],
19+
[5, 6, 7, 8],
20+
],
21+
4
22+
);
2923

30-
it("should create columns even with not equal values", () => {
31-
const data = [1, 2, 3, 4, 5, 6, 7, 8, 9];
32-
const chunks = createChunks(data, 4);
33-
const result = createDataColumns(chunks, 4);
24+
expect(result).toEqual([
25+
[1, 5],
26+
[2, 6],
27+
[3, 7],
28+
[4, 8],
29+
]);
30+
});
3431

35-
expect(result).toEqual([
36-
[1, 5, 9],
37-
[2, 6],
38-
[3, 7],
39-
[4, 8],
40-
]);
41-
});
32+
it('should create columns even with not equal values', () => {
33+
const data = [1, 2, 3, 4, 5, 6, 7, 8, 9];
34+
const chunks = createChunks(data, 4);
35+
const result = createDataColumns(chunks, 4);
4236

43-
it("should create columns even with not equal values", () => {
44-
const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
45-
const chunks = createChunks(data, 4);
46-
const result = createDataColumns(chunks, 4);
37+
expect(result).toEqual([
38+
[1, 5, 9],
39+
[2, 6],
40+
[3, 7],
41+
[4, 8],
42+
]);
43+
});
4744

48-
expect(result).toEqual([
49-
[1, 5, 9, 13],
50-
[2, 6, 10, 14],
51-
[3, 7, 11, 15],
52-
[4, 8, 12],
53-
]);
54-
});
45+
it('should create columns even with not equal values', () => {
46+
const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
47+
const chunks = createChunks(data, 4);
48+
const result = createDataColumns(chunks, 4);
49+
50+
expect(result).toEqual([
51+
[1, 5, 9, 13],
52+
[2, 6, 10, 14],
53+
[3, 7, 11, 15],
54+
[4, 8, 12],
55+
]);
56+
});
5557

56-
it("should create columns even with not equal values another", () => {
57-
const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];
58-
const chunks = createChunks(data, 2);
59-
const result = createDataColumns(chunks, 2);
58+
it('should create columns even with not equal values another', () => {
59+
const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];
60+
const chunks = createChunks(data, 2);
61+
const result = createDataColumns(chunks, 2);
6062

61-
expect(chunks).toEqual([
62-
[1, 2],
63-
[3, 4],
64-
[5, 6],
65-
[7, 8],
66-
[9, 10],
67-
[11, 12],
68-
[13, 14],
69-
]);
63+
expect(chunks).toEqual([
64+
[1, 2],
65+
[3, 4],
66+
[5, 6],
67+
[7, 8],
68+
[9, 10],
69+
[11, 12],
70+
[13, 14],
71+
]);
7072

71-
expect(result).toEqual([
72-
[1, 3, 5, 7, 9, 11, 13],
73-
[2, 4, 6, 8, 10, 12, 14],
74-
]);
73+
expect(result).toEqual([
74+
[1, 3, 5, 7, 9, 11, 13],
75+
[2, 4, 6, 8, 10, 12, 14],
76+
]);
77+
});
7578
});

libs/react-plock/tsconfig.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
{
22
"compilerOptions": {
3-
"jsx": "react",
4-
"esModuleInterop": true,
5-
"outDir": "./dist"
3+
"target": "ES2020",
4+
"useDefineForClassFields": true,
5+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
6+
"module": "ESNext",
7+
"skipLibCheck": true,
8+
"moduleResolution": "bundler",
9+
"allowImportingTsExtensions": true,
10+
"resolveJsonModule": true,
11+
"isolatedModules": true,
12+
"noEmit": true,
13+
"jsx": "react-jsx",
14+
"strict": true,
15+
"noUnusedLocals": true,
16+
"noUnusedParameters": true
617
},
7-
"include": ["./src", "index.ts"]
18+
"include": ["src", "index.ts"],
19+
"references": [{ "path": "./tsconfig.node.json" }]
820
}

libs/react-plock/tsconfig.node.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"compilerOptions": {
3+
"composite": true,
4+
"skipLibCheck": true,
5+
"module": "ESNext",
6+
"moduleResolution": "bundler",
7+
"allowSyntheticDefaultImports": true
8+
},
9+
"include": ["vite.config.ts"]
10+
}

libs/react-plock/tsup.config.ts

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

libs/react-plock/vite.config.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { defineConfig } from 'vite';
2+
import react from '@vitejs/plugin-react';
3+
import { resolve } from 'path';
4+
import dts from 'vite-plugin-dts';
5+
6+
export default defineConfig({
7+
plugins: [react(), dts({ rollupTypes: true })],
8+
build: {
9+
lib: {
10+
entry: resolve(__dirname, 'index.ts'),
11+
formats: ['es', 'cjs'],
12+
fileName: (format) => `index.${format}.js`,
13+
},
14+
rollupOptions: {
15+
external: [/^react($|\/.*)/, 'react-dom'],
16+
output: {
17+
globals: {
18+
react: 'React',
19+
'react-dom': 'ReactDOM',
20+
},
21+
},
22+
},
23+
},
24+
});

libs/react-plock/vitest.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { defineConfig } from 'vitest/config';
2+
3+
export default defineConfig({
4+
test: {
5+
environment: 'jsdom',
6+
globals: true,
7+
},
8+
});

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@
99
},
1010
"devDependencies": {
1111
"@types/node": "^18.14.4",
12-
"tsup": "^6.6.3",
13-
"typescript": "^5.3.3"
12+
"@types/react": "^18.2.0",
13+
"@vitejs/plugin-react": "^4.3.4",
14+
"typescript": "^5.3.3",
15+
"vite": "^6.0.3",
16+
"vite-plugin-dts": "^4.3.0",
17+
"vitest": "^2.1.8",
18+
"jsdom": "^25.0.1"
1419
}
1520
}

0 commit comments

Comments
 (0)