Skip to content

Commit

Permalink
release(esbuild-shared): 🔖 batch release esbuild plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
linbudu599 committed Sep 20, 2021
1 parent e320fa6 commit a2ba0ee
Show file tree
Hide file tree
Showing 22 changed files with 121 additions and 694 deletions.
55 changes: 3 additions & 52 deletions packages/esbuild-plugin-alias-path/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,55 +2,6 @@

ESBuild plugin for alias / tsconfig-paths.

## Usage

**Node: this plugin require ESBuild version ^0.11.19 for the `onStart`/`onEnd` hooks**

```bash
npm i esbuild-plugin-alias-path -D

pnpm i esbuild-plugin-alias-path -D

yarn add esbuild-plugin-alias-path -D
```

```typescript
import { esbuildPluginAliasPath } from 'esbuild-plugin-alias-path';

(async () => {
const res = await build({
entryPoints: ['apps/nest-app/src/main.ts'],
bundle: true,
tsconfig: './tsconfig.base.json',
outfile: './dist/main.js',
plugins: [
esbuildPluginAliasPath({
// absolute path is required
// for node package resolve, use require.resolve("package-name")
alias: { '@/foo': 'D://schematics/apps/nest-app/src/alias/foo.ts' },
tsconfigPath: 'apps/nest-app/tsconfig.app.json',
}),
],
platform: 'node',
format: 'cjs',
external: ['@nestjs/core', '@nestjs/common'],
});
})();
```

## Configuration

