Skip to content

Commit 479e73e

Browse files
committed
Merge migrate-to-turbo-and-pnpm branch
2 parents 3e8b41b + b67163b commit 479e73e

39 files changed

+18052
-18160
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ node_modules
66
# builds
77
build
88
dist
9+
types
910

1011
# misc
1112
.DS_Store
@@ -24,3 +25,4 @@ yarn-error.log*
2425

2526
.next/
2627
.vercel/
28+
.turbo/

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
. "$(dirname "$0")/_/husky.sh"
33

4-
npm run pre-commit
4+
pnpm run pre-commit

contributing.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,44 @@ Suggestions and pull requests are highly encouraged. Have a look at the [open is
44

55
## Development
66

7-
To develop the project locally, you'll need a recent version of Node.js and `yarn` v1 installed globally.
7+
To develop the project locally, you'll need a recent version of Node.js and `pnpm` installed globally.
88

9-
To get started, clone the repo and run `yarn` from the root directory:
9+
To get started, clone the repo and run `pnpm` from the root directory:
1010

1111
```bash
1212
git clone https://github.com/NotionX/react-notion-x.git
1313
cd react-notion-x
14-
yarn
14+
pnpm i
1515
```
1616

17-
This will install dependencies and link all of the local packages together using `lerna`. This includes the example projects which will now point to the local version of your packages.
17+
This will install dependencies and link all of the local packages together using [pnpm workspaces](https://pnpm.io/workspaces). This includes the example projects which point to the local version of your packages. When publishing, `"foo": "workspace:*"` will be transformed to point to the current version.
1818

19-
```bash
20-
yarn dev
21-
```
19+
### Running development tasks
2220

23-
This starts compiling the packages into their respective `build` folders. Under the hood, it is running `tsc --watch` and `tsup --watch`, so every time you make a change to one of the packages, the build will be updated automatically as long as this command is running.
21+
With development tasks, each package will be compiled into their respective `build` folders. Because they run `tsup --watch`, every time you make a change to one of the packages, the build will be updated automatically as long as this command is running.
2422

25-
With `yarn dev` running in one tab, we recommend opening a second tab and navigating to the `examples/minimal` directory.
23+
We recommend running the `notion-x-example-minimal` example.
2624

2725
```bash
28-
cd examples/minimal
29-
yarn dev
26+
turbo dev --filter=notion-x-example-minimal...
3027
```
3128

32-
Running `yarn dev` from the `examples/minimal` directory will start the example project's Next.js dev server. This project should be using your locally built version of the libraries because they have been linked using `lerna`.
29+
Running `turbo dev` with the package name will start the example project's Next.js dev server. This project should be using your locally built version of the libraries because they have `workspace:*` on its `package.json`. The `...` at the end indicate that the `filter` should also select the package's dependencies.
3330

3431
You should now be able to open `http://localhost:3000` to view and debug the example project.
3532

3633
### Gotchas
3734

38-
Whenever you make a change to one of the packages, the `yarn dev` from the project root will re-compile that package, and the `yarn dev` from the example project's Next.js dev server should hot-reload it in the browser.
35+
Whenever you make a change to one of the packages that's being used by the example, the `turbo dev` command that's running the example project will re-compile that package, and the Next.js dev server should hot-reload it in the browser.
36+
37+
Sometimes, this process gets a little out of whack, and if you're not sure what's going on, I usually just quit one or both of the `turbo dev` commands and restart it.
38+
39+
If you're seeing something unexpected while debugging one of the Next.js demos, try running `turbo clean` to refresh the cache before running `turbo dev` again.
3940

40-
Sometimes, this process gets a little out of whack, and if you're not sure what's going on, I usually just quit one or both of the `yarn dev` commands and restart them.
41+
### Build task
4142

42-
If you're seeing something unexpected while debugging one of the Next.js demos, try running `rm -rf .next` to refresh the Next.js cache before running `yarn dev` again.
43+
Simply run the following command from the repository's root
44+
45+
```
46+
turbo build
47+
```

examples/cra/package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@
33
"version": "6.16.1",
44
"private": true,
55
"scripts": {
6-
"dev": "GENERATE_SOURCEMAP=false react-scripts start",
76
"start": "GENERATE_SOURCEMAP=false react-scripts start",
87
"build": "GENERATE_SOURCEMAP=false react-scripts build",
9-
"eject": "GENERATE_SOURCEMAP=false react-scripts eject"
8+
"dev": "GENERATE_SOURCEMAP=false react-scripts start",
9+
"eject": "GENERATE_SOURCEMAP=false react-scripts eject",
10+
"lint": "eslint \"src/**/*.ts*\"",
11+
"clean": "rm -rf build"
1012
},
1113
"dependencies": {
1214
"@types/node": "^16.11.26",
1315
"@types/react": "^17.0.43",
1416
"@types/react-dom": "^17.0.14",
15-
"notion-types": "^6.16.1",
17+
"notion-types": "workspace:*",
1618
"react": "^17.0.2",
1719
"react-dom": "^17.0.2",
18-
"react-notion-x": "^6.16.1",
20+
"react-notion-x": "workspace:*",
1921
"react-scripts": "5.0.0",
2022
"typescript": "^4.6.3"
2123
},

examples/cra/public/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
You can add webfonts, meta tags, or analytics to this file.
4242
The build step will place the bundled scripts into the <body> tag.
4343
44-
To begin the development, run `npm start` or `yarn start`.
45-
To create a production bundle, use `npm run build` or `yarn build`.
44+
To begin the development, run `npm start` or `pnpm start`.
45+
To create a production bundle, use `npm run build` or `pnpm build`.
4646
-->
4747
</body>
4848
</html>

examples/full/lib/notion.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,11 @@ export async function getPage(pageId: string): Promise<ExtendedRecordMap> {
2828
}
2929

3030
export async function search(params: SearchParams): Promise<SearchResults> {
31-
return notion.search(params)
31+
if (notion instanceof NotionAPI) {
32+
return notion.search(params)
33+
} else {
34+
console.error(
35+
'NotionCompatAPI does not have a search method. Use NotionAPI instead.'
36+
)
37+
}
3238
}

examples/full/package.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,29 @@
44
"private": true,
55
"type": "commonjs",
66
"scripts": {
7-
"dev": "next dev",
87
"build": "next build",
8+
"clean": "rm -rf .next",
9+
"dev": "next dev",
10+
"lint": "next lint",
911
"start": "next start",
1012
"analyze": "cross-env ANALYZE=true next build",
1113
"analyze:server": "cross-env BUNDLE_ANALYZE=server next build",
1214
"analyze:browser": "cross-env BUNDLE_ANALYZE=browser next build",
13-
"deploy": "vercel deploy"
15+
"vercel-deploy": "vercel deploy"
1416
},
1517
"dependencies": {
1618
"@notionhq/client": "^1.0.4",
1719
"classnames": "^2.3.1",
1820
"got": "^12.0.2",
1921
"lqip-modern": "^1.2.0",
2022
"next": "^12.1.0",
21-
"notion-client": "^6.16.1",
22-
"notion-compat": "^6.16.1",
23-
"notion-utils": "^6.16.1",
23+
"notion-client": "workspace:*",
24+
"notion-compat": "workspace:*",
25+
"notion-types": "workspace:*",
26+
"notion-utils": "workspace:*",
2427
"p-map": "^5.3.0",
2528
"p-memoize": "^6.0.1",
29+
"prismjs": "^1.27.0",
2630
"react": "^17.0.2",
2731
"react-dom": "^17.0.2",
2832
"react-notion-x": "^6.16.1",

examples/full/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ First, run the development server:
2727
```bash
2828
npm run dev
2929
# or
30-
yarn dev
30+
pnpm dev
3131
```
3232

3333
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

examples/full/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"target": "es2016",
44
"lib": ["dom", "esnext"],
55
"allowJs": false,
6+
"composite": false,
67
"skipLibCheck": true,
78
"strict": false,
89
"forceConsistentCasingInFileNames": true,

0 commit comments

Comments
 (0)