Skip to content

Commit 3a6cf38

Browse files
Merge pull request #5581 from Shopify/03-28-exclude_map_files_from_the_app_bundle
Exclude map files from the app bundle
2 parents 13b9d5a + 947c99c commit 3a6cf38

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

packages/app/src/cli/services/bundle.test.ts

+19
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,23 @@ describe('compressBundle', () => {
4444
expect(zipExists).toBe(true)
4545
})
4646
})
47+
48+
test('excludes .js.map files from the zip', async () => {
49+
await inTemporaryDirectory(async (tmpDir) => {
50+
// Given
51+
const inputDir = joinPath(tmpDir, 'input')
52+
const outputZip = joinPath(tmpDir, 'output.zip')
53+
await mkdir(inputDir)
54+
await writeFile(joinPath(inputDir, 'test.txt'), 'test content')
55+
await writeFile(joinPath(inputDir, 'test.js.map'), 'test content')
56+
57+
// When
58+
await compressBundle(inputDir, outputZip)
59+
60+
// Then
61+
const zipContent = await readFile(outputZip)
62+
// We are reading the zip as a binary because we don't have a library to unzip, but we can still check for the presence of the file name
63+
expect(zipContent).not.toContain('test.js.map')
64+
})
65+
})
4766
})

packages/app/src/cli/services/bundle.ts

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export async function compressBundle(inputPath: string, outputPath: string) {
1919
await zip({
2020
inputDirectory: inputPath,
2121
outputZipPath: outputPath,
22+
matchFilePattern: ['**/*', '!**/*.js.map'],
2223
})
2324
}
2425

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ interface ZipOptions {
1616
outputZipPath: string
1717

1818
/**
19-
* Pattern to match when adding files to zip, uses glob expressions.
19+
* Pattern(s) to match when adding files to zip, uses glob expressions.
2020
*/
21-
matchFilePattern?: string
21+
matchFilePattern?: string | string[]
2222
}
2323

2424
/**

0 commit comments

Comments
 (0)