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/seven-seahorses-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/app': minor
---

Use Shopify Functions Javy plugin instead of default Javy plugin for building JS Shopify Functions
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ packaging/dist
cloudflared*
function-runner*
javy*
shopify_functions_javy_v*.wasm

# Vitest vscode extension autogenerated files
index.d.ts
Expand Down
10 changes: 6 additions & 4 deletions packages/app/src/cli/services/function/binaries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,19 @@ 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', () => {
// When
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 () => {
Expand Down
22 changes: 14 additions & 8 deletions packages/app/src/cli/services/function/binaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<unknown>, outputStream: fs.WriteStream): Promise<void> {
return gunzipResponse(responseStream, outputStream)
return pipeline(responseStream, outputStream)
}
}

Expand Down