Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-bundle-ui-step-path-normalization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/app': patch
---

Fix `shopify app build` intermittently failing with "Source and destination must not be the same" on UI extensions when the local esbuild output directory and the bundle output directory resolve to the same path but differ as strings (e.g. due to `.` segments, trailing slashes, or path joining quirks). The same-path guard now normalizes both paths via `resolvePath` before comparison.
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,13 @@ describe('executeBundleUIStep', () => {
// Then
expect(fs.copyFile).toHaveBeenCalledWith('/test/extension/dist', '/bundle/handle')
})

test('skips the copy when local and bundle output directories resolve to the same path but differ as strings', async () => {
mockContext.extension.outputPath = '/test/./extension/dist/handle.js'
vi.mocked(buildExtension.buildUIExtension).mockResolvedValue('/test/extension/dist/handle.js')

await executeBundleUIStep(step, mockContext)

expect(fs.copyFile).not.toHaveBeenCalled()
})
})
4 changes: 2 additions & 2 deletions packages/app/src/cli/services/build/steps/bundle-ui-step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {createOrUpdateManifestFile} from './include-assets/generate-manifest.js'
import {buildUIExtension} from '../extension.js'
import {BuildManifest} from '../../../models/extensions/specifications/ui_extension.js'
import {copyFile} from '@shopify/cli-kit/node/fs'
import {dirname, joinPath} from '@shopify/cli-kit/node/path'
import {dirname, joinPath, resolvePath} from '@shopify/cli-kit/node/path'
import type {BundleUIStep, BuildContext} from '../client-steps.js'

interface ExtensionPointWithBuildManifest {
Expand All @@ -27,7 +27,7 @@ export async function executeBundleUIStep(step: BundleUIStep, context: BuildCont
const bundleOutputDir = step.config?.bundleFolder
? joinPath(dirname(context.extension.outputPath), step.config.bundleFolder)
: dirname(context.extension.outputPath)
if (localOutputDir !== bundleOutputDir) {
if (resolvePath(localOutputDir) !== resolvePath(bundleOutputDir)) {
await copyFile(localOutputDir, bundleOutputDir)
}
Comment thread
vctrchu marked this conversation as resolved.

Expand Down
Loading