Skip to content

Commit d360855

Browse files
authored
fix: use vite instead of parcel in the examples (#2329)
Parcel would delete some random file like identity because it though it was not used, vite is smarter. Also remove unused imports
1 parent 93578a4 commit d360855

27 files changed

+2641
-5118
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Some examples of valid commit messages (used as first lines):
5959

6060
To run this project, you will need:
6161

62-
- Node.js ≥ 16[nvm](https://github.com/creationix/nvm#install-script) is recommended
62+
- Node.js ≥ 18[nvm](https://github.com/nvm-sh/nvm#install-script) is recommended
6363
- [Yarn](https://yarnpkg.com)
6464

6565
## Release

examples/demo/index.html

+11-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8" />
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
63

7-
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
4+
<head>
5+
<meta charset="UTF-8" />
6+
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8+
<title>DocSearch v3 - React</title>
9+
</head>
810

9-
<title>DocSearch v3 - React</title>
10-
</head>
11+
<body>
12+
<div id="root"></div>
13+
<script type="module" src="/src/main.tsx"></script>
14+
</body>
1115

12-
<body>
13-
<noscript>You need to enable JavaScript to run this app.</noscript>
14-
<div id="root"></div>
15-
16-
<script type="module" src="src/index.js"></script>
17-
</body>
1816
</html>

examples/demo/package.json

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
"version": "3.6.2",
55
"private": true,
66
"license": "MIT",
7+
"type": "module",
78
"scripts": {
8-
"build": "parcel build index.html",
9-
"start": "parcel index.html"
9+
"dev": "vite",
10+
"build": "tsc -b && vite build",
11+
"preview": "vite preview"
1012
},
1113
"dependencies": {
1214
"@docsearch/css": "3.6.2",
13-
"@docsearch/react": "3.6.2",
14-
"react": "^18.1.0",
15-
"react-dom": "^18.1.0"
15+
"@docsearch/react": "3.6.2"
1616
},
1717
"devDependencies": {
18-
"parcel": "2.7.0"
18+
"@vitejs/plugin-react": "^4.3.3",
19+
"vite": "^5.4.10"
1920
}
2021
}
File renamed without changes.
File renamed without changes.

examples/demo/src/App.js examples/demo/src/App.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import React from 'react';
21
import { DocSearch } from '@docsearch/react';
32

4-
import './app.css';
5-
import '@docsearch/css';
3+
import './App.css';
4+
import '@docsearch/css/dist/style.css';
65

76
function App() {
87
return (
@@ -12,7 +11,7 @@ function App() {
1211
indexName="vuejs"
1312
appId="ML0LEBN7FQ"
1413
apiKey="21cf9df0734770a2448a9da64a700c22"
15-
insights
14+
insights={true}
1615
/>
1716
</div>
1817
);

examples/demo/src/index.js

-7
This file was deleted.

examples/demo/src/main.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { StrictMode } from 'react';
2+
import { createRoot } from 'react-dom/client';
3+
4+
import App from './App.js';
5+
6+
createRoot(document.getElementById('root')!).render(
7+
<StrictMode>
8+
<App />
9+
</StrictMode>
10+
);

examples/demo/src/vite-env.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

examples/demo/tsconfig.json

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"compilerOptions": {
3+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
4+
"target": "ES2020",
5+
"useDefineForClassFields": true,
6+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
7+
"module": "ESNext",
8+
"skipLibCheck": true,
9+
10+
/* Bundler mode */
11+
"moduleResolution": "Bundler",
12+
"allowImportingTsExtensions": true,
13+
"isolatedModules": true,
14+
"moduleDetection": "force",
15+
"noEmit": true,
16+
"jsx": "react-jsx",
17+
18+
/* Linting */
19+
"strict": true,
20+
"noUnusedLocals": true,
21+
"noUnusedParameters": true,
22+
"noFallthroughCasesInSwitch": true,
23+
"noUncheckedSideEffectImports": true
24+
},
25+
"include": ["src"]
26+
}

examples/demo/vite.config.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig } from 'vite'
2+
import react from '@vitejs/plugin-react'
3+
4+
// https://vite.dev/config/
5+
export default defineConfig({
6+
plugins: [react()],
7+
})

examples/js-demo/README.md

Whitespace-only changes.

examples/js-demo/index.html

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1+
<!doctype html>
12
<html lang="en">
2-
<head>
3-
<meta charset="UTF-8" />
4-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
53

6-
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
4+
<head>
5+
<meta charset="UTF-8" />
6+
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8+
<title>DocSearch v3 - Vanilla JavaScript</title>
9+
</head>
710

8-
<title>DocSearch v3 - Vanilla JavaScript</title>
9-
</head>
11+
<body>
12+
<div class="container">
13+
<h1>DocSearch v3 - Vanilla JavaScript</h1>
1014

11-
<body>
12-
<div class="container">
13-
<h1>DocSearch v3 - Vanilla JavaScript</h1>
15+
<div id="docsearch"></div>
16+
</div>
1417

15-
<div id="docsearch"></div>
16-
</div>
18+
<script type="module" src="/src/main.ts"></script>
19+
</body>
1720

18-
<script type="module" src="app.js"></script>
19-
</body>
2021
</html>

examples/js-demo/package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
"private": true,
66
"license": "MIT",
77
"scripts": {
8-
"build": "parcel build index.html",
9-
"start": "parcel index.html"
8+
"dev": "vite",
9+
"build": "tsc && vite build",
10+
"preview": "vite preview"
1011
},
1112
"dependencies": {
1213
"@docsearch/css": "3.6.2",
1314
"@docsearch/js": "3.6.2"
1415
},
1516
"devDependencies": {
16-
"parcel": "2.7.0"
17+
"vite": "^5.4.10"
1718
}
1819
}
File renamed without changes.
File renamed without changes.

examples/js-demo/app.js examples/js-demo/src/main.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import docsearch from '@docsearch/js/dist/umd';
1+
import docsearch from '@docsearch/js';
22

33
import './app.css';
4-
import '@docsearch/css';
4+
import '@docsearch/css/dist/style.css';
55

66
docsearch({
77
container: '#docsearch',

examples/js-demo/src/vite-env.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

examples/js-demo/tsconfig.json

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2020",
4+
"useDefineForClassFields": true,
5+
"module": "ESNext",
6+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
7+
"skipLibCheck": true,
8+
9+
/* Bundler mode */
10+
"moduleResolution": "Bundler",
11+
"allowImportingTsExtensions": true,
12+
"isolatedModules": true,
13+
"moduleDetection": "force",
14+
"noEmit": true,
15+
16+
/* Linting */
17+
"strict": true,
18+
"noUnusedLocals": true,
19+
"noUnusedParameters": true,
20+
"noFallthroughCasesInSwitch": true,
21+
"noUncheckedSideEffectImports": true
22+
},
23+
"include": ["src"]
24+
}

lerna.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
2-
"packages": ["packages/*", "examples/*"],
2+
"packages": [
3+
"packages/docsearch-css",
4+
"packages/docsearch-js",
5+
"packages/docsearch-react",
6+
"examples/*"
7+
],
38
"version": "3.6.2",
4-
"npmClient": "yarn",
5-
"useWorkspaces": true
9+
"npmClient": "yarn"
610
}

package.json

+5-17
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
"lint:css": "stylelint **/src/**/*.css",
2929
"lint": "eslint --ext .js,.ts,.tsx .",
3030
"playground:build": "yarn workspace @docsearch/react-example build",
31-
"playground:start": "yarn workspace @docsearch/react-example start",
32-
"playground-js:start": "yarn workspace @docsearch/js-example start",
31+
"playground:start": "yarn workspace @docsearch/react-example dev",
32+
"playground-js:start": "yarn workspace @docsearch/js-example dev",
3333
"release": "shipjs prepare",
3434
"start": "yarn run watch",
3535
"test:size": "bundlesize",
@@ -41,7 +41,6 @@
4141
"website:test": "cd packages/website && yarn install && yarn start --no-open"
4242
},
4343
"devDependencies": {
44-
"@babel/cli": "7.23.4",
4544
"@babel/plugin-transform-react-jsx": "7.23.4",
4645
"@babel/preset-env": "7.23.5",
4746
"@babel/preset-typescript": "7.23.3",
@@ -52,22 +51,16 @@
5251
"@testing-library/dom": "9.3.1",
5352
"@testing-library/jest-dom": "5.16.5",
5453
"@testing-library/react": "14.1.2",
55-
"@testing-library/user-event": "13.5.0",
5654
"@types/jest": "^29.0.0",
57-
"@types/jest-diff": "^24.3.0",
5855
"@types/react": "^18.0.0",
5956
"@types/react-dom": "^18.0.0",
6057
"@typescript-eslint/eslint-plugin": "5.41.0",
6158
"@typescript-eslint/parser": "5.41.0",
62-
"algoliasearch": "5.11.0",
63-
"babel-eslint": "10.1.0",
64-
"babel-loader": "9.1.3",
6559
"babel-plugin-inline-replace-variables": "1.3.1",
6660
"babel-plugin-module-resolver": "4.0.0",
6761
"bundlesize2": "0.0.31",
6862
"cssnano": "4.1.10",
6963
"cypress": "9.6.1",
70-
"dotenv": "16.3.1",
7164
"eslint": "8.55.0",
7265
"eslint-config-algolia": "20.0.0",
7366
"eslint-config-prettier": "8.10.0",
@@ -82,31 +75,26 @@
8275
"eslint-plugin-react-hooks": "4.6.0",
8376
"jest": "29.6.1",
8477
"jest-environment-jsdom": "29.6.1",
85-
"jest-watch-typeahead": "1.1.0",
86-
"lerna": "4.0.0",
78+
"lerna": "8.1.9",
8779
"postcss": "8.4.25",
8880
"prettier": "2.7.1",
8981
"react": "18.2.0",
9082
"react-dom": "18.2.0",
9183
"rollup": "1.32.1",
92-
"rollup-plugin-commonjs": "10.1.0",
9384
"rollup-plugin-dts": "^6.1.1",
9485
"rollup-plugin-filesize": "9.1.2",
95-
"rollup-plugin-license": "3.2.0",
9686
"rollup-plugin-terser": "7.0.2",
97-
"shipjs": "0.24.4",
87+
"shipjs": "0.26.4",
9888
"start-server-and-test": "1.15.5",
9989
"stylelint": "14.16.1",
10090
"stylelint-a11y": "1.2.3",
101-
"stylelint-config-prettier": "9.0.3",
10291
"stylelint-config-sass-guidelines": "9.0.1",
10392
"stylelint-config-standard": "28.0.0",
10493
"stylelint-no-unsupported-browser-features": "5.0.4",
10594
"stylelint-order": "5.0.0",
10695
"stylelint-prettier": "3.0.0",
10796
"ts-jest": "28.0.8",
10897
"typescript": "5.6.3",
109-
"watch": "1.0.2",
110-
"webpack": "4.44.1"
98+
"watch": "1.0.2"
11199
}
112100
}

