Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deploy
on:
push:
branches:
- release
- main

jobs:
deploy:
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Pull request checks
on:
pull_request:
types:
- opened
- reopened
branches:
- main

jobs:
pull_request:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install
uses: pnpm/action-setup@v4
with:
version: latest
run_install: true

- name: TypeScript Compiler
run: tsc --noEmit

- name: Lint
run: pnpx eslint .
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pnpx eslint .
tsc --noEmit
134 changes: 89 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,84 +1,128 @@
# esbuild plugin typescript
<div align="center">

![NPM Downloads](https://img.shields.io/npm/dw/esbuild-plugin-typescript) ![NPM License](https://img.shields.io/npm/l/esbuild-plugin-typescript)
<img width="196" src="https://raw.githubusercontent.com/simonkovtyk/esbuild-plugin-typescript/611c5c4942c8460ec6247ab833418908e9213a9b/docs/esbuild-favicon.svg" />

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.
<h1>TypeScript Plugin</h1>

* Supports newest esbuild and typescript version
* Uses esbuild config to determine the out folder
* Can do everything that TypeScript offers
* Type declarations (d.ts) included
<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>

## How It Works
![NPM Downloads](https://img.shields.io/npm/dw/esbuild-plugin-typescript)
![NPM License](https://img.shields.io/npm/l/esbuild-plugin-typescript)
![GitHub package.json version](https://img.shields.io/npm/v/esbuild-plugin-typescript)
![TypeScript types](https://img.shields.io/badge/TypeScript_types-included-blue)

1. esbuild calls this package in the onStart lifecycle.
2. Gets the configuration from esbuild or user-defined configuration.
3. Evaluate the out folder, that should be deleted, based on the given input.
4. Runs the official TypeScript-Compiler by its API and\
generates output based on the given tsconfig.
<br />

## Options
Add a ⭐ to this repository — *it motivates me a lot!*

### Overriding the out-folder
</div>

This package will search for a tsconfig by TypeScript itself.
It can be helpful sometimes to override the path to the tsconfig:
```typescript
typescriptPlugin(
overrideConfigPath?: string | undefined
);
```
## ⚡️ Getting started

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.
Simply install this package with your package manager.

````shell
npm install -D esbuild-plugin-typescript
````

## Usage
<details>
<summary>📦 other package manager</summary>

### Installation
Here are examples for installing the package with other package manager.

The plugin can be installed by any package manager.
> 💾 **yarn**
> ````shell
> yarn add -D esbuild-plugin-typescript
> ````

<details><summary><b>Show instructions</b></summary>
> 💾 **pnpm**
> ````shell
> pnpm install -D esbuild-plugin-typescript
> ````

> npm \
> ``npm install esbuild-plugin-typescript``
</details>

> yarn \
> ``yarn install esbuild-plugin-typescript``
Looks good so far 🔥 — now you have installed the latest version!

> pnpm \
> ``pnpm install esbuild-plugin-typescript``
## 💡 Introduction

</details>
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
esbuild alone can't provide.

### Integration
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
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.

The easy way to integrate this plugin in esbuild.
## 🔧 Usage

<details><summary><b>Show instructions</b></summary>
```typescript
typescriptPlugin(options);
```

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.

<details>
<summary>Show an example of the integration</summary>

````typescript
await esbuild.build({
esbuild.build({
// some configuration...
plugins: [
typescriptPlugin(...)
typescriptPlugin();
// more plugins here...
]
})
````

[See here for more about the esbuild plugin integration.](https://esbuild.github.io/plugins/#using-plugins)
</details>

<details>
<summary>Show an example of the configuration</summary>

````typescript
typescriptPlugin({
// configure here
});
````

</details>

### Properties

#### ``overridePathToTsconfig``

> Default: ``undefined`` (esbuild's tsconfig file)

A ``string`` that determines the path to the tsconfig.

<details>
<summary>Show an example</summary>

````typescript
typescriptPlugin({
overridePathToTsconfig: "libs/my-lib/tsconfig.json" // any path allowed
});
````

</details>

### Returns

Type: ``Plugin``

An instance of this plugin, that will be used by esbuild automatically.

## License

The MIT License (MIT) - Please have a look at the LICENSE file for more details.
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.

## Contributing

Feel free to contribute to this project.\
You can fork this project and create a new pull request for contributing.
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!

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,
learn new skills, and make an impact on this project!

[Get to the repository at GitHub.](https://github.com/simonkovtyk/esbuild-plugin-typescript)
[See here](https://github.com/simonkovtyk/esbuild-plugin-typescript/blob/main/docs/guides/HOW_TO_CONTRIBUTE.md) for the contribute guide at GitHub.

<hr>

Expand Down
7 changes: 7 additions & 0 deletions docs/esbuild-favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
150 changes: 150 additions & 0 deletions docs/guides/HOW_TO_CONTRIBUTE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# ⚙️ How to contribute

How to Contribute to a GitHub Repository: A Step-by-Step Guide
Contributing to open-source projects on GitHub is a great way to collaborate with others, learn new skills, and improve software. Here's a step-by-step guide on how to contribute to this GitHub
repository.

## 1. Fork the Repository

Before making any changes, you'll need to fork the repository to your own GitHub account.

1. Go to the [repository page](https://github.com/simonkovtyk/esbuild-plugin-typescript/).
2. Click on the "Fork" button in the top-right corner.
3. GitHub will create a copy of the repository in your account.

## 2. Clone Your Fork Locally

Next, you need to clone your forked repository to your local machine.

Open a terminal on your computer.

Use the following command to clone the repository:

````shell
git clone https://github.com/YOUR-USERNAME/esbuild-plugin-typescript.git
````

Replace YOUR-USERNAME with your GitHub username.

Navigate into the project directory:

````shell
cd esbuild-plugin-typescript
````

## 3. Set Up the Upstream Remote

To ensure you can pull in updates from the original repository, add an "upstream" remote.

In the terminal, run:

````shell
git remote add upstream https://github.com/simonkovtyk/esbuild-plugin-typescript.git
````

Confirm the upstream remote has been added:

````shell
git remote -v
````

## 4. Create a New Branch

To keep your changes organized and separate from the main codebase, create a new branch.

Make sure you're in the main branch:

````shell
git checkout main
````

Create and switch to a new branch:

````shell
git checkout -b branch-name
````

Replace branch-name with a descriptive name for your branch (e.g., fix-bug, add-feature).

## 5. Make Your Changes

Now you're ready to make changes to the codebase. Open the project in your favorite code editor, modify the code, and save your changes.

## 6. Commit Your Changes

After making your changes, commit them to your branch.

Check which files have changed:

````shell
git status
````

Stage your changes:

````shell
git add .
````

Commit your changes with a descriptive message:

````shell
git commit -m "Brief description of the changes"
````

## 7. Push Your Branch to GitHub

Push your changes to your fork on GitHub.

````shell
git push origin branch-name
````

## 8. Open a Pull Request

Now that your changes are pushed to your fork, it's time to open a pull request (PR) to the original repository.

1. Go to the [original repository](https://github.com/simonkovtyk/esbuild-plugin-typescript/) on GitHub.
2. Click the "Compare & pull request" button.
3. Review your changes and ensure they are correct.
4. Add a descriptive title and description for your PR.
5. Click "Create pull request."

## 9. Respond to Review Feedback

After opening your pull request, a code style check will run automatically and the maintainers of the repository might review your code and suggest changes.

If changes are requested, update your branch locally, commit the new changes, and push them to your fork.
The PR will automatically update with your latest changes.

## 10. Keep Your Fork Up-to-Date

To ensure your fork remains up-to-date with the original repository, regularly sync it with the upstream repository.

Fetch the latest updates from upstream:

````shell
git fetch upstream
````

Merge the upstream changes into your local main branch:

````shell
git checkout main
````

````shell
git merge upstream/main
````

Push the updated main branch to your fork:

````shell
git push origin main
````

## 11. Celebrate Your Contribution!

Once your pull request is merged, you've officially contributed to an open-source project!

**🚀 Congratulations!**
25 changes: 25 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import stylistic from "@stylistic/eslint-plugin";

export default tseslint.config(
{
ignores: [
".github",
".idea",
"dist",
"docs",
"node_modules"
]
},
eslint.configs.recommended,
...tseslint.configs.strict,
...tseslint.configs.stylistic,
stylistic.configs.customize({
indent: 2,
quotes: "double",
semi: true,
commaDangle: "never",
jsx: false
})
);
Loading