Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Add support for WASM file format in assets in theme app extensions #3893

Closed
thosakwe opened this issue May 13, 2024 · 9 comments · Fixed by #4229
Closed

[Feature]: Add support for WASM file format in assets in theme app extensions #3893

thosakwe opened this issue May 13, 2024 · 9 comments · Fixed by #4229
Assignees
Labels
Area: @shopify/theme @shopify/theme package issues moderate lowest severity for theme related bug Type: Enhancement New feature or request

Comments

@thosakwe
Copy link

What area(s) will this request affect?

App, Extension, Function

What type of change do you want to see?

New feature

Overview

Please add .wasm to the allow list of file type extensions in theme app extensions.

Motivation

Due to Shopify/function-examples#329, I had to port my Shopify Functions to Rust.

However, my app customers heavily requested to be able to use it on the storefront as well.

Initially, I wanted to reuse my Rust code in the form of a .wasm binary in my theme app extensions (which is, in theory, the main use case of WebAssembly).

However, because theme app extensions only allow specific files to be included assets, this is impossible, so I currently have 2 separate implementations of my logic: one in Rust, and another in TypeScript.

This leads to duplicate effort when building apps on top of Shopify's latest APIs.

@blanklob
Copy link

how would you use it in the frontend?

@thosakwe
Copy link
Author

how would you use it in the frontend?

@blanklob

Great question.

The goal is client-side calculations of discounts.

My app provides various logic conditions for when discounts should apply, and I'd prefer to have 1 single implementation that can be used in multiple places.

@bkspace
Copy link

bkspace commented May 21, 2024

You can already do this, by just hosting your WASM elsewhere. I'd be quite careful whilst doing this. WASM can be compressed very well (normally up to 50%), but you'd still be looking at sticking a ~50kb file in the storefront. The better approach is sadly to re-write the logic in Javascript, IMO. There are other big issues as well.

With Discount Kit, we run the WASM as an endpoint which can then be called from the storefront. We are working on a significantly better approach which I can share in future.

@thosakwe
Copy link
Author

@bkspace Thanks for your response.

I'll probably stick with having a separate TS implementation, which gets built into the theme app extension. That way, I don't have to host it on my server.

@amcaplan
Copy link
Contributor

Hi @thosakwe, just checking you're aware that you can build functions in JavaScript/TypeScript?

@amcaplan
Copy link
Contributor

Ah, sorry, I missed the reference to the other issue. @nickwesselman is there anything to update about performance improvements? I wonder if this is just going to be a temporary issue anyway, and if JS will be sufficiently performant soon, then this will become a non-issue.

@thosakwe
Copy link
Author

Hi @thosakwe, just checking you're aware that you can build functions in JavaScript/TypeScript?

Yes, thanks for your response.

Unfortunately, JS/TS Functions aren't viable for my use case (due to Shopify/function-examples#329), which is why I ported it to Rust.

@karreiro karreiro added the moderate lowest severity for theme related bug label May 29, 2024
Copy link
Contributor

This issue seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action.
→ If there's no activity within a week, then a bot will automatically close this.
Thanks for helping to improve Shopify's dev tooling and experience.

P.S. You can learn more about why we stale issues here.

@itsjustriley
Copy link
Contributor

👋 Hi @thosakwe!

Thanks for this suggestion. We've implemented WASM file support for theme app extension assets. This change should be available in the next minor release. 🎉

(I saw you commented on the change itself, but am commenting here as well for visibility).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: @shopify/theme @shopify/theme package issues moderate lowest severity for theme related bug Type: Enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants