Skip to content

Commit

Permalink
Merge pull request #5024 from Shopify/fix-function-drafts-stable
Browse files Browse the repository at this point in the history
[stable] Fix function drafts during `dev`
  • Loading branch information
isaacroldan authored Dec 4, 2024
2 parents 38dc70c + 998ba06 commit 1312153
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/wicked-singers-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/app': patch
---

Fix function drafts not working during dev
2 changes: 1 addition & 1 deletion packages/app/src/cli/services/dev/update-extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ describe('updateExtensionDraft()', () => {
const content = 'test content'
const base64Content = Buffer.from(content).toString('base64')
await mkdir(joinPath(mockExtension.directory, 'dist'))
const outputPath = mockExtension.getOutputPathForDirectory(tmpDir)
const outputPath = mockExtension.outputPath
await mkdir(dirname(outputPath))
await writeFile(outputPath, content)

Expand Down
6 changes: 4 additions & 2 deletions packages/app/src/cli/services/dev/update-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,17 @@ export async function updateExtensionDraft({
// When updating just the theme extension draft, upload the files as part of the config.
config = await themeExtensionConfig(extension)
} else {
config = (await extension.deployConfig({apiKey, appConfiguration})) || {}
config = (await extension.deployConfig({apiKey, appConfiguration})) ?? {}
}

const draftableConfig: {[key: string]: unknown} = {
...config,
serialized_script: encodedFile,
}
if (extension.isFunctionExtension) {
const compiledFiles = await readFile(outputPath, {encoding: 'base64'})
// For function drafts we need to use the `extension.outputPath` instead of `bundlePath`
// The wasm in the bundle path is encoded in base64.
const compiledFiles = await readFile(extension.outputPath, {encoding: 'base64'})
draftableConfig.uploaded_files = {'dist/index.wasm': compiledFiles}
}
const extensionInput: ExtensionUpdateDraftMutationVariables = {
Expand Down

0 comments on commit 1312153

Please sign in to comment.