Skip to content

Commit

Permalink
Setup Preconstruct
Browse files Browse the repository at this point in the history
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
  • Loading branch information
anttimaki committed Nov 29, 2021
1 parent 2d23ba7 commit 02c70bf
Show file tree
Hide file tree
Showing 10 changed files with 2,625 additions and 5,628 deletions.
11 changes: 10 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,14 @@
"rules": {
"react/react-in-jsx-scope": "off",
"react/prop-types": "off"
}
},
"overrides": [
{
"files": "*.js",
// rule overrides for js config files (next.config.js, etc.)
"rules": {
"@typescript-eslint/no-var-requires": "off"
}
}
]
}
2 changes: 1 addition & 1 deletion .github/actions/get-node-version/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {readFileSync} from "fs";
}

const typesVersionRangeString = semver.validRange(
packageJson.devDependencies["@types/node"]
packageJson.dependencies["@types/node"]
);
if (!typesVersionRangeString) {
setFailed(`Invalid types version range: ${typesVersionRangeString}`);
Expand Down
3 changes: 3 additions & 0 deletions apps/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();
7 changes: 4 additions & 3 deletions apps/nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{
"name": "@thunderstore/nextjs",
"version": "0.1.0",
"repository": "https://github.com/thunderstore-io/thunderstore-ui/tree/master/nextjs",
"repository": "https://github.com/thunderstore-io/thunderstore-ui/tree/master/apps/nextjs",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "^11.1.0",
"thunderstore-components": "^0.1.0"
"@thunderstore/components": "^0.1.0",
"next": "^11.1.0"
},
"devDependencies": {
"@preconstruct/next": "^3.0.1",
"eslint-config-next": "^11.1.2"
}
}
3,063 changes: 0 additions & 3,063 deletions apps/nextjs/yarn.lock

This file was deleted.

14 changes: 14 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
presets: [
[
"@babel/preset-env",
{
modules: false,
loose: true,
},
],
"@babel/preset-react",
"@babel/preset-typescript",
],
plugins: ["@babel/plugin-transform-runtime"],
};
27 changes: 20 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
{
"private": true,
"name": "@thunderstore/ui",
"repository": "https://github.com/thunderstore-io/thunderstore-ui",
"private": true,
"workspaces": [
"nextjs",
"thunderstore-components"
"apps/*",
"packages/*"
],
"scripts": {
"postinstall": "preconstruct dev",
"build": "preconstruct build"
},
"engines": {
"node": "^16.6.0"
},
"dependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@babel/core": "^7.16.0",
"@babel/plugin-transform-runtime": "^7.16.4",
"@babel/preset-env": "^7.16.4",
"@babel/preset-react": "^7.16.0",
"@babel/preset-typescript": "^7.16.0",
"@microsoft/eslint-formatter-sarif": "^2.1.5",
"@preconstruct/cli": "^2.1.5",
"@types/node": "^16.6.2",
"@types/react": "^17.0.19",
"@typescript-eslint/eslint-plugin": "^4.29.3",
Expand All @@ -25,6 +31,13 @@
"eslint-plugin-prettier": "^3.4.1",
"eslint-plugin-react": "^7.25.1",
"prettier": "^2.3.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"typescript": "^4.4.2"
},
"preconstruct": {
"packages": [
"packages/*"
]
}
}
8 changes: 6 additions & 2 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
"name": "@thunderstore/components",
"version": "0.1.0",
"description": "Shared components for Thunderstore",
"repository": "https://github.com/thunderstore-io/thunderstore-ui/tree/master/thunderstore-components",
"main": "./dist/index.js",
"repository": "https://github.com/thunderstore-io/thunderstore-ui/tree/master/packages/components",
"main": "dist/thunderstore-components.cjs.js",
"module": "dist/thunderstore-components.esm.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "tsc",
"dev": "tsc --watch"
Expand Down
Loading

0 comments on commit 02c70bf

Please sign in to comment.