Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#429 Migrate to turbo and pnpm #461

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
c277202
Migrated basics from yarn + lerna to turbo + pnpm
FranciscoMoretti Mar 29, 2023
731d04e
removed lerna file
FranciscoMoretti Mar 30, 2023
6bd2d86
replaced yarn with pnpm in comments and md files
FranciscoMoretti Mar 30, 2023
aaa69fc
handle possible NotionCompatAPI without search
FranciscoMoretti Mar 31, 2023
d30334a
build with tsup and turbo
FranciscoMoretti Apr 2, 2023
3dd9be4
remove disabling of typescript rule
FranciscoMoretti Apr 5, 2023
da8f686
updated contributing guide
FranciscoMoretti Apr 5, 2023
ec0cc23
add more details about pnpm workspaces
FranciscoMoretti Apr 6, 2023
70ff8f9
replaced npm with pnpm in some installs
FranciscoMoretti Apr 6, 2023
19427e0
reduce diff in tsconfig
FranciscoMoretti Apr 6, 2023
1c88179
remove unnecessary comment
FranciscoMoretti Apr 6, 2023
1f9e057
add a comment for building
FranciscoMoretti Apr 6, 2023
0a84e25
react-notion-x does not have ava tests
FranciscoMoretti Apr 6, 2023
bcff758
clean up test task in pipeline
FranciscoMoretti Apr 6, 2023
3c624c2
lint shouldn't depend on build
FranciscoMoretti Apr 6, 2023
d21f990
move linting test to pipeline
FranciscoMoretti Apr 6, 2023
2f50cbb
pretest no longer needed. Done in pipeline
FranciscoMoretti Apr 6, 2023
b95f095
added some spaces to contributing
FranciscoMoretti Apr 6, 2023
4647313
renamed test format task and used it only on root
FranciscoMoretti Apr 6, 2023
4ca4198
Added deploy workflow to pipeline
FranciscoMoretti Apr 6, 2023
14b6450
remove unnecessary caches
FranciscoMoretti Apr 8, 2023
bcf343a
renamed to avoid pnpm name collision
FranciscoMoretti Apr 8, 2023
b6feb5e
created publish task
FranciscoMoretti Apr 8, 2023
fd5c4ab
upgrade turbo version
FranciscoMoretti Apr 8, 2023
d07d2cb
define specific build actions in turbo
FranciscoMoretti Apr 8, 2023
2a5471e
renamed publish-package to publish
FranciscoMoretti Apr 8, 2023
0cbacab
updated turbo in pnpm lock
FranciscoMoretti Apr 8, 2023
02c58ca
updated lockfile version with newer pnpm
FranciscoMoretti Apr 8, 2023
c6cbe77
test-format doesn't have output
FranciscoMoretti Apr 8, 2023
c660f55
test already lints
FranciscoMoretti Apr 8, 2023
86f259f
bugfix: missing plugin declaration in prettierc
FranciscoMoretti Apr 8, 2023
a631391
simplify turbo.json
FranciscoMoretti Apr 8, 2023
fbbd365
Revert "bugfix: missing plugin declaration in prettierc"
FranciscoMoretti Apr 8, 2023
e7f57cd
bugfix: extra comma
FranciscoMoretti Apr 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules
# builds
build
dist
types

# misc
.DS_Store
Expand All @@ -24,3 +25,4 @@ yarn-error.log*

.next/
.vercel/
.turbo/
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run pre-commit
pnpm run pre-commit
35 changes: 20 additions & 15 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,44 @@ Suggestions and pull requests are highly encouraged. Have a look at the [open is

## Development

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

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

```bash
git clone https://github.com/NotionX/react-notion-x.git
cd react-notion-x
yarn
pnpm i
```

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.
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.

```bash
yarn dev
```
### Running development tasks

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.
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.

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

```bash
cd examples/minimal
yarn dev
turbo dev --filter=notion-x-example-minimal...
```

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`.
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.

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

### Gotchas

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.
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.

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.

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.

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.
### Build task

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.
Simply run the following command from the repository's root

```
turbo build
```
10 changes: 6 additions & 4 deletions examples/cra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@
"version": "6.16.0",
"private": true,
"scripts": {
"dev": "GENERATE_SOURCEMAP=false react-scripts start",
"start": "GENERATE_SOURCEMAP=false react-scripts start",
"build": "GENERATE_SOURCEMAP=false react-scripts build",
"eject": "GENERATE_SOURCEMAP=false react-scripts eject"
"dev": "GENERATE_SOURCEMAP=false react-scripts start",
"eject": "GENERATE_SOURCEMAP=false react-scripts eject",
"lint": "eslint \"src/**/*.ts*\"",
"clean": "rm -rf build"
},
"dependencies": {
"@types/node": "^16.11.26",
"@types/react": "^17.0.43",
"@types/react-dom": "^17.0.14",
"notion-types": "^6.15.6",
"notion-types": "workspace:*",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-notion-x": "^6.16.0",
"react-notion-x": "workspace:*",
"react-scripts": "5.0.0",
"typescript": "^4.6.3"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/cra/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.

To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
To begin the development, run `npm start` or `pnpm start`.
To create a production bundle, use `npm run build` or `pnpm build`.
-->
</body>
</html>
8 changes: 7 additions & 1 deletion examples/full/lib/notion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,11 @@ export async function getPage(pageId: string): Promise<ExtendedRecordMap> {
}

export async function search(params: SearchParams): Promise<SearchResults> {
return notion.search(params)
if (notion instanceof NotionAPI) {
return notion.search(params)
} else {
console.error(
'NotionCompatAPI does not have a search method. Use NotionAPI instead.'
)
}
}
13 changes: 8 additions & 5 deletions examples/full/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,26 @@
"private": true,
"type": "commonjs",
"scripts": {
"dev": "next dev",
"build": "next build",
"clean": "rm -rf .next",
"dev": "next dev",
"lint": "next lint",
"start": "next start",
"analyze": "cross-env ANALYZE=true next build",
"analyze:server": "cross-env BUNDLE_ANALYZE=server next build",
"analyze:browser": "cross-env BUNDLE_ANALYZE=browser next build",
"deploy": "vercel deploy"
"vercel-deploy": "vercel deploy"
},
"dependencies": {
"@notionhq/client": "^1.0.4",
"classnames": "^2.3.1",
"got": "^12.0.2",
"lqip-modern": "^1.2.0",
"next": "^12.1.0",
"notion-client": "^6.16.0",
"notion-compat": "^6.16.0",
"notion-utils": "^6.16.0",
"notion-client": "workspace:*",
"notion-compat": "workspace:*",
"notion-types": "workspace:*",
"notion-utils": "workspace:*",
"p-map": "^5.3.0",
"p-memoize": "^6.0.1",
"react": "^17.0.2",
Expand Down
2 changes: 1 addition & 1 deletion examples/full/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ First, run the development server:
```bash
npm run dev
# or
yarn dev
pnpm dev
```

Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
Expand Down
1 change: 1 addition & 0 deletions examples/full/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"target": "es2016",
"lib": ["dom", "esnext"],
"allowJs": false,
"composite": false,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
Expand Down
Loading