1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
import assert from "assert";
import { ESBUILD, itBundled, testForFile } from "./expectBundled";
var { describe, test, expect } = testForFile(import.meta.path);
describe("bundler", () => {
itBundled("npm/ReactSSR", {
install: ["react@next", "react-dom@next"],
files: {
"/entry.tsx": /* tsx */ `
import React from "react";
import { renderToReadableStream } from "react-dom/server";
const headers = {
headers: {
"Content-Type": "text/html",
},
};
const App = () => (
<html>
<body>
<h1>Hello World</h1>
<p>This is an example.</p>
</body>
</html>
);
const port = 42001;
const server = Bun.serve({
port,
async fetch(req) {
return new Response(await renderToReadableStream(<App />), headers);
},
});
const res = await fetch("http://localhost:" + port);
if (res.status !== 200) throw "status error";
console.log(await res.text());
server.stop();
`,
},
run: {
stdout: "<!DOCTYPE html><html><head></head><body><h1>Hello World</h1><p>This is an example.</p></body></html>",
},
});
itBundled("npm/LodashES", {
install: ["lodash-es"],
files: {
"/entry.ts": /* tsx */ `
import { isEqual, isBuffer } from "lodash-es";
// https://github.com/oven-sh/bun/issues/3206
if(!isEqual({a: 1}, {a: 1})) throw "error 1";
if(isEqual({a: 1}, {a: 2})) throw "error 2";
// Uncomment when https://github.com/lodash/lodash/issues/5660 is fixed
// It prevents isBuffer from working at all since it evaluates to 'stubFalse'
// if(!isBuffer(Buffer.from("hello"))) throw "error 3";
// if(isBuffer("hello")) throw "error 4";
// if(isBuffer({})) throw "error 5";
// if(isBuffer(new Uint8Array([1]))) throw "error 6";
// if(isBuffer(new ArrayBuffer(1))) throw "error 7";
console.log('pass')
`,
},
run: {
stdout: "pass",
},
});
});
|