Skip to content

Commit

Permalink
feat(typescript-config)!: add typeScript configuration files for `bro…
Browse files Browse the repository at this point in the history
…wser`, `service`, `browser-package` and `node-package` environments (#28)
  • Loading branch information
njfamirm authored Jan 6, 2025
2 parents 348dbf9 + 8e8437d commit dd7fd5b
Show file tree
Hide file tree
Showing 14 changed files with 97 additions and 41 deletions.
9 changes: 4 additions & 5 deletions lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
"type": "refactor",
"section": "Code Refactoring"
},
{
"type": "doc",
"section": "Documentation"
},
{
"type": "chore",
"section": "Miscellaneous Chores",
Expand All @@ -45,11 +49,6 @@
"section": "Documentation",
"hidden": true
},
{
"type": "doc",
"section": "Documentation",
"hidden": true
},
{
"type": "deps",
"section": "Dependencies update",
Expand Down
7 changes: 2 additions & 5 deletions packages/alpine/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
{
"extends": "@nexim/typescript-config/tsconfig.json",
"extends": "@nexim/typescript-config/tsconfig.browser.lib.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"emitDeclarationOnly": true,
"composite": true,
"types": ["@alwatr/nano-build", "@alwatr/type-helper"]
},
"include": ["src/**/*.ts"],
"references": []
"include": ["src/**/*.ts", "src/*.ts"]
}
7 changes: 2 additions & 5 deletions packages/element/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
{
"extends": "@nexim/typescript-config/tsconfig.json",
"extends": "@nexim/typescript-config/tsconfig.browser.lib.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"emitDeclarationOnly": true,
"composite": true,
"types": ["@alwatr/nano-build", "@alwatr/type-helper"]
},
"include": ["src/**/*.ts"],
"references": []
"include": ["src/**/*.ts", "src/*.ts"]
}
7 changes: 2 additions & 5 deletions packages/google-analytics/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
{
"extends": "@nexim/typescript-config/tsconfig.json",
"extends": "@nexim/typescript-config/tsconfig.browser.lib.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"emitDeclarationOnly": true,
"composite": true,
"types": ["@alwatr/nano-build", "@alwatr/type-helper"]
},
"include": ["src/**/*.ts"],
"references": []
"include": ["src/**/*.ts", "src/*.ts"],
}
7 changes: 2 additions & 5 deletions packages/service-worker/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
{
"extends": "@nexim/typescript-config/tsconfig.json",
"extends": "@nexim/typescript-config/tsconfig.browser.lib.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"emitDeclarationOnly": true,
"composite": true,
"types": ["@alwatr/nano-build", "@alwatr/type-helper"]
},
"include": ["src/**/*.ts"],
"references": []
"include": ["src/**/*.ts", "src/*.ts"]
}
59 changes: 48 additions & 11 deletions packages/typescript-config/README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,68 @@
# Nexim TypeScript Config
# Nexim TypeScript Configuration

