Skip to content

Commit 7a06c11

Browse files
authored
Merge pull request #289 from Shopify/expand-liquid-wasm-support
Expand liquid wasm support
2 parents 71e1b03 + 51df7a7 commit 7a06c11

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

.github/scripts/expand-liquid.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,26 @@ async function directoryNames(parentPath) {
3232

3333
async function expandExtensionLiquidTemplates(projectName, flavor) {
3434
console.log(`Expanding liquid templates for ${projectName}`);
35-
const pathSuffix =
36-
flavor === "typescript" || flavor === "vanilla-js" ? "js" : "rs";
35+
36+
let pathSuffix;
37+
switch (flavor) {
38+
case "typescript":
39+
case "vanilla-js":
40+
pathSuffix = "js";
41+
break;
42+
case "rust":
43+
pathSuffix = "rs";
44+
break;
45+
case "wasm":
46+
pathSuffix = "wasm";
47+
break;
48+
default:
49+
throw(`Unrecognized language ${flavor}.`);
50+
}
51+
3752
const projectPath = path.join(process.cwd(), projectName + "-" + pathSuffix);
38-
const langName =
39-
flavor === "typescript" || flavor === "vanilla-js" ? "javascript" : "rust";
4053

41-
if (langName === "javascript") {
54+
if (flavor === "typescript" || flavor === "vanilla-js") {
4255
await (
4356
await glob(path.join(projectPath, "src", "!(*.liquid|*.graphql)"))
4457
).forEach(async (path) => await fs.rm(path));
@@ -52,7 +65,7 @@ async function expandExtensionLiquidTemplates(projectName, flavor) {
5265

5366
await expandLiquidTemplates(projectPath, liquidData);
5467

55-
if (langName === "javascript") {
68+
if (flavor === "typescript" || flavor === "vanilla-js") {
5669
const srcFilePaths = await glob(
5770
path.join(projectPath, "src", "!(*.liquid|*.graphql)")
5871
);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Validate WASM Functions
2+
3+
on:
4+
pull_request:
5+
branches: ["main"]
6+
paths:
7+
- "functions-*-wasm/**"
8+
- ".github/workflows/validate-wasm-functions.yml"
9+
10+
env:
11+
CARGO_TERM_COLOR: always
12+
13+
jobs:
14+
checks:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v3
18+
- name: Install node dependencies
19+
run: yarn
20+
- name: Expand liquid for TypeScript functions
21+
run: CI=1 yarn expand-liquid wasm

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ yarn expand-liquid [rust|vanilla-js|typescript] <project-name-without-suffix>
1717

1818
# optionally specify only the language argument to expand all functions projects for that language
1919
yarn expand-liquid rust
20-
yarn expand-liquid vanilla-js
2120
yarn expand-liquid typescript
21+
yarn expand-liquid vanilla-js
22+
yarn expand-liquid wasm
2223
```
2324

2425
### JavaScript / TypeScript

0 commit comments

Comments
 (0)