packages/docsearch-react/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
},
3434
"dependencies": {
3535
"@algolia/autocomplete-core": "1.9.3",
36-
"@algolia/autocomplete-preset-algolia": "1.9.3",
36+
"@algolia/autocomplete-preset-algolia": "1.17.6",
3737
"@docsearch/css": "3.6.2",
3838
"algoliasearch": "^5.11.0"
3939
},

packages/docsearch-react/src/DocSearch.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ export function DocSearch(props: DocSearchProps) {
6262

6363
const onClose = React.useCallback(() => {
6464
setIsOpen(false);
65-
}, [setIsOpen]);
65+
setInitialQuery(props?.initialQuery);
66+
}, [setIsOpen, props.initialQuery]);
6667

6768
const onInput = React.useCallback(
6869
(event: KeyboardEvent) => {

packages/website/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"dependencies": {
1919
"@algolia/ui-library": "4.0.0-beta.71",
20-
"@docsearch/react": "link:../docsearch-react",
20+
"@docsearch/react": "3.6.2",
2121
"@docusaurus/core": "3.5.2",
2222
"@docusaurus/preset-classic": "3.5.2",
2323
"@mdx-js/react": "^3.1.0",
@@ -48,5 +48,8 @@
4848
"last 1 firefox version",
4949
"last 1 safari version"
5050
]
51+
},
52+
"resolutions": {
53+
"@docsearch/react": "link:../docsearch-react"
5154
}
5255
}

0 commit comments

Comments
 (0)