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

Adding JavaScript functions to sample apps #169

Merged
merged 19 commits into from
Apr 10, 2023
Merged

Conversation

nickwesselman
Copy link
Contributor

@nickwesselman nickwesselman commented Mar 1, 2023

Existing sample apps can add JavaScript functions in this PR. It should not be merged until JavaScript functions are generally available.

  • Vanilla JavaScript functions should be added side-by-side with existing Rust functions to all sample apps.
  • The function logic should be the same in JS as it is in Rust.
  • Vitest should be used to exhibit unit testing.
  • Test cases should be the same in JS as they are in Rust.

🎩

  • Execution of JS functions requires the checkout extensibility developer preview.

Payment Customization

yarn create @shopify/app --template https://github.com/Shopify/function-examples/sample-apps/payment-customizations#sample-apps-javascript

Delivery Customization

yarn create @shopify/app --template https://github.com/Shopify/function-examples/sample-apps/delivery-customizations#sample-apps-javascript

Discounts

yarn create @shopify/app --template https://github.com/Shopify/function-examples/sample-apps/discounts#sample-apps-javascript

Copy link
Contributor

@andrewhassan andrewhassan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why did we choose to have a JS example and not a TS example instead?

@@ -0,0 +1,1741 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these two yarn.lock files be committed? It looks like we already have package-lock.json files. We should choose one or the other depending on the tooling we recommend (e.g. yarn or npm).

Copy link
Contributor Author

@nickwesselman nickwesselman Mar 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we had standardized on yarn in this repo, but looks like we have a mix. In our docs, we don't recommend a particular package manager. But the CLI team internally has moved from yarn to pnpm.

@nickwesselman
Copy link
Contributor Author

Out of curiosity, why did we choose to have a JS example and not a TS example instead?

@andrewhassan Our docs, and thus the sample, are going to focus on JS based on consistency with UI extensions, and survey feedback (Vanilla JS edging out TS). Thought about doing both but it would add maintenance overhead for minor benefit.

@RaVbaker RaVbaker self-requested a review April 6, 2023 08:08
@nickwesselman nickwesselman marked this pull request as ready for review April 7, 2023 17:28
@nickwesselman
Copy link
Contributor Author

@adampetro Looks like this is failing now due to Rust checks being done on a JavaScript extension, is that something that was added in the JS unit test PR?

@adampetro
Copy link
Contributor

@adampetro Looks like this is failing now due to Rust checks being done on a JavaScript extension, is that something that was added in the JS unit test PR?

Most likely this line. I think we can get around it by using exclude in the root Cargo.toml.

* move vitest and test script to the extension itself
* ensure sample tests run with workspace tests
@nickwesselman
Copy link
Contributor Author

@adampetro Thanks! Unfortunately they can't be globbed due to this but that fixed it.

Also added the JS sample extensions to the workspace so those tests run now too. Awesome work setting up all the test automation.

Copy link
Contributor

@adampetro adampetro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! If you have time it would be nice to add a newline at the end of files that don't have one

Added missing newlines
@nickwesselman nickwesselman merged commit 9b38425 into main Apr 10, 2023
@nickwesselman nickwesselman deleted the sample-apps-javascript branch April 10, 2023 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants