mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
@@ -1689,10 +1689,11 @@ fn NewPrinter(
|
||||
.bun => {
|
||||
if (record.kind == .dynamic) {
|
||||
p.print("Promise.resolve(globalThis.Bun)");
|
||||
} else if (record.kind == .require) {
|
||||
return;
|
||||
} else if (record.kind == .require or record.kind == .stmt) {
|
||||
p.print("globalThis.Bun");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
},
|
||||
.bun_test => {
|
||||
if (record.kind == .dynamic) {
|
||||
|
||||
@@ -3,6 +3,41 @@ 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: "",
|
||||
|
||||
Reference in New Issue
Block a user