![NPM Version](https://img.shields.io/npm/v/@nexim/typescript-config)
![Build & Lint & Test](https://github.com/the-nexim/nanolib/actions/workflows/build-lint-test.yaml/badge.svg)
![NPM Downloads](https://img.shields.io/npm/dm/@nexim/typescript-config)
![NPM License](https://img.shields.io/npm/l/@nexim/typescript-config)

## Overview
This package provides pre-configured settings for using TypeScript in Nexim projects.

This is a base TypeScript configuration for Nexim projects.
## Installation

## installation
Install the package as a development dependency:

```bash
yarn add -D @nexim/typescript-config
```

## Usage

Create a `tsconfig.json` file in the root of your project:
To use this configuration, create a `tsconfig.json` file in the root of your project and extend one of the provided configurations:

### Base Configuration (`tsconfig.base.json`)

This configuration contains the fundamental settings shared by all other configurations. It's generally not used directly, but serves as the foundation for other, more specific configurations.

### Browser Application (`tsconfig.browser.app.json`)

Use this configuration for browser-based applications. It extends the base configuration and is primarily used for type checking during development. It doesn't produce build outputs.

```json
{
"extends": "@nexim/typescript-config/tsconfig.browser.app.json",
"include": ["src/**/*.ts", "src/*.ts"] // Include all TypeScript files in your source directory
}
```

### Browser Library (`tsconfig.browser.lib.json`)

Use this configuration for browser-based libraries. extends the base configuration, generates declaration files (\*.d.ts), and supports referencing other projects.

```json
{
"extends": "@nexim/typescript-config/tsconfig.browser.lib.json",
"include": ["src/**/*.ts", "src/*.ts"] // Include all TypeScript files in your source directory
}
```

### Node.js Application (`tsconfig.node.app.json`)

Use this configuration for nodejs-based applications. It extends the base configuration and includes Node.js specific type definitions. It doesn't produce build outputs and primarily used for type checking during development.

```json
{
"extends": "@nexim/typescript-config/tsconfig.node.app.json",
"include": ["src/**/*.ts", "src/*.ts"] // Include all TypeScript files in your source directory
}
```

### Node.js Library (`tsconfig.node.lib.json`)

Use this configuration for nodejs-based libraries. extends the base configuration, incorporates Node.js type definitions, generates declaration files (\*.d.ts), and supports referencing other projects.

```json
{
"extends": "@nexim/typescript-config",
"compilerOptions": {
"rootDir": "src",
"outDir": "dist"
},
"include": ["src/**/*.ts"]
"extends": "@nexim/typescript-config/tsconfig.node.lib.json",
"include": ["src/**/*.ts", "src/*.ts"] // Include all TypeScript files in your source directory
}
```
7 changes: 5 additions & 2 deletions packages/typescript-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@
"contributors": [
"Arash Ghardashpoor <[email protected]> (https://www.agpagp.ir)"
],
"main": "tsconfig.json",
"peerDependencies": {
"typescript": "^5"
},
"main": "tsconfig.base.json",
"files": [
"**/*.{js,mjs,cjs,map,d.ts,html,md,LEGAL.txt}",
"tsconfig.json",
"tsconfig*.json",
"LICENSE"
],
"publishConfig": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
// "outFile": "./",
// "outDir": "./",
// "rootDir": "./src",
"composite": true,
// "tsBuildInfoFile": ".tsbuildinfo",
// "removeComments": true,
// "noEmit": true,
Expand Down
6 changes: 6 additions & 0 deletions packages/typescript-config/tsconfig.browser.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"noEmit": true,
},
}
7 changes: 7 additions & 0 deletions packages/typescript-config/tsconfig.browser.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"composite": true,
},
}
7 changes: 7 additions & 0 deletions packages/typescript-config/tsconfig.node.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"noEmit": true,
"types": ["node"]
},
}
8 changes: 8 additions & 0 deletions packages/typescript-config/tsconfig.node.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"emitDeclarationOnly": true,
"composite": true,
"types": ["node"]
},
}
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "@nexim/typescript-config/tsconfig.json",
"extends": "@nexim/typescript-config/tsconfig.base.json",
"compilerOptions": {
"noEmit": true,
"types": ["node"]
Expand All @@ -11,7 +11,7 @@
"path": "./packages/element"
},
{
"path": "./packages/typescript-config"
"path": "./packages/typescript-config/tsconfig.base.json"
},
{
"path": "./packages/alpine"
Expand Down
2 changes: 2 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,8 @@ __metadata:
"@nexim/typescript-config@workspace:^, @nexim/typescript-config@workspace:packages/typescript-config":
version: 0.0.0-use.local
resolution: "@nexim/typescript-config@workspace:packages/typescript-config"
peerDependencies:
typescript: ^5
languageName: unknown
linkType: soft

Expand Down

0 comments on commit dd7fd5b

Please sign in to comment.