@anatine/esbuildnx

中文文档
0.2.0发布于 2022/03/30MITTypeScriptCommonJS近 30 天下载 2460

Esbuild plugin for Nx

原始使用文档
文档目录5 节
  1. Installing the esbuildnx Plugin
  2. Application Setup
  3. Commands
  4. esbuild
  5. Overridden build

esbuildnx Plugin

The esbuild Plugin contains generators and executors for compiling a node app using esbuild

Installing the esbuildnx Plugin

Installing the esbuildnx plugin to a workspace can be done with the following:

#yarn
yarn add -D @anatine/esbuildnx
#npm
npm install -D @anatine/esbuildnx

Application Setup

This plugin is designed to be used with an existing Node application. Target an existing node app and run the setup.

nx generate @anatine/esbuildnx:setup <node-app>

If you want to replace the existing build command with esbuild, use the --override flag.

nx generate @anatine/esbuildnx:setup <node-app> --override 

Commands

esbuild

After a node project is setup, execute a build with the command:

nx esbuild <node-app>

esbuild options: external: [ ... ]

Not every module can go through treeshaking and packing. Esbuild provides an option called external that contains an array of package name strings.

This plugin will take all dependencies in the package.json, and merge them with any external files defined in the app esbuild.json file. These node_modules will be copied into the dist directory at build time and will not be packed into the single .js file.

The entire compiled dist folder can be deployed into a docker container with minimum node_modules.

One of the goals of this plugin will be to grow and maintain a list of npm modules that can't be bundled by esbuild and automatically add them to the external file list.

watch

The --watch flag is also available. In watch mode, the node_module files are not copied over.

nx esbuild <node-app> --watch

Overridden build

If the setup was run with the --overwrite flag, build your node app as normal within the nx environment.

nx build <node-app>

版本与发布记录

@anatine/esbuildnx 共发布 9 个版本,首次发布于 2021/04/16;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.2.0latest2022/03/304 年前
0.1.182021/09/205 年前
0.1.172021/08/055 年前
0.0.62021/06/305 年前
0.0.52021/06/025 年前
0.0.42021/05/125 年前

关于 @anatine/esbuildnx 的常见问题

@anatine/esbuildnx 是什么?

Esbuild plugin for Nx

如何安装 @anatine/esbuildnx?

在项目目录运行 npm install @anatine/esbuildnx,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:esbuild(~0.14.29)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@anatine/esbuildnx 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@anatine/esbuildnx 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@anatine/esbuildnx 可以商用吗?

@anatine/esbuildnx 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@anatine/esbuildnx 的下载量有多少?

根据 npm 官方下载统计,@anatine/esbuildnx 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,460 次,日均约 82 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@anatine/esbuildnx 还在维护吗?

最新版本 0.2.0 发布于 2022/03/30(4 年前);至今共发布 9 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/04/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。