Skip to content
/ bud Public

Commit 5c3f02f

Browse files
authored
✨ improve(minor): no split chunks (@roots/sage) (#2399)
- don't create vendor chunk by default - users can create a vendor chunk using [bud.bundle](https://bud.js.org/docs/bud.bundle) or async imports - prevents `@wordpress/*` dependencies from being enqueued by Acorn for multiple entrypoints when they are only utilized in one ## References - https://discourse.roots.io/t/updating-bud-to-6-14-x-adds-all-wp-includes-scripts-to-front-end/25736 ## Type of change **MINOR: feature**
1 parent b47f0e9 commit 5c3f02f

File tree

3 files changed

+7
-23
lines changed

3 files changed

+7
-23
lines changed

sources/@roots/sage/src/sage/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class Sage extends Extension {
4747
})
4848
.when(
4949
bud.isProduction,
50-
() => bud.minimize().hash().splitChunks(),
50+
() => bud.hash(),
5151
() => bud.devtool(),
5252
)
5353
.hooks.on(`build.output.uniqueName`, `@roots/bud/sage/${bud.label}`)

sources/@roots/sage/test/sage/extension.test.ts

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,35 +63,20 @@ describe(`@roots/sage`, async () => {
6363
expect(spy).toHaveBeenCalled()
6464
})
6565

66-
it(`should call bud.minimize in production`, async () => {
67-
const bud = await factory({mode: `production`})
68-
expect(bud.isProduction).toBe(true)
69-
70-
const whenSpy = vi.spyOn(bud, `when`)
71-
const spy = vi.spyOn(bud, `minimize`)
72-
await sage.register(bud)
73-
expect(whenSpy).toHaveBeenCalledWith(
74-
true,
75-
expect.any(Function),
76-
expect.any(Function),
77-
)
78-
expect(spy).toHaveBeenCalled()
79-
})
80-
81-
it(`should call bud.splitChunks in production`, async () => {
66+
it(`should call bud.hash in production`, async () => {
8267
const bud = await factory({mode: `production`})
8368
expect(bud.isProduction).toBe(true)
8469

8570
const whenSpy = vi.spyOn(bud, `when`)
86-
const spy = vi.spyOn(bud, `splitChunks`)
8771
const devtoolSpy = vi.spyOn(bud, `devtool`)
72+
const hashSpy = vi.spyOn(bud, `hash`)
8873
await sage.register(bud)
8974
expect(whenSpy).toHaveBeenCalledWith(
9075
true,
9176
expect.any(Function),
9277
expect.any(Function),
9378
)
94-
expect(spy).toHaveBeenCalled()
79+
expect(hashSpy).toHaveBeenCalled()
9580
expect(devtoolSpy).not.toHaveBeenCalled()
9681
})
9782

@@ -100,14 +85,14 @@ describe(`@roots/sage`, async () => {
10085
expect(bud.isProduction).toBe(false)
10186
const whenSpy = vi.spyOn(bud, `when`)
10287
const devtoolSpy = vi.spyOn(bud, `devtool`)
103-
const splitChunksSpy = vi.spyOn(bud, `splitChunks`)
88+
const hashSpy = vi.spyOn(bud, `hash`)
10489
await sage.register(bud)
10590
expect(whenSpy).toHaveBeenCalledWith(
10691
false,
10792
expect.any(Function),
10893
expect.any(Function),
10994
)
11095
expect(devtoolSpy).toHaveBeenCalled()
111-
expect(splitChunksSpy).not.toHaveBeenCalled()
96+
expect(hashSpy).not.toHaveBeenCalled()
11297
})
11398
})

tests/reproductions/issue-2126.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ describe(`issue-2126`, () => {
2929
),
3030
`utf8`,
3131
)
32-
expect(js.length).toBeLessThan(65000)
33-
32+
expect(js.length).toBeLessThan(75000)
3433
const css = await fs.read(
3534
join(
3635
paths.tests,

0 commit comments

Comments
 (0)