Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {executeBundleUIStep} from './bundle-ui-step.js'
import * as generateManifest from './include-assets/generate-manifest.js'
import * as buildExtension from '../extension.js'
import {BundleUIStep, BuildContext} from '../client-steps.js'
import {ExtensionInstance} from '../../../models/extensions/extension-instance.js'
Expand All @@ -7,6 +8,7 @@ import * as fs from '@shopify/cli-kit/node/fs'

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

describe('executeBundleUIStep', () => {
let mockContext: BuildContext
Expand Down Expand Up @@ -55,4 +57,25 @@ describe('executeBundleUIStep', () => {

expect(fs.copyFile).not.toHaveBeenCalled()
})

test('skips manifest generation when local and bundle output directories resolve to the same path', async () => {
const stepWithManifest: BundleUIStep = {
id: 'bundle-ui',
name: 'Bundle UI Extension',
type: 'bundle_ui',
config: {generatesAssetsManifest: true},
}
mockContext.extension.outputPath = '/test/./extension/dist/handle.js'
mockContext.extension.configuration = {
extension_points: [
{target: 'admin.product-details.action.render', build_manifest: {assets: {main: {filepath: 'main.js'}}}},
],
} as ExtensionInstance['configuration']
vi.mocked(buildExtension.buildUIExtension).mockResolvedValue('/test/extension/dist/handle.js')

await executeBundleUIStep(stepWithManifest, mockContext)

expect(fs.copyFile).not.toHaveBeenCalled()
expect(generateManifest.createOrUpdateManifestFile).not.toHaveBeenCalled()
})
})
8 changes: 5 additions & 3 deletions packages/app/src/cli/services/build/steps/bundle-ui-step.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ 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 (resolvePath(localOutputDir) !== resolvePath(bundleOutputDir)) {
await copyFile(localOutputDir, bundleOutputDir)
}

// If the final output path is the same as the local one: don't copy the results and don't generate manifests.
if (resolvePath(localOutputDir) === resolvePath(bundleOutputDir)) return

await copyFile(localOutputDir, bundleOutputDir)

if (!step.config?.generatesAssetsManifest) return

Expand Down
Loading