oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73.07k stars 2.67k forks source link

esbuild.context is not a function #6107

Open robobun opened 11 months ago

robobun commented 11 months ago

esbuild.context is not a function. (In 'esbuild.context(config)', esbuild.context is undefined.)

this is from trying to run esbuild in watch mode.

there isn't much other info other than I'm requiring esbuild using const esbuild= require('esbuild')

Originally reported on Discord: bun --bun run on script that uses esbuild fails.

prodkt commented 11 months ago

Happening to us as well in a Nextjs monorepo after attempting to switch over to bun workspaces from pnpm workspaces. Have yet to resolve or rollback on machines that attempted this. Could it be bun had updated some global dependency during install? We have a path forward as the build's work fine on the machines that didn't install bun. We'll proceed down the contentlayer direction but thought we should share given we could only reproduce after installing bun.

> prodkt-cloud-docs@2.0.1 build /PRODUCTION/apps/docs
> contentlayer build && next build

This error shouldn't have happened. Please consider opening a GitHub issue with the stack trace below here:
https://github.com/contentlayerdev/contentlayer/issues

An unchecked error was produced.

TypeError: esbuild.context is not a function
    at T.tryCatchPromise.UnknownEsbuildError.error.error (/PRODUCTION/node_modules/.pnpm/@contentlayer+core@0.3.4_esbuild@0.16.17/node_modules/@contentlayer/core/dist/getConfig/esbuild.js:64:79)
    at PRODUCTION/node_modules/.pnpm/@effect-ts+system@0.57.5/node_modules/@effect-ts/system/_mjs/Effect/promise.mjs:13:5
    at PRODUCTION/node_modules/.pnpm/@effect-ts+system@0.57.5/node_modules/@effect-ts/system/_mjs/Effect/effectAsync.mjs:30:5
    at FiberContext.evaluateNow PRODUCTION/node_modules/.pnpm/@effect-ts+system@0.57.5/node_modules/@effect-ts/system/_mjs/Fiber/context.mjs:892:35)
    at PRODUCTION/node_modules/.pnpm/@effect-ts+system@0.57.5/node_modules/@effect-ts/system/_mjs/Fiber/context.mjs:504:33
    at PRODUCTION/node_modules/.pnpm/@effect-ts+system@0.57.5/node_modules/@effect-ts/system/_mjs/Support/Scheduler/index.mjs:11:22

Fiber: #6 (started at: 2023-10-03T15:44:35.553Z) was supposed to continue to: <empty trace>

Fiber: #6 (started at: 2023-10-03T15:44:35.553Z) Execution trace: <empty trace>

Fiber: #6 (started at: 2023-10-03T15:44:35.553Z) was spawned by: <empty trace>

OS: darwin 23.0.0 (arch: arm64)
Process: /PRODUCTION/apps/docs/node_modules/contentlayer/bin/cli.cjs build
Node version: v16.20.0
Contentlayer version: 0.3.4
omarish commented 10 months ago

Running into this one as well. We also run contentlayer in our pnpm monorepo.

omarish commented 10 months ago

This was my fault - I had the wrong version of esbuild. Specifically, I was running 0.14.18 and contentlayer requires esbuild@"0.17.x || 0.18.x".

jeffshaver commented 6 months ago

as of bun 1.0.30 this is still an issue

jeffshaver commented 5 months ago

@Jarred-Sumner sorry for tagging you directly, im not sure if there is a real way for me to get his figured out. and part of it seems to be a me problem and this issue is kind of old.

I tried to make a small repro so i could post here, but i can't...

BUT if i go back and change my const esbuild = require('esbuild') to const esbuild = require('./node_modules/esbuild'), it isn't completely successful, but i get past this error.

also, if i console.log the esbuild variable with just requiring esbuild, it is {} but if i do it with the path, its what i would expect. im not really sure how my companies repo is different from teh minimal test case i was trying to make. but it seems as though the node module can't be resolved or something.

upgraded to 1.1 and this is still an issue as well