```typescript
export interface Options {
// alias, default as {}
// {"replace-key": "replace-with"}
// you will need to use absolute path as replace-with
// if value of k-v is absolute path, it will be used directly
// or the path will be resolved with process.cwd() (for CICD usage)
alias?: Record<string, string>;
// tsconfig.json path
tsconfigPath?: string;
// should this plugin be skipped
skip?: boolean;
}
```
- [Documentation](https://nx-plugins.netlify.app/derived/esbuild.html#alias-path).
- [GitHub Repo](https://github.com/LinbuduLab/nx-plugins)
- [Author](https://github.com/linbudu599)
2 changes: 1 addition & 1 deletion packages/esbuild-plugin-alias-path/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "esbuild-plugin-alias-path",
"version": "0.3.3",
"version": "0.4.0",
"main": "dist/src/index.js",
"scripts": {
"release": "release-it",
Expand Down
57 changes: 3 additions & 54 deletions packages/esbuild-plugin-clean/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,6 @@

ESBuild plugin for cleaning up output/assets before building.

## Usage

**Node: this plugin require ESBuild version ^0.11.19 for the `onStart`/`onEnd` hooks**

**GitHub Repository/Homepage is private for now, if you got any troubles, just open issue in this [repo](https://github.com/linbudu599/Blog).**

```bash
npm i esbuild-plugin-clean -D
pnpm i esbuild-plugin-clean -D
yarn add esbuild-plugin-clean -D
```

```typescript
import { build } from 'esbuild';
import clean from 'esbuild-plugin-clean';

(async () => {
const res1 = await build({
entryPoints: ['./demo.ts'],
bundle: true,
outfile: './dist/main.js',
plugins: [
clean({
patterns: ['./dist/*'],
}),
],
});
})();
```

## Configuration

This plugin use [del](https://www.npmjs.com/package/del) under the hood, so you can easily pass del options to plugin.

```typescript
export interface CleanOptions {
// del patterns
// default: []
patterns?: string | string[];
// use dry-run mode to have a try
// default: false
dryRun?: boolean;
// del options
// default: {}
options?: DelOptions;
// use del or del.sync for cleaning up
// default: true
sync?: boolean;
// do cleaning in start/end/both
// maybe in some strange cases you will need it ? :)
// default: "start"
cleanOn?: 'start' | 'end' | 'both';
}
```
- [Documentation](https://nx-plugins.netlify.app/derived/esbuild.html#clean).
- [GitHub Repo](https://github.com/LinbuduLab/nx-plugins)
- [Author](https://github.com/linbudu599)
3 changes: 1 addition & 2 deletions packages/esbuild-plugin-clean/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "esbuild-plugin-clean",
"version": "0.1.3",
"version": "0.5.0",
"description": "ESBuild plugin for cleaning up assets before building.",
"keywords": [
"esbuild",
Expand All @@ -20,7 +20,6 @@
"author": "Linbudu <linbudu599@gmail.com> (https://github.com/linbudu599)",
"main": "dist/src/index.js",
"scripts": {
"release": "release-it",
"release:dry": "release-it --dry-run",
"release:minor": "release-it minor",
"release:major": "release-it major"
Expand Down
59 changes: 3 additions & 56 deletions packages/esbuild-plugin-compress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,6 @@

ESBuild plugin for output compression (gzip/brotli).

## Usage

**Node: this plugin require ESBuild version ^0.11.19 for the `onStart`/`onEnd` hooks**

**GitHub Repository/Homepage is private for now, if you got any troubles, just open issue in this [repo](https://github.com/linbudu599/Blog).**

```bash
npm i esbuild-plugin-compress -D
pnpm i esbuild-plugin-compress -D
yarn add esbuild-plugin-compress -D
```

```typescript
import { build } from 'esbuild';
import compress from 'esbuild-plugin-compress';

(async () => {
const res1 = await build({
entryPoints: ['./demo.ts'],
bundle: true,
outfile: './dist/main.js',
plugins: [
compress({
outputDir: 'compressed-dist',
brotli: false,
}),
],
});
})();
```

## Configuration

```typescript
export interface CompressOptions {
// apply gzip compression
// default: true
gzip?: boolean;
// gzip options
// default: {}
gzipOptions?: ZlibOptions;
// apply brotli compression
// default: true
brotli?: boolean;
// brotli options
// default: {}
brotliOptions?: BrotliOptions;
// should generate origin files
// if no compression is specified, origin files will must be generated
// default: false
removeOrigin?: boolean;
// output dir name, relative to outdir/outfile(path.dirname(outfile))
// default: null, will generate compressed file at the same level of output file
outputDir?: string;
}
```
- [Documentation](https://nx-plugins.netlify.app/derived/esbuild.html#compress).
- [GitHub Repo](https://github.com/LinbuduLab/nx-plugins)
- [Author](https://github.com/linbudu599)
2 changes: 1 addition & 1 deletion packages/esbuild-plugin-compress/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "esbuild-plugin-compress",
"version": "0.1.2",
"version": "0.2.0",
"description": "ESBuild plugin for output compression",
"keywords": [
"esbuild",
Expand Down
60 changes: 3 additions & 57 deletions packages/esbuild-plugin-copy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,6 @@

ESBuild plugin for assets copy.

## Usage

**Node: this plugin require ESBuild version ^0.11.19 for the `onStart`/`onEnd` hooks**

**GitHub Repository/Homepage is private for now, if you got any troubles, just open issue in this [repo](https://github.com/linbudu599/Blog).**

```bash
npm i esbuild-plugin-copy -D
pnpm i esbuild-plugin-copy -D
yarn add esbuild-plugin-copy -D
```

```typescript
import { build } from 'esbuild';
import copy from 'esbuild-plugin-copy';

(async () => {
const res1 = await build({
entryPoints: ['./demo.ts'],
bundle: true,
outfile: './dist/main.js',
plugins: [
copy({
assets: {
from: ['./assets/*'],
to: ['./assets', './tmp-assets'],
},
}),
],
});
})();
```

## Configuration

```typescript
type MaybeArray<T> = T | T[];

// file/folder/globs
export interface AssetPair {
from: MaybeArray<string>;
to: MaybeArray<string>;
}

export interface Options {
// assets pair to copy
assets: MaybeArray<AssetPair>;
// start copy on onStart/onEnd hooks
// default: false
copyOnStart: boolean;
// verbose logging
// default: true
verbose: boolean;
// extra globby options to match paths to copy from
globbyOptions: GlobbyOptions;
}
```
- [Documentation](https://nx-plugins.netlify.app/derived/esbuild.html#copy).
- [GitHub Repo](https://github.com/LinbuduLab/nx-plugins)
- [Author](https://github.com/linbudu599)
2 changes: 1 addition & 1 deletion packages/esbuild-plugin-copy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "esbuild-plugin-copy",
"version": "0.1.2",
"version": "0.2.0",
"description": "ESBuild plugin for assets copy.",
"keywords": [
"esbuild",
Expand Down
81 changes: 4 additions & 77 deletions packages/esbuild-plugin-decorator/README.md
Original file line number Diff line number Diff line change
@@ -1,80 +1,7 @@
# esbuild-plugin-decorator

ESBuild plugin to handle TypeScript decorators compilation.
ESBuild plugin for TypeScript decorators compilation.

- Support compilation by `typescript` / `@swc/core`.
- Support typescript/swc config file load.
- (WIP)Integration with [Nx](https://nx.dev/).

## Usage

```bash
# install peer dependencies
# install @swc/core if you want to use swc as compiler
npm i esbuild typescript @swc/core -D
```

```bash
npm i esbuild-plugin-decorator -D
pnpm i esbuild-plugin-decorator -D
yarn add esbuild-plugin-decorator -D
```

```typescript
import { build } from 'esbuild';
import { esbuildPluginDecorator } from 'esbuild-plugin-decorator';

(async () => {
const res1 = await build({
entryPoints: ['./demo.ts'],
bundle: true,
outfile: './dist/main.js',
plugins: [
esbuildPluginDecorator({
tsconfigPath: 'apps/nest-app/tsconfig.app.json',
}),
],
});
})();
```

## Configuration

```typescript
export interface ESBuildPluginDecoratorOptions {
// tsconfig path (tsconfig.json)
// required even you're using swc as compiler
// if not specified, will search tsconfig.json(relative to cwd option) by default
tsconfigPath?: string;
// swc config path (.swcrc)
swcrcPath?: string;

// force specified compiler for all code compilation
// (even no decorators are found)
// if set to false, plugin will be skipped when no decorators are found
force?: boolean;

// default: process.cwd()
cwd?: string;

// use typescript or @swc/core for decorator compilation
// default: tsc
compiler?: 'tsc' | 'swc';

// when innx project, will search tsconfig.base.json
// when tsconfigPath is not speficied
// there will be more customization for nx-workspace in the future
// default: false
isNxProject?: boolean;

// extra compile options
// will override config from config file
tscCompilerOptions?: TSCCompileOptions;
swcCompilerOptions?: SWCCompileOptions;

// verbose logging
// log info about plugin skipped / decorators not found / current configuration
// default: false
verbose?: boolean;
}
```
- [Documentation](https://nx-plugins.netlify.app/derived/esbuild.html#decorator).
- [GitHub Repo](https://github.com/LinbuduLab/nx-plugins)
- [Author](https://github.com/linbudu599)
2 changes: 1 addition & 1 deletion packages/esbuild-plugin-decorator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "esbuild-plugin-decorator",
"version": "0.1.2",
"version": "0.2.0",
"description": "ESBuild plugin for decorator compilation.",
"keywords": [
"esbuild",
Expand Down
Loading

0 comments on commit a2ba0ee

Please sign in to comment.