Skip to content

Commit f6f7ea5

Browse files
authored
Switch to vite (#152)
* set up vite * specific tsconfig for build * configure vitest and esbuild build * move build script to script folder * fix vitest config * fix eslint config * fix prettier * fix port * fix build * ignore files in npm * build dts with rollup and add multiple configs * format files * ignore rollup config in npm
1 parent 0c85ca3 commit f6f7ea5

File tree

17 files changed

+1811
-3987
lines changed

17 files changed

+1811
-3987
lines changed

.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ dist
22
.parcel-cache/
33
jest.config.js
44
.eslintrc.js
5-
babel.config.js
5+
babel.config.js
6+
scripts

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
run: |
3434
yarn lint
3535
yarn test
36-
yarn start &
36+
CI=true yarn start &
3737
yarn cypress run
3838
3939
- name: Upload Cypress Screenshots

.npmignore

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,14 @@ yarn-error.log
1414
dist/
1515
examples/
1616
cypress/
17-
cypress.config.js
18-
.release-it.json
17+
cypress.config.ts
18+
.release-it.json
19+
index.html
20+
vite.config.ts
21+
vitest.config.ts
22+
scripts/
23+
.github/
24+
.eslintignore
25+
.eslintrc.js
26+
.prettierignore
27+
rollup.config.js

.parcelrc

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

cypress/e2e/spec.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const examples: ExampleTest[] = [
3535

3636
describe("template spec", () => {
3737
before(() => {
38-
cy.visit("http://localhost:1234");
38+
cy.visit("http://localhost:5173");
3939
});
4040

4141
it("pdfs must mach baseline", () => {

examples/index.html renamed to index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
</head>
77
<body>
88
<div id="app"></div>
9-
<script type="module" src="./index.tsx"></script>
9+
<script type="module" src="./examples/index.tsx"></script>
1010
</body>
1111
</html>

jest.config.js

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

package.json

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
"name": "react-to-pdf",
33
"version": "1.0.1",
44
"description": "Create PDF documents from React Components",
5-
"source": "src/index.ts",
6-
"main": "dist/main.js",
7-
"module": "dist/module.js",
8-
"types": "dist/types.d.ts",
5+
"main": "dist/index.js",
6+
"module": "dist/index.mjs",
7+
"types": "dist/index.d.ts",
98
"keywords": [
109
"pdf",
1110
"react",
@@ -22,49 +21,43 @@
2221
},
2322
"homepage": "https://github.com/ivmarcos/react-to-pdf#readme",
2423
"scripts": {
25-
"start": "parcel examples/index.html",
26-
"build": "parcel build src/index.ts",
24+
"start": "vite",
25+
"build": "node scripts/build && rollup -c",
2726
"clean": "rimraf dist",
2827
"docs": "typedoc --plugin typedoc-plugin-markdown --out docs src/index.ts src/types.ts src/constants.ts",
29-
"test": "npm run lint && jest",
28+
"test": "npm run lint && vitest run",
3029
"lint": "eslint . && prettier -c .",
3130
"release": "release-it",
3231
"prerelease": "npm run clean && npm run build",
33-
"format": "prettier --write src examples README.md CHANGELOG.md .release-it.json *.json *.ts cypress .github"
32+
"format": "prettier --write ."
3433
},
3534
"devDependencies": {
36-
"@babel/preset-env": "^7.20.2",
37-
"@babel/preset-react": "^7.18.6",
38-
"@babel/preset-typescript": "^7.21.0",
39-
"@parcel/packager-ts": "2.8.3",
40-
"@parcel/transformer-typescript-types": "2.8.3",
41-
"@release-it/keep-a-changelog": "^4.0.0",
42-
"@types/jest": "^29.5.1",
4335
"@types/jsdom": "^21.1.1",
4436
"@types/react": "^18.0.28",
4537
"@types/react-dom": "^18.0.11",
4638
"@types/react-test-renderer": "^18.0.0",
4739
"@typescript-eslint/eslint-plugin": "^5.59.0",
4840
"@typescript-eslint/parser": "^5.59.0",
41+
"@vitejs/plugin-react": "^4.3.4",
4942
"canvas": "^3.1.0",
5043
"compare-pdf": "^1.1.8",
5144
"cypress": "^13.1.0",
5245
"eslint": "^8.39.0",
5346
"eslint-plugin-react": "^7.32.2",
54-
"jest": "^29.5.0",
55-
"jest-environment-jsdom": "^29.5.0",
56-
"parcel": "latest",
47+
"jsdom": "^26.0.0",
5748
"prettier": "^2.8.4",
5849
"process": "^0.11.10",
5950
"react": "^16.8",
6051
"react-dom": "^16.8",
6152
"react-test-renderer": "^16.14.0",
6253
"release-it": "^18.1.2",
6354
"rimraf": "^5.0.0",
64-
"ts-jest": "^29.1.1",
55+
"rollup-plugin-dts": "^6.2.1",
6556
"typedoc": "^0.24.4",
6657
"typedoc-plugin-markdown": "^3.15.2",
67-
"typescript": ">=3.0.0"
58+
"typescript": ">=3.0.0",
59+
"vite": "^6.2.3",
60+
"vitest": "^3.0.9"
6861
},
6962
"peerDependencies": {
7063
"react": ">=16.8",
@@ -73,8 +66,5 @@
7366
"dependencies": {
7467
"html2canvas": "^1.4.1",
7568
"jspdf": "^3.0.1"
76-
},
77-
"alias": {
78-
"react-to-pdf": "./src"
7969
}
8070
}

release-it.json

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

rollup.config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import dts from "rollup-plugin-dts";
2+
3+
export default {
4+
input: "src/index.ts",
5+
output: {
6+
file: "dist/index.d.ts",
7+
format: "es",
8+
},
9+
plugins: [dts()],
10+
};

0 commit comments

Comments
 (0)