@ocavue/tsconfig 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ github: [ocavue]
@@ -0,0 +1,26 @@
1
+ name: Setup
2
+ description: Setup the environment
3
+
4
+ inputs:
5
+ node-version:
6
+ description: The version of node.js
7
+ required: false
8
+ default: '18'
9
+
10
+ runs:
11
+ using: composite
12
+ steps:
13
+ - name: Install pnpm
14
+ run: corepack enable
15
+ shell: bash
16
+
17
+ - name: Setup node
18
+ uses: actions/setup-node@v4
19
+ with:
20
+ node-version: ${{ inputs.node-version }}
21
+ cache: pnpm
22
+ registry-url: 'https://registry.npmjs.org'
23
+
24
+ - name: Install
25
+ run: pnpm install
26
+ shell: bash
@@ -0,0 +1,34 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+
8
+ jobs:
9
+ version:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: googleapis/release-please-action@v4
13
+ id: release-please
14
+ with:
15
+ release-type: node
16
+ outputs:
17
+ release_created: ${{ steps.release-please.outputs.release_created }}
18
+
19
+ publish:
20
+ runs-on: ubuntu-latest
21
+ needs: [version]
22
+ if: ${{ needs.version.outputs.release_created }}
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+
26
+ - uses: ./.github/actions/setup
27
+
28
+ - name: Build
29
+ run: pnpm run build
30
+
31
+ - name: Publish to NPM
32
+ run: pnpm publish
33
+ env:
34
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/CHANGELOG.md ADDED
@@ -0,0 +1,22 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2024-12-28)
4
+
5
+
6
+ ### Features
7
+
8
+ * add tsconfig files ([b133827](https://github.com/ocavue/tsconfig/commit/b133827c08a645b0b7663e1ce0b2460a6798b12d))
9
+ * enable composite ([bcd2ae4](https://github.com/ocavue/tsconfig/commit/bcd2ae46c81fd6a32c6d027b3f8092e1361be26c))
10
+ * refactor ([b8e7992](https://github.com/ocavue/tsconfig/commit/b8e79926cb144cfc1e136604e15dce6b8667d4e1))
11
+ * use different outDir paths ([f9b6d1e](https://github.com/ocavue/tsconfig/commit/f9b6d1e97f491bfceb7b52e6e3713f1cbeb5a9d3))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * fix exports in package.json ([8c1edb3](https://github.com/ocavue/tsconfig/commit/8c1edb3b9405c6e23c1af57695eb677f08fb1b81))
17
+ * set rootDir in tsc.json ([686e434](https://github.com/ocavue/tsconfig/commit/686e434dea0f6ee5a6e42855aa3d0a92cf3d24bc))
18
+
19
+
20
+ ### Miscellaneous Chores
21
+
22
+ * trigger release ([2ff890b](https://github.com/ocavue/tsconfig/commit/2ff890bc7d3d070d9414895b2696a1647a302b00))
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 ocavue
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,137 @@
1
+ # @ocavue/tsconfig
2
+
3
+ [![NPM version](https://img.shields.io/npm/v/@ocavue/tsconfig?color=a1b858&label=)](https://www.npmjs.com/package/@ocavue/tsconfig)
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @ocavue/tsconfig
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Application
14
+
15
+ If you are building an application, create a `tsconfig.json` in the root of your project.
16
+
17
+ ```
18
+ my-app/
19
+ ├── node_modules/
20
+ ├── components/
21
+ │   └── button.ts
22
+ ├── pages/
23
+ │   └── home.ts
24
+ ├── eslint.config.js
25
+ ├── vitest.config.ts
26
+ ├── package.json
27
+ └── tsconfig.json
28
+ ```
29
+
30
+ In `tsconfig.json`, add the following content based on your target environment.
31
+
32
+ ```jsonc
33
+ // tsconfig.json
34
+ {
35
+ // If you're building for the browser:
36
+ "extends": "@ocavue/tsconfig/dom/app",
37
+
38
+ // If you're building for non-browser environment:
39
+ "extends": "@ocavue/tsconfig/es/app"
40
+ }
41
+ ```
42
+
43
+ ### Library
44
+
45
+ If you are building a library, put all your source code in the `src` directory, and create `tsconfig.json` and `tsconfig.build.json` in the root of your project.
46
+
47
+ ```
48
+ my-lib/
49
+ ├── dist/
50
+ │   └── index.js
51
+ ├── src/
52
+ │   └── index.ts
53
+ ├── eslint.config.js
54
+ ├── vitest.config.ts
55
+ ├── package.json
56
+ ├── tsconfig.build.json
57
+ └── tsconfig.json
58
+ ```
59
+
60
+ In `tsconfig.json`, add the following content:
61
+
62
+ ```jsonc
63
+ // tsconfig.json
64
+ {
65
+ "extends": "@ocavue/tsconfig/es/root",
66
+ "references": [{ "path": "./tsconfig.build.json" }]
67
+ }
68
+ ```
69
+
70
+ In `tsconfig.build.json`, add the following content based on your build tool and your target environment.
71
+
72
+ ```jsonc
73
+ // tsconfig.build.json
74
+ {
75
+ // If you're building for the browser and using a bundler like esbuild, vite, tsup etc:
76
+ "extends": "@ocavue/tsconfig/dom/build-bundler",
77
+
78
+ // If you're building for the browser and using tsc:
79
+ "extends": "@ocavue/tsconfig/dom/build-tsc",
80
+
81
+ // If you're building for non-browser environment and using a bundler like esbuild, vite, tsup etc:
82
+ "extends": "@ocavue/tsconfig/es/build-bundler",
83
+
84
+ // If you're building for non-browser environment and using tsc:
85
+ "extends": "@ocavue/tsconfig/es/build-tsc"
86
+ }
87
+ ```
88
+
89
+ ### Monorepo
90
+
91
+ If you are using a monorepo that might have multiple packages and applications, you should have a file structure like this:
92
+
93
+ ```
94
+ my-monorepo/
95
+ ├── node_modules/
96
+ ├── packages/
97
+ │   └── my-lib/
98
+ │   ├── src/
99
+ │   ├── dist/
100
+ │   ├── vitest.config.ts
101
+ │   ├── package.json
102
+ │   └── tsconfig.json
103
+ ├── apps/
104
+ │   └── my-app/
105
+ │   ├── pages/
106
+ │   ├── components/
107
+ │   ├── vitest.config.ts
108
+ │   ├── package.json
109
+ │   ├── tsconfig.build.json
110
+ │   └── tsconfig.json
111
+ ├── eslint.config.js
112
+ ├── package.json
113
+ └── tsconfig.json
114
+ ```
115
+
116
+ In the root `tsconfig.json`, add the following content:
117
+
118
+ ```jsonc
119
+ // tsconfig.json
120
+ {
121
+ "extends": "@ocavue/tsconfig/es/root",
122
+ "references": [
123
+ { "path": "./apps/my-app/tsconfig.json" },
124
+ { "path": "./packages/my-lib/tsconfig.json" }
125
+ ]
126
+ }
127
+ ```
128
+
129
+ Configure each package and application's `tsconfig.json` based on the instructions above.
130
+
131
+ ## Version Requirements
132
+
133
+ The [`${configDir}`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#the-configdir-template-variable-for-configuration-files) template variable is used so you need to install TypeScript v5.5 or higher.
134
+
135
+ ## License
136
+
137
+ MIT
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@ocavue/tsconfig",
3
+ "type": "module",
4
+ "version": "0.1.0",
5
+ "description": "A collection of reusable TypeScript configurations",
6
+ "author": "ocavue <ocavue@gmail.com>",
7
+ "license": "MIT",
8
+ "funding": "https://github.com/sponsors/ocavue",
9
+ "homepage": "https://github.com/ocavue/tsconfig#readme",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/ocavue/tsconfig.git"
13
+ },
14
+ "bugs": "https://github.com/ocavue/tsconfig/issues",
15
+ "keywords": [
16
+ "tsconfig",
17
+ "typescript",
18
+ "config"
19
+ ],
20
+ "exports": {
21
+ "./es/app": "./src/es/app.json",
22
+ "./es/build-bundler": "./src/es/build-bundler.json",
23
+ "./es/build-tsc": "./src/es/build-tsc.json",
24
+ "./es/root": "./src/es/root.json",
25
+ "./dom/app": "./src/dom/app.json",
26
+ "./dom/build-bundler": "./src/dom/build-bundler.json",
27
+ "./dom/build-tsc": "./src/dom/build-tsc.json",
28
+ "./dom/root": "./src/dom/root.json"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ }
33
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": [
4
+ "../es/app.json",
5
+ "../shared/dom.json",
6
+ ]
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": [
4
+ "../es/build-bundler.json",
5
+ "../shared/dom.json",
6
+ ]
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": [
4
+ "../es/build-tsc.json",
5
+ "../shared/dom.json",
6
+ ]
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": [
4
+ "../es/root.json",
5
+ "../shared/dom.json",
6
+ ]
7
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "outDir": "${configDir}/node_modules/.cache/ocavue-tsconfig/app",
5
+ "tsBuildInfoFile": "${configDir}/node_modules/.cache/ocavue-tsconfig/app/tsconfig.tsbuildinfo"
6
+ },
7
+ "extends": [
8
+ "../shared/base.json",
9
+ "../include/all.json",
10
+ "../module/bundler.json",
11
+ ]
12
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "outDir": "${configDir}/node_modules/.cache/ocavue-tsconfig/build-bundler",
5
+ "tsBuildInfoFile": "${configDir}/node_modules/.cache/ocavue-tsconfig/build-bundler/tsconfig.tsbuildinfo"
6
+ },
7
+ "extends": [
8
+ "../shared/base.json",
9
+ "../include/src.json",
10
+ "../module/bundler.json",
11
+ ]
12
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "outDir": "${configDir}/dist",
5
+ "tsBuildInfoFile": "${configDir}/dist/tsconfig.tsbuildinfo"
6
+ },
7
+ "extends": [
8
+ "../shared/base.json",
9
+ "../include/src.json",
10
+ "../module/node.json",
11
+ ]
12
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "outDir": "${configDir}/node_modules/.cache/ocavue-tsconfig/root",
5
+ "tsBuildInfoFile": "${configDir}/node_modules/.cache/ocavue-tsconfig/root/tsconfig.tsbuildinfo"
6
+ },
7
+ "extends": [
8
+ "../shared/base.json",
9
+ "../include/root.json",
10
+ "../module/bundler.json",
11
+ ]
12
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "include": [
4
+ "${configDir}/**/*"
5
+ ]
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "include": [
4
+ "${configDir}/*"
5
+ ]
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "include": [
4
+ "${configDir}/src/**/*"
5
+ ]
6
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "module": "preserve",
5
+ "moduleResolution": "bundler",
6
+ "emitDeclarationOnly": true,
7
+ }
8
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ }
7
+ }
@@ -0,0 +1,43 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "target": "ES2020",
5
+ "lib": [
6
+ "ESNext",
7
+ "ESNext.AsyncIterable"
8
+ ],
9
+ // Enable all strict type-checking options.
10
+ "strict": true,
11
+ // Disable unused local variables.
12
+ "noUnusedLocals": true,
13
+ // Force you to use `override` keyword when overriding a method.
14
+ "noImplicitOverride": true,
15
+ // Disable fallthrough cases in switch statements.
16
+ "noFallthroughCasesInSwitch": true,
17
+ // Emit additional JavaScript to ease support for importing CommonJS
18
+ // modules. This is necessary for some libraries with CommonJS/AMD/UMD
19
+ // modules.
20
+ "esModuleInterop": true,
21
+ // Skip type checking all .d.ts files. This improves performance and
22
+ // reduces the number of errors that you cannot fix directly.
23
+ "skipLibCheck": true,
24
+ // Allow JavaScript files to be included in the project.
25
+ "allowJs": true,
26
+ // Allow JSON files to be imported as modules.
27
+ "resolveJsonModule": true,
28
+ // Force TypeScript to consider all files as modules. This helps to avoid
29
+ // ['cannot redeclare block-scoped variable'](https://www.totaltypescript.com/cannot-redeclare-block-scoped-variable)
30
+ // errors.
31
+ "moduleDetection": "force",
32
+ // Prevents a few TS features which are unsafe when treating modules as
33
+ // isolated files.
34
+ "isolatedModules": true,
35
+ // Force you to use import type and export type
36
+ "verbatimModuleSyntax": true,
37
+ // Ensure that casing is correct in imports.
38
+ "forceConsistentCasingInFileNames": true,
39
+ // Allow TypeScript to cache build information and skip compilation
40
+ // when no changes are detected.
41
+ "composite": true,
42
+ }
43
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "compilerOptions": {
4
+ "lib": [
5
+ "ESNext",
6
+ "ESNext.AsyncIterable",
7
+ "DOM",
8
+ "DOM.Iterable",
9
+ "DOM.AsyncIterable"
10
+ ],
11
+ }
12
+ }