Skip to content

Commit 94c6799

Browse files
committed
Setup Preconstruct
Basically the changes done here are the results of following this tutorial: https://monorepo.guide/getting-started . Additionally some changes are from an earlier pr (#37), which was also about setting up Preconstruct. * Add Preconstruct as dependency * Setup Babel and ESLint * Rename workspaces to use the structure used in the tutorial. I don't know if this is some convention oslt, but it seems like a nice, clear structure for the repo * Add a script for using Preconstruct, and a postinstall hook to run it automatically while devving (see root package.json) * Move all devDependencies to dependencies on root package.json. This was recommended by Preconstruct, but I can't quite recall why
1 parent 2d23ba7 commit 94c6799

File tree

9 files changed

+2624
-5627
lines changed

9 files changed

+2624
-5627
lines changed

.eslintrc.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,14 @@
2828
"rules": {
2929
"react/react-in-jsx-scope": "off",
3030
"react/prop-types": "off"
31-
}
31+
},
32+
"overrides": [
33+
{
34+
"files": "*.js",
35+
// rule overrides for js config files (next.config.js, etc.)
36+
"rules": {
37+
"@typescript-eslint/no-var-requires": "off"
38+
}
39+
}
40+
]
3241
}

apps/nextjs/next.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const withPreconstruct = require("@preconstruct/next");
2+
3+
module.exports = withPreconstruct();

apps/nextjs/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
{
22
"name": "@thunderstore/nextjs",
33
"version": "0.1.0",
4-
"repository": "https://github.com/thunderstore-io/thunderstore-ui/tree/master/nextjs",
4+
"repository": "https://github.com/thunderstore-io/thunderstore-ui/tree/master/apps/nextjs",
55
"private": true,
66
"scripts": {
77
"dev": "next dev",
88
"build": "next build",
99
"start": "next start"
1010
},
1111
"dependencies": {
12-
"next": "^11.1.0",
13-
"thunderstore-components": "^0.1.0"
12+
"@thunderstore/components": "^0.1.0",
13+
"next": "^11.1.0"
1414
},
1515
"devDependencies": {
16+
"@preconstruct/next": "^3.0.1",
1617
"eslint-config-next": "^11.1.2"
1718
}
1819
}

apps/nextjs/yarn.lock

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

babel.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
"@babel/preset-env",
5+
{
6+
modules: false,
7+
loose: true,
8+
},
9+
],
10+
"@babel/preset-react",
11+
"@babel/preset-typescript",
12+
],
13+
plugins: ["@babel/plugin-transform-runtime"],
14+
};

package.json

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
{
2-
"private": true,
2+
"name": "@thunderstore/ui",
33
"repository": "https://github.com/thunderstore-io/thunderstore-ui",
4+
"private": true,
45
"workspaces": [
5-
"nextjs",
6-
"thunderstore-components"
6+
"apps/*",
7+
"packages/*"
78
],
9+
"scripts": {
10+
"postinstall": "preconstruct dev",
11+
"build": "preconstruct build"
12+
},
813
"engines": {
914
"node": "^16.6.0"
1015
},
1116
"dependencies": {
12-
"react": "^17.0.2",
13-
"react-dom": "^17.0.2"
14-
},
15-
"devDependencies": {
1617
"@babel/core": "^7.16.0",
18+
"@babel/plugin-transform-runtime": "^7.16.4",
19+
"@babel/preset-env": "^7.16.4",
20+
"@babel/preset-react": "^7.16.0",
21+
"@babel/preset-typescript": "^7.16.0",
1722
"@microsoft/eslint-formatter-sarif": "^2.1.5",
23+
"@preconstruct/cli": "^2.1.5",
1824
"@types/node": "^16.6.2",
1925
"@types/react": "^17.0.19",
2026
"@typescript-eslint/eslint-plugin": "^4.29.3",
@@ -25,6 +31,13 @@
2531
"eslint-plugin-prettier": "^3.4.1",
2632
"eslint-plugin-react": "^7.25.1",
2733
"prettier": "^2.3.2",
34+
"react": "^17.0.2",
35+
"react-dom": "^17.0.2",
2836
"typescript": "^4.4.2"
37+
},
38+
"preconstruct": {
39+
"packages": [
40+
"packages/*"
41+
]
2942
}
3043
}

packages/components/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@
22
"name": "@thunderstore/components",
33
"version": "0.1.0",
44
"description": "Shared components for Thunderstore",
5-
"repository": "https://github.com/thunderstore-io/thunderstore-ui/tree/master/thunderstore-components",
6-
"main": "./dist/index.js",
5+
"repository": "https://github.com/thunderstore-io/thunderstore-ui/tree/master/packages/components",
6+
"main": "dist/thunderstore-components.cjs.js",
7+
"module": "dist/thunderstore-components.esm.js",
78
"types": "./dist/index.d.ts",
9+
"files": [
10+
"dist"
11+
],
812
"scripts": {
913
"build": "tsc",
1014
"dev": "tsc --watch"

0 commit comments

Comments
 (0)