esbuild-plugin-entry-chunks

Esbuild plugin to compose entryPoints as chunks

MIT 22 个版本
安装
npm install esbuild-plugin-entry-chunks
yarn add esbuild-plugin-entry-chunks
pnpm add esbuild-plugin-entry-chunks
bun add esbuild-plugin-entry-chunks
README

esbuild-plugin-entry-chunks

Esbuild plugin to compose entryPoints as chunks

lcov npm

Status

PoC

Problem

Esbuild provides code-splitting with dynamic imports to reuse common code chunks of several entries. This plugin has similar functionality, but:

  1. Bounds parts in static form.
  2. Composes entryPoints bundles as chunks without extracting common parts.

This is kind of workaround for the missing manual-chunks API.

Practical case

For example, if a package has two entry points — index.js and cli.js — the last bundle will use index.js as a dependency without duplicating its contents.

Usage

import { build, BuildOptions } from 'esbuild'
import { entryChunksPlugin } from 'esbuild-plugin-entry-chunks'

const plugin = entryChunksPlugin()
const config: BuildOptions = {
  entryPoints: [
    'a.ts',
    'b.ts',
    'c.ts',
  ],
  plugins: [plugin],
  external: ['node:*'],
  bundle: true,
  minify: false,
  sourcemap: false,
  format: 'esm',
  allowOverwrite: true,
}

await build(config)

Inputs:

// a.ts -----------------
export * from './b'
export const a = 'a'

// b.ts -----------------
export * from './c'
export const b = 'b'

// c.ts -----------------
export * from './d'
export const c = 'c'

// d.ts -----------------
export * from './e'
export const d = 'd'

// e.ts -----------------
import * as fs from 'node:fs'
export const e = 'e'
export const rf = fs.readFile

Outputs:

// a.js -----------------
// a.ts
export * from "./b.js";
var a = "a";
export {
  a
};

// b.js -----------------
// b.ts
export * from "./c.js";
var b = "b";
export {
  b
};

// c.js -----------------
// e.ts
import * as fs from "node:fs";
var e = "e";
var rf = fs.readFile;

// d.ts
var d = "d";

// c.ts
var c = "c";
export {
  c,
  d,
  e,
  rf
};

License

MIT

版本列表
0.1.21 2026-04-13
0.1.19 2026-04-11
0.1.18 2026-04-05
0.1.17 2025-08-16
0.1.16 2025-08-14
0.1.15 2024-05-26
0.1.14 2024-05-05
0.1.13 2024-05-05
0.1.12 2024-03-27
0.1.11 2024-03-16
0.1.10 2024-03-16
0.1.9 2024-03-16
0.1.8 2024-02-20
0.1.7 2024-02-19
0.1.6 2024-02-18
0.1.5 2024-01-26
0.1.4 2024-01-25
0.1.3 2024-01-05
0.1.2 2024-01-03
0.1.1 2024-01-02
0.1.0 2024-01-02
0.0.0 2024-01-02