Files
bun.sh/test/bundler/bundler_bun.test.ts
robobun 6e3359dd16 Bump version to 1.3.0 (#23401)
## What does this PR do?

Bumps Bun version from 1.2.24 to 1.3.0, marking the start of the 1.3.x
release series.

## Changes

- **`package.json`**: Updated version from `1.2.24` to `1.3.0`
- **`LATEST`**: Updated from `1.2.23` to `1.3.0` (used by installation
scripts)
- **`test/bundler/bundler_bun.test.ts`**: Updated version check to
include `1.3.x` so export conditions tests continue to run

## Verification

 Debug build successful showing version `1.3.0-debug`
 All platforms compile successfully via `bun run zig:check-all` (49/49
steps)
 Bundler tests pass with updated version check

## Additional Notes

- CI workflow Bun versions (e.g., `1.2.3`, `1.2.0` in
`.github/workflows/release.yml`) are intentionally left unchanged -
these are pinned versions used to run the release tooling, not the
version being released
- Docker images use `ARG BUN_VERSION` passed at build time and don't
need updates
- The actual release version comes from git tags via `${{
env.BUN_VERSION }}`

---

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
2025-10-09 06:30:35 -07:00

187 lines
5.6 KiB
TypeScript

import { Database } from "bun:sqlite";
import { describe, expect } from "bun:test";
import { itBundled } from "./expectBundled";
describe("bundler", () => {
// https://github.com/oven-sh/bun/issues/18899
itBundled("bun/import-bun-format-cjs", {
target: "bun",
format: "cjs",
bytecode: true,
outdir: "/out",
files: {
"/entry.ts": /* js */ `
import {RedisClient} from 'bun';
import * as BunStar from 'bun';
const bunRequire = require("bun");
if (RedisClient.name !== "RedisClient") {
throw new Error("RedisClient.name is not RedisClient");
}
if (BunStar.RedisClient.name !== "RedisClient") {
throw new Error("BunStar.RedisClient.name is not RedisClient");
}
if (bunRequire.RedisClient.name !== "RedisClient") {
throw new Error("bunRequire.RedisClient.name is not RedisClient");
}
console.log(RedisClient.name);
console.log(BunStar.RedisClient.name);
console.log(bunRequire.RedisClient.name);
export class RedisCache {
constructor(config: any) {
this.connectServer(config);
}
}
`,
},
run: { stdout: "RedisClient\nRedisClient\nRedisClient\n" },
});
itBundled("bun/embedded-sqlite-file", {
target: "bun",
outfile: "",
outdir: "/out",
files: {
"/entry.ts": /* js */ `
import db from './db.sqlite' with {type: "sqlite", embed: "true"};
console.log(db.query("select message from messages LIMIT 1").get().message);
`,
"/db.sqlite": (() => {
const db = new Database(":memory:");
db.exec("create table messages (message text)");
db.exec("insert into messages values ('Hello, world!')");
return db.serialize();
})(),
},
run: { stdout: "Hello, world!" },
});
itBundled("bun/sqlite-file", {
target: "bun",
files: {
"/entry.ts": /* js */ `
import db from './db.sqlite' with {type: "sqlite"};
console.log(db.query("select message from messages LIMIT 1").get().message);
`,
},
runtimeFiles: {
"/db.sqlite": (() => {
const db = new Database(":memory:");
db.exec("create table messages (message text)");
db.exec("insert into messages values ('Hello, world!')");
return db.serialize();
})(),
},
run: { stdout: "Hello, world!", setCwd: true },
});
itBundled("bun/TargetBunNoSourcemapMessage", {
target: "bun",
files: {
"/entry.ts": /* js */ `
// this file has comments and weird whitespace, intentionally
// to make it obvious if sourcemaps were generated and mapped properly
if (true) code();
function code() {
// hello world
throw new
Error("Hello World");
}
`,
},
run: {
exitCode: 1,
validate({ stderr }) {
expect(stderr).toInclude("\nnote: missing sourcemaps for ");
expect(stderr).toInclude("\nnote: consider bundling with '--sourcemap' to get unminified traces\n");
},
},
});
itBundled("bun/TargetBunSourcemapInline", {
target: "bun",
files: {
"/entry.ts": /* js */ `
// this file has comments and weird whitespace, intentionally
// to make it obvious if sourcemaps were generated and mapped properly
if (true) code();
function code() {
// hello world
throw new
Error("Hello World");
}
`,
},
sourceMap: "inline",
run: {
exitCode: 1,
validate({ stderr }) {
expect(stderr).toStartWith(
`1 | // this file has comments and weird whitespace, intentionally
2 | // to make it obvious if sourcemaps were generated and mapped properly
3 | if (true) code();
4 | function code() {
5 | // hello world
6 | throw new
^
error: Hello World`,
);
expect(stderr).toInclude("entry.ts:6:19");
},
},
});
itBundled("bun/unicode comment", {
target: "bun",
files: {
"/a.ts": /* js */ `
/* æ */
`,
},
run: { stdout: "" },
});
if (Bun.version.startsWith("1.3") || Bun.version.startsWith("1.2")) {
for (const backend of ["api", "cli"] as const) {
itBundled("bun/ExportsConditionsDevelopment" + backend.toUpperCase(), {
files: {
"src/entry.js": `import 'pkg1'`,
"node_modules/pkg1/package.json": /* json */ `
{
"exports": {
"development": "./custom1.js",
"default": "./default.js"
}
}
`,
"node_modules/pkg1/custom1.js": `console.log('SUCCESS')`,
"node_modules/pkg1/default.js": `console.log('FAIL')`,
},
backend,
outfile: "out.js",
define: { "process.env.NODE_ENV": '"development"' },
run: {
stdout: "SUCCESS",
},
});
itBundled("bun/ExportsConditionsDevelopmentInProduction" + backend.toUpperCase(), {
files: {
"src/entry.js": `import 'pkg1'`,
"node_modules/pkg1/package.json": /* json */ `
{
"exports": {
"development": "./custom1.js",
"default": "./default.js"
}
}
`,
"node_modules/pkg1/custom1.js": `console.log('FAIL')`,
"node_modules/pkg1/default.js": `console.log('SUCCESS')`,
},
backend,
outfile: "/Users/user/project/out.js",
define: { "process.env.NODE_ENV": '"production"' },
run: {
stdout: "SUCCESS",
},
});
}
}
});