Skip to content

Commit 1ab6618

Browse files
Merge pull request #7013 from Shopify/smaller-bundle
Smaller bundle
2 parents f1bf879 + 8fa1647 commit 1ab6618

7 files changed

Lines changed: 26 additions & 47 deletions

File tree

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,7 @@
147147
"ignoreBinaries": [
148148
"playwright"
149149
],
150-
"ignoreDependencies": [
151-
"@shopify/theme-check-node",
152-
"@shopify/theme-check-docs-updater"
153-
],
150+
"ignoreDependencies": [],
154151
"ignoreWorkspaces": [
155152
"packages/eslint-plugin-cli",
156153
"packages/e2e"
@@ -199,6 +196,7 @@
199196
"**/graphql/**/generated/*.ts"
200197
],
201198
"ignoreDependencies": [
199+
"@graphql-typed-document-node/core",
202200
"@shopify/plugin-cloudflare"
203201
],
204202
"vite": {
@@ -215,7 +213,9 @@
215213
],
216214
"project": "**/*.ts!",
217215
"ignoreDependencies": [
218-
"@ast-grep/napi"
216+
"@ast-grep/napi",
217+
"@shopify/theme-check-docs-updater",
218+
"@shopify/theme-check-node"
219219
],
220220
"vite": {
221221
"config": [
@@ -288,6 +288,9 @@
288288
"ignoreBinaries": [
289289
"open"
290290
],
291+
"ignoreDependencies": [
292+
"@graphql-typed-document-node/core"
293+
],
291294
"vite": {
292295
"config": [
293296
"vite.config.ts"
@@ -306,10 +309,7 @@
306309
"**/scripts/*.ts!",
307310
"**/src/testing/index.ts"
308311
],
309-
"project": "**/*.{ts,tsx}!",
310-
"ignoreDependencies": [
311-
"react-dom"
312-
]
312+
"project": "**/*.{ts,tsx}!"
313313
},
314314
"packages/ui-extensions-test-utils": {
315315
"entry": [

packages/cli-kit/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
"ansi-escapes": "6.2.1",
121121
"archiver": "5.3.2",
122122
"bottleneck": "2.19.5",
123-
"brotli": "1.3.3",
123+
124124
"chalk": "5.4.1",
125125
"change-case": "4.1.2",
126126
"color-json": "3.0.5",
@@ -168,7 +168,7 @@
168168
"zod": "3.24.4"
169169
},
170170
"devDependencies": {
171-
"@types/brotli": "^1.3.4",
171+
172172
"@types/commondir": "^1.0.0",
173173
"@types/diff": "^5.2.3",
174174
"@types/fs-extra": "9.0.13",

packages/cli-kit/src/public/node/archiver.integration.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {joinPath, dirname} from './path.js'
44
import {exec} from './system.js'
55
import {describe, expect, test} from 'vitest'
66
import StreamZip from 'node-stream-zip'
7-
import brotli from 'brotli'
7+
import {brotliDecompressSync} from 'zlib'
88

99
import fs from 'fs'
1010

@@ -92,8 +92,8 @@ describe('brotliCompress', () => {
9292
// Brotli files start with the bytes 0x1B...
9393
expect(compressedContent[0]).toBe(0x1b)
9494

95-
// Decompress using brotli library
96-
const decompressed = brotli.decompress(compressedContent)
95+
// Decompress using native zlib brotli
96+
const decompressed = brotliDecompressSync(compressedContent)
9797
expect(decompressed).toBeTruthy()
9898
})
9999
})
@@ -125,7 +125,7 @@ describe('brotliCompress', () => {
125125

126126
// Save compressed content to a file
127127
const compressedContent = fs.readFileSync(brotliPath)
128-
const decompressed = brotli.decompress(compressedContent)
128+
const decompressed = brotliDecompressSync(compressedContent)
129129
const tmpTarPath = joinPath(tmpDir, 'output.tar')
130130
fs.writeFileSync(tmpTarPath, decompressed)
131131

packages/cli-kit/src/public/node/archiver.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {createWriteStream, readFileSync, writeFileSync} from 'fs'
66
import {readFile} from 'fs/promises'
77
import {tmpdir} from 'os'
88
import {randomUUID} from 'crypto'
9+
import {brotliCompressSync, constants as zlibConstants} from 'zlib'
910

1011
interface ZipOptions {
1112
/**
@@ -183,16 +184,13 @@ export async function brotliCompress(options: BrotliOptions): Promise<void> {
183184
})
184185

185186
const tarContent = readFileSync(tempTarPath)
186-
const brotli = await import('brotli')
187-
const compressed = brotli.default.compress(tarContent, {
188-
quality: 7,
189-
mode: 0,
187+
const compressed = brotliCompressSync(tarContent, {
188+
params: {
189+
[zlibConstants.BROTLI_PARAM_QUALITY]: 7,
190+
[zlibConstants.BROTLI_PARAM_MODE]: zlibConstants.BROTLI_MODE_GENERIC,
191+
},
190192
})
191193

192-
if (!compressed) {
193-
throw new Error('Brotli compression failed')
194-
}
195-
196194
writeFileSync(options.outputPath, compressed)
197195
} finally {
198196
try {

packages/cli/bin/bundle.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const hydrogenAssets = joinPath(hydrogenPath, 'dist/assets/hydrogen/**/*')
4040

4141
esBuild({
4242
bundle: true,
43-
entryPoints: ['./src/**/*.ts'],
43+
entryPoints: ['./src/index.ts', './src/hooks/prerun.ts', './src/hooks/postrun.ts'],
4444
outdir: './dist',
4545
platform: 'node',
4646
format: 'esm',
@@ -53,14 +53,14 @@ esBuild({
5353
},
5454
inject: ['../../bin/bundling/cjs-shims.js'],
5555
external,
56-
sourcemap: true,
56+
sourcemap: 'external',
5757
loader: {'.node': 'copy'},
5858
splitting: true,
5959
// these tree shaking and minify options remove any in-source tests from the bundle
6060
treeShaking: true,
61-
minifyWhitespace: false,
61+
minifyWhitespace: true,
6262
minifySyntax: true,
63-
minifyIdentifiers: false,
63+
minifyIdentifiers: true,
6464

6565
plugins: [
6666
ShopifyVSCodePlugin,

packages/cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"/bin/run.cmd",
3939
"/bin/run.js",
4040
"/dist",
41+
"!/dist/**/*.map",
4142
"/oclif.manifest.json"
4243
],
4344
"scripts": {

pnpm-lock.yaml

Lines changed: 0 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)