diff --git a/.changeset/seven-seahorses-bake.md b/.changeset/seven-seahorses-bake.md new file mode 100644 index 00000000000..9117786fef0 --- /dev/null +++ b/.changeset/seven-seahorses-bake.md @@ -0,0 +1,5 @@ +--- +'@shopify/app': minor +--- + +Use Shopify Functions Javy plugin instead of default Javy plugin for building JS Shopify Functions diff --git a/.gitignore b/.gitignore index 13df16cc1c8..499fc2c132b 100644 --- a/.gitignore +++ b/.gitignore @@ -155,6 +155,7 @@ packaging/dist cloudflared* function-runner* javy* +shopify_functions_javy_v*.wasm # Vitest vscode extension autogenerated files index.d.ts diff --git a/packages/app/src/cli/services/function/binaries.test.ts b/packages/app/src/cli/services/function/binaries.test.ts index 7656cd9e2f0..80bc845d5cd 100644 --- a/packages/app/src/cli/services/function/binaries.test.ts +++ b/packages/app/src/cli/services/function/binaries.test.ts @@ -135,9 +135,9 @@ describe('javy', () => { describe('javy-plugin', () => { test('properties are set correctly', () => { - expect(javyPlugin.name).toBe('javy_quickjs_provider_v3') - expect(javyPlugin.version).match(/^v\d.\d.\d$/) - expect(javyPlugin.path).toMatch(/(\/|\\)javy_quickjs_provider_v3.wasm$/) + expect(javyPlugin.name).toBe('shopify_functions_javy_v1') + expect(javyPlugin.version).match(/^v\d+$/) + expect(javyPlugin.path).toMatch(/(\/|\\)shopify_functions_javy_v1.wasm$/) }) test('downloadUrl returns the correct URL', () => { @@ -145,7 +145,9 @@ describe('javy-plugin', () => { const url = javyPlugin.downloadUrl('', '') // Then - expect(url).toMatch(/https:\/\/github.com\/bytecodealliance\/javy\/releases\/download\/v\d\.\d\.\d\/plugin.wasm.gz/) + expect(url).toMatch( + /^https:\/\/cdn\.shopify\.com\/shopifycloud\/shopify-functions-javy-plugin\/shopify_functions_javy_v\d+\.wasm$/, + ) }) test('downloads javy-plugin', async () => { diff --git a/packages/app/src/cli/services/function/binaries.ts b/packages/app/src/cli/services/function/binaries.ts index d702c1f1a1c..092a8085747 100644 --- a/packages/app/src/cli/services/function/binaries.ts +++ b/packages/app/src/cli/services/function/binaries.ts @@ -4,16 +4,17 @@ import {outputDebug} from '@shopify/cli-kit/node/output' import {performActionWithRetryAfterRecovery} from '@shopify/cli-kit/common/retry' import {fetch} from '@shopify/cli-kit/node/http' import {PipelineSource} from 'stream' +import {pipeline} from 'stream/promises' import stream from 'node:stream/promises' import fs from 'node:fs' import * as gzip from 'node:zlib' import {fileURLToPath} from 'node:url' -const FUNCTION_RUNNER_VERSION = 'v6.4.0' +const FUNCTION_RUNNER_VERSION = 'v6.5.0' const JAVY_VERSION = 'v4.0.0' -// The Javy plugin version does not need to match the Javy version. It should -// match the plugin version used in the function-runner version specified above. -const JAVY_PLUGIN_VERSION = 'v3.2.0' +// The Javy plugin version should match the plugin version used in the +// function-runner version specified above. +const JAVY_PLUGIN_VERSION = 'v1' interface DownloadableBinary { path: string @@ -93,17 +94,22 @@ class JavyPlugin implements DownloadableBinary { readonly path: string constructor() { - this.name = 'javy_quickjs_provider_v3' + this.name = `shopify_functions_javy_${JAVY_PLUGIN_VERSION}` this.version = JAVY_PLUGIN_VERSION - this.path = joinPath(dirname(fileURLToPath(import.meta.url)), '..', 'bin', 'javy_quickjs_provider_v3.wasm') + this.path = joinPath( + dirname(fileURLToPath(import.meta.url)), + '..', + 'bin', + `shopify_functions_javy_${JAVY_PLUGIN_VERSION}.wasm`, + ) } downloadUrl(_processPlatform: string, _processArch: string) { - return `https://github.com/bytecodealliance/javy/releases/download/${this.version}/plugin.wasm.gz` + return `https://cdn.shopify.com/shopifycloud/shopify-functions-javy-plugin/shopify_functions_javy_${JAVY_PLUGIN_VERSION}.wasm` } async processResponse(responseStream: PipelineSource, outputStream: fs.WriteStream): Promise { - return gunzipResponse(responseStream, outputStream) + return pipeline(responseStream, outputStream) } }