esbuild-ignore-with-comments-plugin
TypeScript icon, indicating that this package has built-in type declarations

0.3.12 • Public • Published

npm version

ESBuild Ignore with Comments Plugin

Allows inserting comments into TypeScript source files. ESBuild will ignore these files during build.

Usage

Add to any .ts or .tsx file the following comment:

/* esbuild-ignore */

This file will be replaced with a source file that has an empty object as a default export.

Configure the plugin for esbuild as follows:

import ignorePlugin from 'esbuild-ignore-with-comments-plugin';
import { build } from 'esbuild';

await build({
  plugins: [ignorePlugin()],
});

If you are bundling the same files multiple times (such as for server-side rendering) you can group files into sets and only ignore specific sets of files.

For instance, assume you have the following files:

server.ts

/* esbuild-ignore ui */

// some server only stuff

ui.ts

/* esbuild-ignore server */

// some ui only stuff

Then running the following will ignore server.ts during the build:

await build({
  plugins: [ignorePlugin(['ui'])],
});

Note that files that have the comment /* esbuild-ignore */ without specifying a group will always be ignored.

Also note that if you want to add a file to multiple groups, you need to include multiple esbuild-ignore comments, such as:

/* esbuild-ignore server */
/* esbuild-ignore ui */

Readme

Keywords

Package Sidebar

Install

npm i esbuild-ignore-with-comments-plugin

Weekly Downloads

12

Version

0.3.12

License

MIT

Unpacked Size

9.59 kB

Total Files

6

Last publish

Collaborators

  • mxro