Skip to content

Commit

Permalink
chore(all): tsconfig sharing via internal package
Browse files Browse the repository at this point in the history
  • Loading branch information
serjilyashenko committed May 12, 2024
1 parent 7a2a104 commit 65fc627
Show file tree
Hide file tree
Showing 19 changed files with 96 additions and 49 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ simple-pie-project
└─ packages
├─ pie-math
├─ simple-pie
└─ react-simple-pie
├─ react-simple-pie
└─ tsconfig
```

## Installing packages
Expand Down
3 changes: 2 additions & 1 deletion apps/homepage-legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint": "tsc",
"lint-legacy": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
Expand Down
1 change: 1 addition & 0 deletions apps/homepage-legacy/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
Expand Down
16 changes: 15 additions & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,18 @@ Some common ones are:

## Linting

🚧TBD
TypeScript can be used in one of two ways - as a linter, or as a build tool.
`noEmit` prevents emitting files. So, TS is used to check source code's types.

tsconfig for `packages/*` is shared from the `packages/tsconfig` package. `apps/hompage-legacy` has
its own tsconfig

```mermaid
flowchart
T[packages/tsconfig] --> PM[packages/pie-math]
T --> SP[packages/simple-pie]
T --> RSP[packages/react-simple-pie]
HL[apps/homepage-legacy]
```

🚧 TBD
13 changes: 9 additions & 4 deletions docs/monorepo.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,22 @@ simple-pie-project
└─ packages
├─ pie-math
├─ simple-pie
└─ react-simple-pie
├─ react-simple-pie
└─ tsconfig
```

`packages/pie-math` includes all calculations (business logic).\
`packages/simple-pie` and `packages/react-simple-pie` are external and are published to npm.
They don't include any calculations and they are just "transport" packages (read more in [package-publishing.md](./package-publishing.md)).
They don't include any calculations and they are just "transport" packages (read more in [package-publishing.md](./package-publishing.md)).\
`packages/tsconfig` just shares tsconfigs for packages.

```mermaid
flowchart TD
PM[packages/pie-math] --> SP[packages/simple-pie]
PM[packages/pie-math] --> RSP[packages/react-simple-pie]
T[packages/tsconfig] --> PM[packages/pie-math]
T --> SP[packages/simple-pie]
PM --> SP
PM --> RSP[packages/react-simple-pie]
T --> RSP
SP --> HL[apps/homepage-legacy]
RSP --> HL
SP -.-> NPM[npm]
Expand Down
2 changes: 1 addition & 1 deletion docs/package-publishing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package publishing

The publishing is applied to the next packages:
The publishing is applied to external packages. The next ones:

- `packages/simple-pie`
- `packages/react-simple-pie`
Expand Down
12 changes: 10 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"dev": "turbo dev",
"build": "turbo build",
"build:packages": "turbo build --filter='./packages/*'",
"lint": "turbo lint",
"changeset": "npx changeset",
"release": "changeset publish",
"prettier": "prettier --write .",
Expand Down
5 changes: 4 additions & 1 deletion packages/pie-math/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"main": "./src/index.ts",
"private": true,
"scripts": {
"type-check": "tsc"
"lint": "tsc"
},
"devDependencies": {
"tsconfig": "*"
},
"author": "Serge Iyashenko <[email protected]>",
"repository": "https://github.com/serjilyashenko/simple-pie-project",
Expand Down
12 changes: 1 addition & 11 deletions packages/pie-math/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
{
"compilerOptions": {
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"module": "ESNext",
"moduleResolution": "Bundler",
"preserveWatchOutput": true,
"skipLibCheck": true,
"noEmit": true,
"strict": true
},
"extends": "tsconfig/pkg.json",
"include": ["src"],
"exclude": ["node_modules"]
}
4 changes: 1 addition & 3 deletions packages/react-simple-pie/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
"scripts": {
"dev": "npm run build -- --watch",
"build": "tsup src/index.ts --format cjs,esm --dts --minify",
"npm:publish": "npm version patch && npm publish",
"type-check": "tsc",
"lint": "eslint src"
"lint": "tsc"
},
"devDependencies": {
"@types/react": "18.2.64",
Expand Down
12 changes: 2 additions & 10 deletions packages/react-simple-pie/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
{
"extends": "tsconfig/pkg.json",
"compilerOptions": {
"jsx": "react-jsx",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"module": "ESNext",
"moduleResolution": "Bundler",
"preserveWatchOutput": true,
"skipLibCheck": true,
"noEmit": true,
"strict": true
"jsx": "react-jsx"
},
"include": ["src"],
"exclude": ["node_modules"]
Expand Down
4 changes: 1 addition & 3 deletions packages/simple-pie/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
"scripts": {
"dev": "npm run build -- --watch",
"build": "tsup src/index.ts --format cjs,esm --dts --minify",
"npm:publish": "npm version patch && npm publish",
"type-check": "tsc",
"lint": "eslint src"
"lint": "tsc"
},
"devDependencies": {
"pie-math": "*",
Expand Down
12 changes: 1 addition & 11 deletions packages/simple-pie/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
{
"compilerOptions": {
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"module": "ESNext",
"moduleResolution": "Bundler",
"preserveWatchOutput": true,
"skipLibCheck": true,
"noEmit": true,
"strict": true
},
"extends": "tsconfig/pkg.json",
"include": ["src"],
"exclude": ["node_modules"]
}
4 changes: 4 additions & 0 deletions packages/tsconfig/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "tsconfig",
"private": true
}
16 changes: 16 additions & 0 deletions packages/tsconfig/pkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"module": "ESNext",
"moduleResolution": "Bundler",
"preserveWatchOutput": true,
"skipLibCheck": true,
"noEmit": true,
"strict": true
},
"include": ["src"],
"exclude": ["node_modules"]
}
24 changes: 24 additions & 0 deletions packages/tsconfig/vite.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,

"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",

"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
Empty file.
1 change: 1 addition & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"dependsOn": ["^build"],
"outputs": ["dist/**"]
},
"lint": {},
"dev": {
"cache": false,
"persistent": true,
Expand Down

0 comments on commit 65fc627

Please sign in to comment.