|
1 |
| -# esbuild plugin typescript |
| 1 | +<div align="center"> |
2 | 2 |
|
3 |
| -  |
| 3 | +<img width="196" src="https://raw.githubusercontent.com/simonkovtyk/esbuild-plugin-package-json/d7d77d5766ef9ef97f157c2d221d61a7d3cef51c/docs/esbuild-favicon.svg" /> |
4 | 4 |
|
5 |
| -The plugin enhances the build process by seamlessly integrating TypeScript, offering powerful features like type checking, automatic generation of .d.ts files, and ensuring robust type safety |
6 |
| -throughout. |
| 5 | +<h1>TypeScript Plugin</h1> |
7 | 6 |
|
8 |
| -* Supports newest esbuild and typescript version |
9 |
| -* Uses esbuild config to determine the out folder |
10 |
| -* Can do everything that TypeScript offers |
11 |
| -* Type declarations (d.ts) included |
| 7 | +<p>The plugin enhances the build process by seamlessly integrating TypeScript, offering powerful features like type checking, automatic generation of .d.ts files, and ensuring robust type safety throughout.</p> |
12 | 8 |
|
13 |
| -## How It Works |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
14 | 13 |
|
15 |
| -1. esbuild calls this package in the onStart lifecycle. |
16 |
| -2. Gets the configuration from esbuild or user-defined configuration. |
17 |
| -3. Evaluate the out folder, that should be deleted, based on the given input. |
18 |
| -4. Runs the official TypeScript-Compiler by its API and\ |
19 |
| -generates output based on the given tsconfig. |
| 14 | +<br /> |
20 | 15 |
|
21 |
| -## Options |
| 16 | +Add a ⭐ to this repository — *it motivates me a lot!* |
22 | 17 |
|
23 |
| -### Overriding the out-folder |
| 18 | +</div> |
24 | 19 |
|
25 |
| -This package will search for a tsconfig by TypeScript itself. |
26 |
| -It can be helpful sometimes to override the path to the tsconfig: |
27 |
| -```typescript |
28 |
| -typescriptPlugin( |
29 |
| - overrideConfigPath?: string | undefined |
30 |
| -); |
31 |
| -``` |
| 20 | +## ⚡️ Getting started |
32 | 21 |
|
33 |
| -After using this override, this package will start to resolve your tsconfig. If your override is not valid, because the tsconfig does not exists, this package will discover the nearest tsconfing. |
| 22 | +Simply install this package with your package manager. |
| 23 | + |
| 24 | +````shell |
| 25 | +npm install -D esbuild-plugin-typescript |
| 26 | +```` |
34 | 27 |
|
35 |
| -## Usage |
| 28 | +<details> |
| 29 | +<summary>📦 other package manager</summary> |
36 | 30 |
|
37 |
| -### Installation |
| 31 | +Here are examples for installing the package with other package manager. |
38 | 32 |
|
39 |
| -The plugin can be installed by any package manager. |
| 33 | +> 💾 **yarn** |
| 34 | +> ````shell |
| 35 | +> yarn add -D esbuild-plugin-typescript |
| 36 | +> ```` |
40 | 37 |
|
41 |
| -<details><summary><b>Show instructions</b></summary> |
| 38 | +> 💾 **pnpm** |
| 39 | +> ````shell |
| 40 | +> pnpm install -D esbuild-plugin-typescript |
| 41 | +> ```` |
42 | 42 |
|
43 |
| -> npm \ |
44 |
| -> ``npm install esbuild-plugin-typescript`` |
| 43 | +</details> |
45 | 44 |
|
46 |
| -> yarn \ |
47 |
| -> ``yarn install esbuild-plugin-typescript`` |
| 45 | +Looks good so far 🔥 — now you have installed the latest version! |
48 | 46 |
|
49 |
| -> pnpm \ |
50 |
| -> ``pnpm install esbuild-plugin-typescript`` |
| 47 | +## 💡 Introduction |
51 | 48 |
|
52 |
| -</details> |
| 49 | +This esbuild plugin integrates TypeScript, generating .d.ts files and performing type checks based on the user's tsconfig.json. It uses the TypeScript compiler API to ensure strict type checks that |
| 50 | +esbuild alone can't provide. |
53 | 51 |
|
54 |
| -### Integration |
| 52 | +During the build, TypeScript is compiled to JavaScript while .d.ts files are created simultaneously. The plugin runs tsc in a subprocess to handle type checking |
| 53 | +independently from esbuild’s fast bundling. This ensures type safety without sacrificing performance. It respects the user's configuration, ensuring compatibility with various project setups. |
55 | 54 |
|
56 |
| -The easy way to integrate this plugin in esbuild. |
| 55 | +## 🔧 Usage |
57 | 56 |
|
58 |
| -<details><summary><b>Show instructions</b></summary> |
| 57 | +```typescript |
| 58 | +typescriptPlugin(options); |
| 59 | +``` |
| 60 | +
|
| 61 | +This function needs to be called inside the esbuild configuration in order to use this plugin. It will provide the plugin inside the build process of esbuild. |
| 62 | +
|
| 63 | +<details> |
| 64 | +<summary>Show an example of the integration</summary> |
59 | 65 |
|
60 | 66 | ````typescript
|
61 |
| -await esbuild.build({ |
| 67 | +esbuild.build({ |
| 68 | + // some configuration... |
62 | 69 | plugins: [
|
63 |
| - typescriptPlugin(...) |
| 70 | + typescriptPlugin(); |
| 71 | + // more plugins here... |
64 | 72 | ]
|
65 | 73 | })
|
66 | 74 | ````
|
67 | 75 |
|
68 |
| -[See here for more about the esbuild plugin integration.](https://esbuild.github.io/plugins/#using-plugins) |
| 76 | +</details> |
| 77 | +
|
| 78 | +<details> |
| 79 | +<summary>Show an example of the configuration</summary> |
| 80 | +
|
| 81 | +````typescript |
| 82 | +typescriptPlugin({ |
| 83 | + // configure here |
| 84 | +}); |
| 85 | +```` |
69 | 86 |
|
70 | 87 | </details>
|
71 | 88 |
|
| 89 | +### Properties |
| 90 | +
|
| 91 | +#### ``overridePathToTsconfig`` |
| 92 | +
|
| 93 | +> Default: ``undefined`` (esbuild's tsconfig file) |
| 94 | +
|
| 95 | +A ``string`` that determines the path to the tsconfig. |
| 96 | +
|
| 97 | +<details> |
| 98 | +<summary>Show an example</summary> |
| 99 | +
|
| 100 | +````typescript |
| 101 | +typescriptPlugin({ |
| 102 | + overridePathToTsconfig: "libs/my-lib/tsconfig.json" // any path allowed |
| 103 | +}); |
| 104 | +```` |
| 105 | +
|
| 106 | +</details> |
| 107 | +
|
| 108 | +### Returns |
| 109 | +
|
| 110 | +Type: ``Plugin`` |
| 111 | +
|
| 112 | +An instance of this plugin, that will be used by esbuild automatically. |
| 113 | +
|
72 | 114 | ## License
|
73 | 115 |
|
74 |
| -The MIT License (MIT) - Please have a look at the LICENSE file for more details. |
| 116 | +The MIT License (MIT) - Please have a look at the [License](https://github.com/simonkovtyk/esbuild-plugin-typescript/blob/main/LICENSE) file for more details. |
75 | 117 |
|
76 | 118 | ## Contributing
|
77 | 119 |
|
78 |
| -Feel free to contribute to this project.\ |
79 |
| -You can fork this project and create a new pull request for contributing. |
| 120 | +Want to contribute to an open-source project on GitHub but unsure where to start? Check out this comprehensive step-by-step guide on how to contribute effectively! |
| 121 | +
|
| 122 | +From forking the repository to creating pull requests, this guide walks you through every stage of the process, helping you make a successful contribution to this GitHub project. Start collaborating, |
| 123 | +learn new skills, and make an impact on this project! |
80 | 124 |
|
81 |
| -[Get to the repository at GitHub.](https://github.com/simonkovtyk/esbuild-plugin-typescript) |
| 125 | +[See here](https://github.com/simonkovtyk/esbuild-plugin-typescript/blob/main/docs/guides/HOW_TO_CONTRIBUTE.md) for the contribute guide at GitHub. |
82 | 126 |
|
83 | 127 | <hr>
|
84 | 128 |
|
|
0 commit comments