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

chore: use preconstruct to manage monorepo #37

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 10 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,14 @@
],
"rules": {
"react/react-in-jsx-scope": "off"
}
},
"overrides": [
{
"files": "*.js",
// rule overrides for js config files (next.config.js, etc.)
"rules": {
"@typescript-eslint/no-var-requires": "off"
}
}
]
Comment on lines +31 to +39
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allows us to use require statements in .js files, which I imagine will mostly be configuration files for this project.

}
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Thunderstore UI

## Monorepo Setup

- [`yarn` workspaces](https://classic.yarnpkg.com/en/docs/workspaces/) for
managing the packages in the monorepo (see `packages` key in base
`package.json` file)
- [`preconstruct`](https://preconstruct.tools/) tool takes a lot of the pain
out of managing a monorepo
- code behaves the same in dev as it will in production
Comment on lines +8 to +10
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels a bit 3rd person/an extract from the docs instead of more of a guide/explanation of how the tool works with/is used in the repo

- packages linked locally via `preconstruct dev` (runs automatically in
`postinstall` hook) without needing to manually build anything
Comment on lines +11 to +12
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

runs automatically in postinstall hook

From preconstruct's docs:

If you're in a monorepo, you should also run yarn preconstruct dev and add it to a postinstall script("postinstall": "preconstruct dev") that runs preconstruct dev so that you can import your code without having to rebuild your project every time in changes.

Where is this actually setup?

- `nextjs` workspace uses `@preconstruct/next` plugin to integrate
Comment on lines +8 to +13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could include some documentation on exactly how to setup the project from after git clone which includes how to start the Next.js dev server and having the components automatically compiled (this might change with #28 or at least how important knowing how to start Next.js is but having the commands for the typical running dev environments would help, e.g. components and storybook, components and Next.js, just Next.js (if that's even useful)).

13 changes: 13 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
presets: [
"@babel/preset-typescript",
"@babel/preset-react",
[
"@babel/preset-env",
{
modules: false,
loose: true,
},
],
],
};
3 changes: 3 additions & 0 deletions nextjs/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const withPreconstruct = require("@preconstruct/next");

module.exports = withPreconstruct();
3 changes: 3 additions & 0 deletions nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
"dependencies": {
"next": "^10.0.7",
"thunderstore-components": "^0.1.0"
},
"devDependencies": {
"@preconstruct/next": "^2.0.0"
}
}
19 changes: 15 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
{
"private": true,
"name": "thunderstore-ui",
"workspaces": [
"nextjs",
"thunderstore-components"
],
"repository": "https://github.com/thunderstore-io/thunderstore-ui",
"dependencies": {
"react": "^17.0.1",
"react-dom": "^17.0.1"
"scripts": {
"build": "preconstruct build && yarn workspace nextjs build",
"prepare": "preconstruct dev"
},
"devDependencies": {
"dependencies": {
"@babel/core": "^7.13.8",
"@babel/preset-env": "^7.13.9",
"@babel/preset-react": "^7.12.13",
"@babel/preset-typescript": "^7.13.0",
"@microsoft/eslint-formatter-sarif": "^2.1.5",
"@preconstruct/cli": "^2.0.6",
"@types/node": "^14.14.31",
"@types/react": "^17.0.2",
"@typescript-eslint/eslint-plugin": "^4.16.1",
Expand All @@ -22,5 +28,10 @@
"eslint-plugin-react": "^7.22.0",
"prettier": "^2.2.1",
"typescript": "^4.2.3"
},
"preconstruct": {
"packages": [
"thunderstore-components"
]
}
}
13 changes: 7 additions & 6 deletions thunderstore-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
"version": "0.1.0",
"description": "Shared components for Thunderstore",
"repository": "https://github.com/thunderstore-io/thunderstore-ui/tree/master/thunderstore-components",
"scripts": {
"build": "tsc",
"dev": "tsc --watch"
},
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"main": "dist/thunderstore-components.cjs.js",
"module": "dist/thunderstore-components.esm.js",
"dependencies": {
"@chakra-ui/react": "^1.3.3",
"@emotion/react": "^11.1.5",
"@emotion/styled": "^11.1.5",
"framer-motion": "^3.10.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
Comment on lines +16 to +17
Copy link
Member

@nihaals nihaals Mar 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't this need to be part of nextjs?

"react-hook-form": "^6.15.4"
},
"devDependencies": {}
Expand Down
Loading