#Latest bun no longer builds

1 messages · Page 1 of 1 (latest)

outer pewter
#

I was using bun to make a NodeJS library. I updated it to the latest version and now my build.mjs script does not produce an index.js file:

import dts from 'bun-plugin-dts';

await Bun.build({
    entrypoints: ['lib/index.ts'],
    outdir: './dist',
    target: 'node',
    plugins: [dts()],
});

Nowhere on the 1.1.30 release is this mentioned to have a breaking change or any change whatsoever. Is there a way to roll back to a working bun version? Why change something that was working perfectly before 1.1.30?

gusty palmBOT
#

How to install bun?

If you're on Linux or macOS, you can install bun using the following command:

curl -fsSL https://bun.sh/install.sh | bash

# or if you want specific version
curl -fsSL https://bun.sh/install.sh | bash -s "bun-v1.0.0"

If you're on Windows, you can install bun using the following command:

powershell -c "irm bun.sh/install.ps1|iex"

# or if you want specific version
powershell -c "& {$(irm bun.sh/install.ps1)} -Version 1.1.4"
blissful fox
#

this is how to install older verison^

#

but im interested in the actual bug 👀

blissful fox
outer pewter
#

I suspect it may be such plugin. I don't really have a public repository, but the mjs file looks exactly like that 😅 . Should I provide any other file details? The command does not fail whatsoever, not even catching an error inside the await call. $? returns a 0. No further output is given.

blissful fox
#

i tried a really basic example of it and building a basic ts file like its github says, and my windows works (on 1.1.30) so im thinking something more specific...

#

that being said, does bun build without the plugin work?

outer pewter
#

it doesn't 😦 it just produces the same output

#

This is what the build script does: $ rm -rf dist && mkdir dist && bun run build.mjs && cp ./README.md ./dist/README.md && cp ./package.json ./dist/package.json

#

I apologize for the cursed shell scripting there.

#

I've extracted relevant data from the package.json file:

#
{
    "name": "@my-org/libsomething",
    "version": "0.2.0",
    "types": "index.d.ts",
    "engines": {
        "node": ">=20.0.0"
    },
    "description": "TypeScript library for doing some things.",
    "files": [
        "index.js",
        "index.d.ts",
        "package.json",
        "README.md"
    ],
    "exports": {
        ".": "./index.js"
    },
    "scripts": {
        "build": "rm -rf dist && mkdir dist && bun run build.mjs && cp ./README.md ./dist/README.md && cp ./package.json ./dist/package.json",
        "doc": "bunx typedoc lib/index.ts",
        "prepublish": "bun run build"
    },
    "publishConfig": {
        "registry": "https://npm.pkg.github.com/"
    },
    "type": "module",
    "devDependencies": {
        "@types/bun": "latest",
        "bun-plugin-dts": "^0.2.4",
        "typedoc": "^0.26.8"
    },
    "peerDependencies": {
        "typescript": "^5.5.4"
    },
    "dependencies": {
        "axios": "^1.7.7"
    }
}
outer pewter
#

Fixed by moving to esbuild. Thanks

vital mason
#

@outer pewter any chance you could paste some code for us to take a look at?

#

or alternatively

#

what the error you're seeing is

outer pewter
#

There was no error. The builder just took its time to lock the console and do nothing afterwards. Rollback didn't help either inside the pipelines as well. Whatever that's making it fail might be an update inside a lib or something.

vital mason
#

Hm

#

Sounds like an infinite loop somewhere

outer pewter
#

I even rolled back my repository. Set the pipelines to an older bun version and nothing. I thought it was the libs, but rolling back like 10 commits didn't help as well

vital mason
#

maybe it's a peer dependency?

#

or is the machine possibly non-avx2

#

and the version of bun uses avx2?

#

(baseline)

outer pewter
#

I don't know what that is :/ nor do I understand why was it working last week and now it isn't 😦

#
    "devDependencies": {
        "@types/bun": "latest",
        "@types/crypto-js": "^4.2.2",
        "bun-plugin-dts": "^0.3.0",
        "typedoc": "^0.26.7"
    },
    "peerDependencies": {
        "typescript": "^5.6.3"
    },
    "dependencies": {
        "@types/bcrypt": "^5.0.2",
        "axios": "^1.7.7",
        "bcrypt": "^5.1.1",
        "dayjs": "^1.11.13",
        "mongoose": "^8.7.0",
        "twilio": "^5.3.2",
        "valibot": "^0.40.0",
        "winston": "^3.14.2"
    }
```  I don´t see anything strange in my dependencies :/ however, I suspect it might be something related to twilio.
#
  1. Because using tsc does output a lot of errors which I cannot get to shut up and just compile my file.
#
  1. Someone else has a jerky .d.ts plugin for esbuild which suffers the same syndrome
blissful fox
vestal meteor
#

there is a footgun in the bun build api here

vestal meteor
# outer pewter There was no error. The builder just took its time to lock the console and do no...

@outer pewter if a standard bun build fails it returns success: false instead of throwing, which is honestly a mistake we should fix in the next set of breaking changes we do.

const { success, logs } = await Bun.build(...);
if(!success) throw new AggregateError(logs, "Failed to build")

with this extra line addeed, it will show the error produced. from there we can work to find what the regression is

outer pewter
#

After many hours I solved this issue. Turns out some digging was needed.

#
  1. The other thing I didn't mention because I thought it wasn't important was that, the IDE seemed to detect "wrong" files inside dist/ at build-time.
#

I copy-pasted my library and used node with tsc/esbuild instead. To mimic the build. It failed

outer pewter
#

Placing a console.trace() shed more light into the matter:

#
{
  outputs: [],
  success: false,
  logs: [
    43 |     const AWSMock = require('mock-aws-s3');
                                 ^
error: Could not resolve: "mock-aws-s3". Maybe you need to "bun install"?
    at /home/vg/GitHub/libexperiment/node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:43:29, 76 |   const AWS = require('aws-sdk');
                           ^
error: Could not resolve: "aws-sdk". Maybe you need to "bun install"?
    at /home/vg/GitHub/libexperiment/node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:76:23, 112 |   const nock = require('nock');
                             ^
error: Could not resolve: "nock". Maybe you need to "bun install"?
    at /home/vg/GitHub/libexperiment/node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:112:24
  ],
}
      at /home/vg/GitHub/libexperiment/build.mjs:30:17
```  This however is the result of running such `console.trace()` at the promise `.then()` function. I do not use those dependencies anythere in the project, so I figured out it may be a deep dependency causing trouble.