mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
bun run prettier
This commit is contained in:
committed by
github-actions[bot]
parent
81e767c7e3
commit
436819a9b2
30
packages/bun-types/bun.d.ts
vendored
30
packages/bun-types/bun.d.ts
vendored
@@ -2175,7 +2175,7 @@ declare module "bun" {
|
||||
root?: string; // project root
|
||||
splitting?: boolean; // default true, enable code splitting
|
||||
/**
|
||||
* Controls how entry point signatures are preserved.
|
||||
* Controls how entry point signatures are preserved.
|
||||
* - `"strict"`: Entry chunks contain only their direct code
|
||||
* - `"allow-extension"`: Shared modules can be merged into entry chunks (default)
|
||||
* - `"exports-only"`: Only explicitly exported symbols are preserved
|
||||
@@ -2270,7 +2270,7 @@ declare module "bun" {
|
||||
|
||||
/**
|
||||
* Advanced chunking options for custom module grouping and size constraints.
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* Bun.build({
|
||||
@@ -2297,31 +2297,31 @@ declare module "bun" {
|
||||
* @default undefined
|
||||
*/
|
||||
minShareCount?: number;
|
||||
|
||||
|
||||
/**
|
||||
* Minimum size for a chunk in bytes.
|
||||
* @default undefined
|
||||
*/
|
||||
minSize?: number;
|
||||
|
||||
|
||||
/**
|
||||
* Maximum size for a chunk in bytes.
|
||||
* @default undefined
|
||||
*/
|
||||
maxSize?: number;
|
||||
|
||||
|
||||
/**
|
||||
* Minimum size for a module to be considered for chunking.
|
||||
* @default undefined
|
||||
*/
|
||||
minModuleSize?: number;
|
||||
|
||||
|
||||
/**
|
||||
* Maximum size for a module to be included in a chunk.
|
||||
* @default undefined
|
||||
*/
|
||||
maxModuleSize?: number;
|
||||
|
||||
|
||||
/**
|
||||
* Custom grouping rules for modules.
|
||||
*/
|
||||
@@ -2330,44 +2330,44 @@ declare module "bun" {
|
||||
* Name of the group.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
|
||||
/**
|
||||
* Test pattern for matching modules (string will be treated as regex).
|
||||
*/
|
||||
test?: string | RegExp;
|
||||
|
||||
|
||||
/**
|
||||
* Priority for group matching (higher priority groups are matched first).
|
||||
* @default 0
|
||||
*/
|
||||
priority?: number;
|
||||
|
||||
|
||||
/**
|
||||
* Type of modules to include.
|
||||
* @default "all"
|
||||
*/
|
||||
type?: "javascript" | "css" | "asset" | "all";
|
||||
|
||||
|
||||
/**
|
||||
* Minimum size for the group.
|
||||
*/
|
||||
minSize?: number;
|
||||
|
||||
|
||||
/**
|
||||
* Maximum size for the group.
|
||||
*/
|
||||
maxSize?: number;
|
||||
|
||||
|
||||
/**
|
||||
* Minimum number of modules in the group.
|
||||
*/
|
||||
minChunks?: number;
|
||||
|
||||
|
||||
/**
|
||||
* Maximum number of modules in the group.
|
||||
*/
|
||||
maxChunks?: number;
|
||||
|
||||
|
||||
/**
|
||||
* Enforce creation of this group even if it would be empty.
|
||||
* @default false
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, test, expect } from "bun:test";
|
||||
import { bunExe, bunEnv, tempDirWithFiles } from "harness";
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { bunEnv, bunExe, tempDirWithFiles } from "harness";
|
||||
|
||||
describe("Advanced Chunks Edge Cases", () => {
|
||||
test("should handle empty advancedChunks config", async () => {
|
||||
@@ -355,4 +355,4 @@ describe("Advanced Chunks Edge Cases", () => {
|
||||
expect(exitCode).toBe(0);
|
||||
expect(stdout).toContain("Type test: true");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, test, expect } from "bun:test";
|
||||
import { bunExe, bunEnv, tempDirWithFiles } from "harness";
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { bunEnv, bunExe, tempDirWithFiles } from "harness";
|
||||
|
||||
describe("Advanced Chunks", () => {
|
||||
test("should accept advancedChunks config option", async () => {
|
||||
@@ -243,4 +243,4 @@ describe("Advanced Chunks", () => {
|
||||
expect(stdout).toContain("Advanced chunks test passed: true");
|
||||
expect(stderr).toBe("");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -151,7 +151,10 @@ describe("bundler", () => {
|
||||
run: [
|
||||
{ file: "/out/entry-a.js", stdout: "Shared loaded\nEntry A loaded" },
|
||||
{ file: "/out/entry-b.js", stdout: "Shared loaded\nEntry B: shared-value" },
|
||||
{ file: "/test.js", stdout: "Shared loaded\nEntry A loaded\nImported a: entry-a\nShared via function: shared-value" },
|
||||
{
|
||||
file: "/test.js",
|
||||
stdout: "Shared loaded\nEntry A loaded\nImported a: entry-a\nShared via function: shared-value",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
@@ -352,4 +355,4 @@ describe("bundler", () => {
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { tempDirWithFiles, bunExe, bunEnv } from "harness";
|
||||
import { readdirSync } from "fs";
|
||||
import { bunEnv, bunExe, tempDirWithFiles } from "harness";
|
||||
import { join } from "path";
|
||||
|
||||
describe("bundler", () => {
|
||||
@@ -27,9 +27,10 @@ describe("bundler", () => {
|
||||
"build",
|
||||
join(dir, "entry-a.js"),
|
||||
join(dir, "entry-b.js"),
|
||||
"--outdir", outDir,
|
||||
"--outdir",
|
||||
outDir,
|
||||
"--splitting",
|
||||
"--preserve-entry-signatures=strict"
|
||||
"--preserve-entry-signatures=strict",
|
||||
],
|
||||
env: bunEnv,
|
||||
cwd: dir,
|
||||
@@ -82,9 +83,10 @@ describe("bundler", () => {
|
||||
"build",
|
||||
join(dir, "entry-a.js"),
|
||||
join(dir, "entry-b.js"),
|
||||
"--outdir", outDir,
|
||||
"--outdir",
|
||||
outDir,
|
||||
"--splitting",
|
||||
"--preserve-entry-signatures=allow-extension"
|
||||
"--preserve-entry-signatures=allow-extension",
|
||||
],
|
||||
env: bunEnv,
|
||||
cwd: dir,
|
||||
@@ -112,8 +114,8 @@ describe("bundler", () => {
|
||||
const entryB = await Bun.file(join(outDir, "entry-b.js")).text();
|
||||
const utilInA = entryA.includes('util = "util"');
|
||||
const utilInB = entryB.includes('util = "util"');
|
||||
|
||||
|
||||
expect(utilInA !== utilInB).toBe(true); // Exactly one has util
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { tempDirWithFiles, bunExe, bunEnv } from "harness";
|
||||
import { readdirSync, readFileSync } from "fs";
|
||||
import { bunEnv, bunExe, tempDirWithFiles } from "harness";
|
||||
import { join } from "path";
|
||||
|
||||
// Comprehensive test suite for the Rolldown chunk extension optimization
|
||||
@@ -21,7 +21,16 @@ describe("bundler", () => {
|
||||
|
||||
const outDir = join(dir, "out");
|
||||
await using proc = Bun.spawn({
|
||||
cmd: [bunExe(), "build", "entry-a.js", "entry-b.js", "--outdir", outDir, "--splitting", "--preserve-entry-signatures=strict"],
|
||||
cmd: [
|
||||
bunExe(),
|
||||
"build",
|
||||
"entry-a.js",
|
||||
"entry-b.js",
|
||||
"--outdir",
|
||||
outDir,
|
||||
"--splitting",
|
||||
"--preserve-entry-signatures=strict",
|
||||
],
|
||||
env: bunEnv,
|
||||
cwd: dir,
|
||||
});
|
||||
@@ -46,7 +55,16 @@ describe("bundler", () => {
|
||||
|
||||
const outDir = join(dir, "out");
|
||||
await using proc = Bun.spawn({
|
||||
cmd: [bunExe(), "build", "entry-a.js", "entry-b.js", "--outdir", outDir, "--splitting", "--preserve-entry-signatures=allow-extension"],
|
||||
cmd: [
|
||||
bunExe(),
|
||||
"build",
|
||||
"entry-a.js",
|
||||
"entry-b.js",
|
||||
"--outdir",
|
||||
outDir,
|
||||
"--splitting",
|
||||
"--preserve-entry-signatures=allow-extension",
|
||||
],
|
||||
env: bunEnv,
|
||||
cwd: dir,
|
||||
});
|
||||
@@ -54,11 +72,11 @@ describe("bundler", () => {
|
||||
expect(await proc.exited).toBe(0);
|
||||
const files = readdirSync(outDir);
|
||||
expect(files.length).toBe(2); // Optimization merged shared into an entry
|
||||
|
||||
|
||||
// Verify cross-imports
|
||||
const entryA = readFileSync(join(outDir, "entry-a.js"), "utf-8");
|
||||
const entryB = readFileSync(join(outDir, "entry-b.js"), "utf-8");
|
||||
|
||||
|
||||
// One should have the shared code, other should import
|
||||
const hasShared = (content: string) => content.includes("shared-value");
|
||||
expect(hasShared(entryA) !== hasShared(entryB)).toBe(true);
|
||||
@@ -85,7 +103,16 @@ describe("bundler", () => {
|
||||
|
||||
const outDir = join(dir, "out");
|
||||
await using proc = Bun.spawn({
|
||||
cmd: [bunExe(), "build", "entry-a.js", "entry-b.js", "--outdir", outDir, "--splitting", "--preserve-entry-signatures=allow-extension"],
|
||||
cmd: [
|
||||
bunExe(),
|
||||
"build",
|
||||
"entry-a.js",
|
||||
"entry-b.js",
|
||||
"--outdir",
|
||||
outDir,
|
||||
"--splitting",
|
||||
"--preserve-entry-signatures=allow-extension",
|
||||
],
|
||||
env: bunEnv,
|
||||
cwd: dir,
|
||||
});
|
||||
@@ -119,7 +146,17 @@ describe("bundler", () => {
|
||||
|
||||
const outDir = join(dir, "out");
|
||||
await using proc = Bun.spawn({
|
||||
cmd: [bunExe(), "build", "entry-a.js", "entry-b.js", "entry-c.js", "--outdir", outDir, "--splitting", "--preserve-entry-signatures=allow-extension"],
|
||||
cmd: [
|
||||
bunExe(),
|
||||
"build",
|
||||
"entry-a.js",
|
||||
"entry-b.js",
|
||||
"entry-c.js",
|
||||
"--outdir",
|
||||
outDir,
|
||||
"--splitting",
|
||||
"--preserve-entry-signatures=allow-extension",
|
||||
],
|
||||
env: bunEnv,
|
||||
cwd: dir,
|
||||
});
|
||||
@@ -127,16 +164,16 @@ describe("bundler", () => {
|
||||
expect(await proc.exited).toBe(0);
|
||||
const files = readdirSync(outDir);
|
||||
expect(files.length).toBe(3); // Each entry has its unique module
|
||||
|
||||
|
||||
// Verify shared module is in one of entry-a or entry-b
|
||||
const entryA = readFileSync(join(outDir, "entry-a.js"), "utf-8");
|
||||
const entryB = readFileSync(join(outDir, "entry-b.js"), "utf-8");
|
||||
const entryC = readFileSync(join(outDir, "entry-c.js"), "utf-8");
|
||||
|
||||
|
||||
const sharedInA = entryA.includes('shared = "shared"');
|
||||
const sharedInB = entryB.includes('shared = "shared"');
|
||||
const sharedInC = entryC.includes('shared = "shared"');
|
||||
|
||||
|
||||
expect(sharedInC).toBe(false); // C doesn't use shared
|
||||
expect(sharedInA !== sharedInB).toBe(true); // Exactly one of A or B has it
|
||||
});
|
||||
@@ -166,29 +203,41 @@ describe("bundler", () => {
|
||||
|
||||
const outDir = join(dir, "out");
|
||||
await using proc = Bun.spawn({
|
||||
cmd: [bunExe(), "build", "entry-a.js", "entry-b.js", "entry-c.js", "--outdir", outDir, "--splitting", "--preserve-entry-signatures=allow-extension"],
|
||||
cmd: [
|
||||
bunExe(),
|
||||
"build",
|
||||
"entry-a.js",
|
||||
"entry-b.js",
|
||||
"entry-c.js",
|
||||
"--outdir",
|
||||
outDir,
|
||||
"--splitting",
|
||||
"--preserve-entry-signatures=allow-extension",
|
||||
],
|
||||
env: bunEnv,
|
||||
cwd: dir,
|
||||
});
|
||||
|
||||
expect(await proc.exited).toBe(0);
|
||||
const files = readdirSync(outDir);
|
||||
|
||||
|
||||
// With optimization, shared modules should be consolidated
|
||||
expect(files.length).toBeLessThan(6); // Less than 3 entries + 3 shared
|
||||
expect(files).toContain("entry-a.js");
|
||||
expect(files).toContain("entry-b.js");
|
||||
expect(files).toContain("entry-c.js");
|
||||
|
||||
|
||||
// Count how many files contain each shared module
|
||||
let abCount = 0, bcCount = 0, abcCount = 0;
|
||||
let abCount = 0,
|
||||
bcCount = 0,
|
||||
abcCount = 0;
|
||||
for (const file of files) {
|
||||
const content = readFileSync(join(outDir, file), "utf-8");
|
||||
if (content.includes("shared-by-ab")) abCount++;
|
||||
if (content.includes("shared-by-bc")) bcCount++;
|
||||
if (content.includes("shared-by-all")) abcCount++;
|
||||
}
|
||||
|
||||
|
||||
// Each shared module should appear exactly once
|
||||
expect(abCount).toBe(1);
|
||||
expect(bcCount).toBe(1);
|
||||
@@ -211,7 +260,16 @@ describe("bundler", () => {
|
||||
|
||||
const outDir = join(dir, "out");
|
||||
await using proc = Bun.spawn({
|
||||
cmd: [bunExe(), "build", "entry.js", "other.js", "--outdir", outDir, "--splitting", `--preserve-entry-signatures=${mode}`],
|
||||
cmd: [
|
||||
bunExe(),
|
||||
"build",
|
||||
"entry.js",
|
||||
"other.js",
|
||||
"--outdir",
|
||||
outDir,
|
||||
"--splitting",
|
||||
`--preserve-entry-signatures=${mode}`,
|
||||
],
|
||||
env: bunEnv,
|
||||
cwd: dir,
|
||||
});
|
||||
@@ -233,4 +291,4 @@ describe("bundler", () => {
|
||||
expect(falseCount).toBe(2);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user