Skip to content

Commit 3ba5e2b

Browse files
Merge pull request #7085 from Shopify/03-24-fix_restore_dist_index.wasm_bundle_path_contract_for_function_extensions
fix: restore dist/index.wasm bundle path contract for function extensions
2 parents 15263fa + 07bb33a commit 3ba5e2b

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

packages/app/src/cli/models/app/loader.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2249,8 +2249,8 @@ describe('load', () => {
22492249
// When
22502250
const app = await loadTestingApp()
22512251

2252-
// Then
2253-
expect(app.allExtensions[0]!.outputPath).toMatch(/wasm32-wasi\/release\/my-function.wasm/)
2252+
// Then - outputPath always defaults to dist/index.wasm at load time; build.path is applied by buildFunctionExtension
2253+
expect(app.allExtensions[0]!.outputPath).toMatch(/dist\/index\.wasm/)
22542254
})
22552255

22562256
test(`defaults the function wasm path if not configured`, async () => {

packages/app/src/cli/models/extensions/extension-instance.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ describe('draftMessages', async () => {
544544
expect(extensionInstance.outputPath).toBe(joinPath('test-function', 'dist', 'index.wasm'))
545545
})
546546

547-
test('uses custom path when build.path is defined', async () => {
547+
test('uses default path when build.path is defined (custom path is only applied during build)', async () => {
548548
// Given
549549
const config = functionConfiguration()
550550
config.build = {
@@ -557,8 +557,8 @@ describe('draftMessages', async () => {
557557
dir: 'test-function',
558558
})
559559

560-
// Then
561-
expect(extensionInstance.outputPath).toBe(joinPath('test-function', 'custom/output.wasm'))
560+
// Then - outputPath always defaults to dist/index.wasm; build.path is applied by buildFunctionExtension
561+
expect(extensionInstance.outputPath).toBe(joinPath('test-function', 'dist', 'index.wasm'))
562562
})
563563
})
564564
})

packages/app/src/cli/models/extensions/specifications/function.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ const functionSpec = createExtensionSpecification({
8989
schema: FunctionExtensionSchema,
9090
appModuleFeatures: (_) => ['function'],
9191
buildConfig: {mode: 'function'},
92-
getOutputRelativePath: (extension: ExtensionInstance<FunctionConfigType>) =>
93-
extension.configuration.build?.path ?? joinPath('dist', 'index.wasm'),
92+
getOutputRelativePath: (_extension: ExtensionInstance<FunctionConfigType>) => joinPath('dist', 'index.wasm'),
9493
deployConfig: async (config, directory, apiKey) => {
9594
let inputQuery: string | undefined
9695
const moduleId = randomUUID()

packages/app/src/cli/services/build/extension.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ export async function buildFunctionExtension(
150150

151151
try {
152152
const bundlePath = extension.outputPath
153-
const relativeBuildPath = extension.specification.getOutputRelativePath?.(extension) ?? ''
153+
const relativeBuildPath =
154+
(extension as ExtensionInstance<FunctionConfigType>).configuration.build?.path ?? extension.outputRelativePath
154155

155156
extension.outputPath = joinPath(extension.directory, relativeBuildPath)
156157

0 commit comments

Comments
 (0)