Skip to content

Commit a4e320f

Browse files
authored
Merge pull request #7413 from Shopify/04-28-skip_manifest_generation_when_bundle_dir_matches_local_output
Skip manifest generation when bundle dir matches local output
2 parents 3b42804 + 3cc6aa2 commit a4e320f

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

packages/app/src/cli/services/build/steps/bundle-ui-step.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {executeBundleUIStep} from './bundle-ui-step.js'
2+
import * as generateManifest from './include-assets/generate-manifest.js'
23
import * as buildExtension from '../extension.js'
34
import {BundleUIStep, BuildContext} from '../client-steps.js'
45
import {ExtensionInstance} from '../../../models/extensions/extension-instance.js'
@@ -7,6 +8,7 @@ import * as fs from '@shopify/cli-kit/node/fs'
78

89
vi.mock('@shopify/cli-kit/node/fs')
910
vi.mock('../extension.js')
11+
vi.mock('./include-assets/generate-manifest.js')
1012

1113
describe('executeBundleUIStep', () => {
1214
let mockContext: BuildContext
@@ -55,4 +57,25 @@ describe('executeBundleUIStep', () => {
5557

5658
expect(fs.copyFile).not.toHaveBeenCalled()
5759
})
60+
61+
test('skips manifest generation when local and bundle output directories resolve to the same path', async () => {
62+
const stepWithManifest: BundleUIStep = {
63+
id: 'bundle-ui',
64+
name: 'Bundle UI Extension',
65+
type: 'bundle_ui',
66+
config: {generatesAssetsManifest: true},
67+
}
68+
mockContext.extension.outputPath = '/test/./extension/dist/handle.js'
69+
mockContext.extension.configuration = {
70+
extension_points: [
71+
{target: 'admin.product-details.action.render', build_manifest: {assets: {main: {filepath: 'main.js'}}}},
72+
],
73+
} as ExtensionInstance['configuration']
74+
vi.mocked(buildExtension.buildUIExtension).mockResolvedValue('/test/extension/dist/handle.js')
75+
76+
await executeBundleUIStep(stepWithManifest, mockContext)
77+
78+
expect(fs.copyFile).not.toHaveBeenCalled()
79+
expect(generateManifest.createOrUpdateManifestFile).not.toHaveBeenCalled()
80+
})
5881
})

packages/app/src/cli/services/build/steps/bundle-ui-step.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ export async function executeBundleUIStep(step: BundleUIStep, context: BuildCont
2626
const bundleOutputDir = step.config?.bundleFolder
2727
? joinPath(dirname(context.extension.outputPath), step.config.bundleFolder)
2828
: dirname(context.extension.outputPath)
29-
if (resolvePath(localOutputDir) !== resolvePath(bundleOutputDir)) {
30-
await copyFile(localOutputDir, bundleOutputDir)
31-
}
29+
30+
// If the final output path is the same as the local one: don't copy the results and don't generate manifests.
31+
if (resolvePath(localOutputDir) === resolvePath(bundleOutputDir)) return
32+
33+
await copyFile(localOutputDir, bundleOutputDir)
3234

3335
if (!step.config?.generatesAssetsManifest) return
3436

0 commit comments

Comments
 (0)