Skip to content

Yarn workspace: esbuild not bundling internal library #4120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
SimTheFool opened this issue Mar 23, 2025 · 1 comment
Open

Yarn workspace: esbuild not bundling internal library #4120

SimTheFool opened this issue Mar 23, 2025 · 1 comment

Comments

@SimTheFool
Copy link

Hi !

I'm building an app with esbuild. The app (workers) is relying on some internal library (utils). But, after bundling, nothing of utils can be found in my bundled index.cjs.

Here is my file tree:

root
├── workers
│   ├── build
│   │   └── index.js
│   ├── src
│   │   └── index.ts
│   └── package.json
├── utils
│   ├── src
│   │   └── index.ts
│   └── package.json
└── package.json

Here is my root package.json:

{
  "name": "XXXX",
  "version": "0.0.0",
  "license": "MIT",
  "private": true,
  "workspaces": [
    "workers",
    "utils"
  ]
}

Here is my utils/package.json:

{
  "name": "utils",
  "version": "1.0.0",
  "main": "src/index.ts",
  "license": "MIT",
  "private": true,
  "dependencies": {
   ...
  }
}

Here is my workers/package.json:

{
  "name": "workers",
  "version": "1.0.0",
  "main": "build/src/index.js",
  "type": "module",
  "scripts": {
    "build": "node build.js",
    "start": "node build/index.cjs"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "esbuild": "^0.25.1"
  },
  "dependencies": {
    ...,
    "utils": "*"
  }
}

And here is my build script:

import * as esbuild from "esbuild";

await esbuild.build({
  entryPoints: ["src/index.ts"],
  bundle: true,
  outfile: "build/index.cjs",
  platform: "node",
  loader: { ".node": "file", ".html": "text" },
});

Any idea how to get utils libray to be bundled with my workers app ?

@hyrious
Copy link

hyrious commented Mar 24, 2025

I cannot reproduce what you said. Maybe you can provide a runnable reproduction? Here's what I tried: esbuild-4120.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants