diff --git a/.changeset/nasty-carrots-juggle.md b/.changeset/nasty-carrots-juggle.md new file mode 100644 index 0000000000..a1b6e97b51 --- /dev/null +++ b/.changeset/nasty-carrots-juggle.md @@ -0,0 +1,7 @@ +--- +'@shopify/hydrogen': patch +'@shopify/cli-hydrogen': patch +--- + +1. Update Remix to 1.14.0 +1. Add `Cache-Control` defaults to all the demo store routes diff --git a/package-lock.json b/package-lock.json index 4b43ca4f9d..74ae0c9d39 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4316,8 +4316,9 @@ "license": "0BSD" }, "node_modules/@remix-run/dev": { - "version": "1.12.0", - "license": "MIT", + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/@remix-run/dev/-/dev-1.14.0.tgz", + "integrity": "sha512-EG9kG/rGSRucer+g5PJQ8lSMLtJNVVCpxVMzHOciGPRXjPK3pg5acOuOksJGvdiqgFX9UO5itielQZ81ZBy6jA==", "dependencies": { "@babel/core": "^7.18.6", "@babel/generator": "^7.18.6", @@ -4330,7 +4331,7 @@ "@babel/types": "^7.20.2", "@esbuild-plugins/node-modules-polyfill": "^0.1.4", "@npmcli/package-json": "^2.0.0", - "@remix-run/server-runtime": "1.12.0", + "@remix-run/server-runtime": "1.14.0", "@vanilla-extract/integration": "^6.0.2", "arg": "^5.0.1", "cacache": "^15.0.5", @@ -4356,10 +4357,12 @@ "ora": "^5.4.1", "postcss": "^8.4.19", "postcss-discard-duplicates": "^5.1.0", + "postcss-load-config": "^4.0.1", "postcss-modules": "^6.0.0", "prettier": "2.7.1", "pretty-ms": "^7.0.1", "proxy-agent": "^5.0.0", + "react-refresh": "^0.14.0", "recast": "^0.21.5", "remark-frontmatter": "4.0.1", "remark-mdx-frontmatter": "^1.0.1", @@ -4377,7 +4380,7 @@ "node": ">=14" }, "peerDependencies": { - "@remix-run/serve": "^1.12.0" + "@remix-run/serve": "^1.14.0" }, "peerDependenciesMeta": { "@remix-run/serve": { @@ -4517,9 +4520,10 @@ } }, "node_modules/@remix-run/eslint-config": { - "version": "1.12.0", + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/@remix-run/eslint-config/-/eslint-config-1.14.0.tgz", + "integrity": "sha512-Q4IcYRuLmDEvgovbzsqftx/FPkJHgle24e6L331RsXt7CRHHFQ1DxHBscSac20O0hW5s4smQl/gjfx42VjMvRA==", "dev": true, - "license": "MIT", "dependencies": { "@babel/core": "^7.19.1", "@babel/eslint-parser": "^7.19.1", @@ -4553,11 +4557,12 @@ } }, "node_modules/@remix-run/react": { - "version": "1.12.0", - "license": "MIT", + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/@remix-run/react/-/react-1.14.0.tgz", + "integrity": "sha512-zwir/r49WKST7afHBVCSeB7FtMiZXkRYaBBZld49WmUJcheo3BrXGiZRtSCLtBWqe1eSI5jbOoe6K4EHJ8etEA==", "dependencies": { - "@remix-run/router": "1.3.1", - "react-router-dom": "6.8.0", + "@remix-run/router": "1.3.3", + "react-router-dom": "6.8.2", "use-sync-external-store": "1.2.0" }, "engines": { @@ -4569,17 +4574,19 @@ } }, "node_modules/@remix-run/router": { - "version": "1.3.1", - "license": "MIT", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.3.3.tgz", + "integrity": "sha512-YRHie1yQEj0kqqCTCJEfHqYSSNlZQ696QJG+MMiW4mxSl9I0ojz/eRhJS4fs88Z5i6D1SmoF9d3K99/QOhI8/w==", "engines": { "node": ">=14" } }, "node_modules/@remix-run/server-runtime": { - "version": "1.12.0", - "license": "MIT", + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/@remix-run/server-runtime/-/server-runtime-1.14.0.tgz", + "integrity": "sha512-qkqfT7DDwVzLICtJxMGthIU4T7DVtLy+oxKAzOi9eiCFlr3aWqV30YJ5Kq6r/kP8tighlnHbj1uEo41+WbD8uA==", "dependencies": { - "@remix-run/router": "1.3.1", + "@remix-run/router": "1.3.3", "@types/cookie": "^0.4.0", "@types/react": "^18.0.15", "@web3-storage/multipart-parser": "^1.0.0", @@ -6072,7 +6079,8 @@ }, "node_modules/@types/cookie": { "version": "0.4.1", - "license": "MIT" + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==" }, "node_modules/@types/debug": { "version": "4.1.7", @@ -6906,7 +6914,8 @@ }, "node_modules/@web3-storage/multipart-parser": { "version": "1.0.0", - "license": "(Apache-2.0 AND MIT)" + "resolved": "https://registry.npmjs.org/@web3-storage/multipart-parser/-/multipart-parser-1.0.0.tgz", + "integrity": "sha512-BEO6al7BYqcnfX15W2cnGR+Q566ACXAT9UQykORCWW80lmkpWsnEob6zJS1ZVBKsSJC8+7vJkHwlp+lXG1UCdw==" }, "node_modules/@xobotyi/scrollbar-width": { "version": "1.9.5", @@ -8734,7 +8743,8 @@ }, "node_modules/cookie": { "version": "0.4.2", - "license": "MIT", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==", "engines": { "node": ">= 0.6" } @@ -13465,7 +13475,6 @@ }, "node_modules/lilconfig": { "version": "2.0.6", - "dev": true, "license": "MIT", "engines": { "node": ">=10" @@ -17264,7 +17273,6 @@ }, "node_modules/postcss-load-config": { "version": "4.0.1", - "dev": true, "license": "MIT", "dependencies": { "lilconfig": "^2.0.5", @@ -18042,11 +18050,20 @@ "dev": true, "license": "MIT" }, + "node_modules/react-refresh": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.14.0.tgz", + "integrity": "sha512-wViHqhAd8OHeLS/IRMJjTSDHF3U9eWi62F/MledQGPdJGDhodXJ9PBLNGr6WWL7qlH12Mt3TyTpbS+hGXMjCzQ==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/react-router": { - "version": "6.8.0", - "license": "MIT", + "version": "6.8.2", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.8.2.tgz", + "integrity": "sha512-lF7S0UmXI5Pd8bmHvMdPKI4u4S5McxmHnzJhrYi9ZQ6wE+DA8JN5BzVC5EEBuduWWDaiJ8u6YhVOCmThBli+rw==", "dependencies": { - "@remix-run/router": "1.3.1" + "@remix-run/router": "1.3.3" }, "engines": { "node": ">=14" @@ -18056,11 +18073,12 @@ } }, "node_modules/react-router-dom": { - "version": "6.8.0", - "license": "MIT", + "version": "6.8.2", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.8.2.tgz", + "integrity": "sha512-N/oAF1Shd7g4tWy+75IIufCGsHBqT74tnzHQhbiUTYILYF0Blk65cg+HPZqwC+6SqEyx033nKqU7by38v3lBZg==", "dependencies": { - "@remix-run/router": "1.3.1", - "react-router": "6.8.0" + "@remix-run/router": "1.3.3", + "react-router": "6.8.2" }, "engines": { "node": ">=14" @@ -22015,7 +22033,6 @@ }, "node_modules/yaml": { "version": "2.1.1", - "dev": true, "license": "ISC", "engines": { "node": ">= 14" @@ -22774,7 +22791,7 @@ "license": "SEE LICENSE IN LICENSE.md", "dependencies": { "@oclif/core": "^1.20.4", - "@remix-run/dev": "^1.12.0", + "@remix-run/dev": "^1.14.0", "@shopify/cli-kit": "3.29.0", "@shopify/mini-oxygen": "^1.3.1", "fast-glob": "^3.2.12", @@ -22802,7 +22819,7 @@ "node": ">=16.13" }, "peerDependencies": { - "@remix-run/react": "^1.12.0", + "@remix-run/react": "^1.14.0", "@shopify/hydrogen-react": "^2023.1.5", "@shopify/remix-oxygen": "^1.0.3" } @@ -22873,8 +22890,8 @@ "vitest": "^0.27.2" }, "peerDependencies": { - "@remix-run/react": "1.12.0", - "@remix-run/server-runtime": "1.12.0" + "@remix-run/react": "1.14.0", + "@remix-run/server-runtime": "1.14.0" } }, "packages/hydrogen/node_modules/acorn-walk": { @@ -22981,7 +22998,7 @@ "version": "1.0.3", "license": "SEE LICENSE IN LICENSE.md", "dependencies": { - "@remix-run/server-runtime": "1.12.0" + "@remix-run/server-runtime": "1.14.0" }, "devDependencies": { "@shopify/oxygen-workers-types": "^3.17.2" @@ -22994,7 +23011,7 @@ "version": "0.0.0", "dependencies": { "@headlessui/react": "^1.7.2", - "@remix-run/react": "1.12.0", + "@remix-run/react": "1.14.0", "@shopify/cli": "3.29.0", "@shopify/cli-hydrogen": "^4.0.8", "@shopify/hydrogen": "^2023.1.5", @@ -23014,8 +23031,8 @@ "typographic-base": "^1.0.4" }, "devDependencies": { - "@remix-run/dev": "1.12.0", - "@remix-run/eslint-config": "1.12.0", + "@remix-run/dev": "1.14.0", + "@remix-run/eslint-config": "1.14.0", "@shopify/eslint-plugin": "^42.0.1", "@shopify/oxygen-workers-types": "^3.17.2", "@shopify/prettier-config": "^1.1.2", @@ -23044,7 +23061,7 @@ "templates/hello-world": { "version": "0.0.0", "dependencies": { - "@remix-run/react": "1.12.0", + "@remix-run/react": "1.14.0", "@shopify/cli": "3.29.0", "@shopify/cli-hydrogen": "^4.0.8", "@shopify/hydrogen": "^2023.1.5", @@ -23055,7 +23072,7 @@ "react-dom": "^18.2.0" }, "devDependencies": { - "@remix-run/dev": "1.12.0", + "@remix-run/dev": "1.14.0", "@shopify/oxygen-workers-types": "^3.17.2", "@shopify/prettier-config": "^1.1.2", "@types/eslint": "^8.4.10", @@ -23073,7 +23090,7 @@ "templates/skeleton": { "version": "0.0.0", "dependencies": { - "@remix-run/react": "1.12.0", + "@remix-run/react": "1.14.0", "@shopify/cli": "3.29.0", "@shopify/cli-hydrogen": "^4.0.8", "@shopify/hydrogen": "^2023.1.5", @@ -23084,7 +23101,7 @@ "react-dom": "^18.2.0" }, "devDependencies": { - "@remix-run/dev": "1.12.0", + "@remix-run/dev": "1.14.0", "@shopify/oxygen-workers-types": "^3.17.2", "@shopify/prettier-config": "^1.1.2", "@types/eslint": "^8.4.10", @@ -25977,7 +25994,9 @@ } }, "@remix-run/dev": { - "version": "1.12.0", + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/@remix-run/dev/-/dev-1.14.0.tgz", + "integrity": "sha512-EG9kG/rGSRucer+g5PJQ8lSMLtJNVVCpxVMzHOciGPRXjPK3pg5acOuOksJGvdiqgFX9UO5itielQZ81ZBy6jA==", "requires": { "@babel/core": "^7.18.6", "@babel/generator": "^7.18.6", @@ -25990,7 +26009,7 @@ "@babel/types": "^7.20.2", "@esbuild-plugins/node-modules-polyfill": "^0.1.4", "@npmcli/package-json": "^2.0.0", - "@remix-run/server-runtime": "1.12.0", + "@remix-run/server-runtime": "1.14.0", "@vanilla-extract/integration": "^6.0.2", "arg": "^5.0.1", "cacache": "^15.0.5", @@ -26016,10 +26035,12 @@ "ora": "^5.4.1", "postcss": "^8.4.19", "postcss-discard-duplicates": "^5.1.0", + "postcss-load-config": "^4.0.1", "postcss-modules": "^6.0.0", "prettier": "2.7.1", "pretty-ms": "^7.0.1", "proxy-agent": "^5.0.0", + "react-refresh": "^0.14.0", "recast": "^0.21.5", "remark-frontmatter": "4.0.1", "remark-mdx-frontmatter": "^1.0.1", @@ -26107,7 +26128,9 @@ } }, "@remix-run/eslint-config": { - "version": "1.12.0", + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/@remix-run/eslint-config/-/eslint-config-1.14.0.tgz", + "integrity": "sha512-Q4IcYRuLmDEvgovbzsqftx/FPkJHgle24e6L331RsXt7CRHHFQ1DxHBscSac20O0hW5s4smQl/gjfx42VjMvRA==", "dev": true, "requires": { "@babel/core": "^7.19.1", @@ -26129,20 +26152,26 @@ } }, "@remix-run/react": { - "version": "1.12.0", + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/@remix-run/react/-/react-1.14.0.tgz", + "integrity": "sha512-zwir/r49WKST7afHBVCSeB7FtMiZXkRYaBBZld49WmUJcheo3BrXGiZRtSCLtBWqe1eSI5jbOoe6K4EHJ8etEA==", "requires": { - "@remix-run/router": "1.3.1", - "react-router-dom": "6.8.0", + "@remix-run/router": "1.3.3", + "react-router-dom": "6.8.2", "use-sync-external-store": "1.2.0" } }, "@remix-run/router": { - "version": "1.3.1" + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.3.3.tgz", + "integrity": "sha512-YRHie1yQEj0kqqCTCJEfHqYSSNlZQ696QJG+MMiW4mxSl9I0ojz/eRhJS4fs88Z5i6D1SmoF9d3K99/QOhI8/w==" }, "@remix-run/server-runtime": { - "version": "1.12.0", + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/@remix-run/server-runtime/-/server-runtime-1.14.0.tgz", + "integrity": "sha512-qkqfT7DDwVzLICtJxMGthIU4T7DVtLy+oxKAzOi9eiCFlr3aWqV30YJ5Kq6r/kP8tighlnHbj1uEo41+WbD8uA==", "requires": { - "@remix-run/router": "1.3.1", + "@remix-run/router": "1.3.3", "@types/cookie": "^0.4.0", "@types/react": "^18.0.15", "@web3-storage/multipart-parser": "^1.0.0", @@ -26278,7 +26307,7 @@ "version": "file:packages/cli", "requires": { "@oclif/core": "^1.20.4", - "@remix-run/dev": "^1.12.0", + "@remix-run/dev": "^1.14.0", "@shopify/cli-kit": "3.29.0", "@shopify/mini-oxygen": "^1.3.1", "@types/fs-extra": "^9.0.13", @@ -27122,7 +27151,7 @@ "@shopify/remix-oxygen": { "version": "file:packages/remix-oxygen", "requires": { - "@remix-run/server-runtime": "1.12.0", + "@remix-run/server-runtime": "1.14.0", "@shopify/oxygen-workers-types": "^3.17.2" } }, @@ -27253,7 +27282,9 @@ } }, "@types/cookie": { - "version": "0.4.1" + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz", + "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q==" }, "@types/debug": { "version": "4.1.7", @@ -27813,7 +27844,9 @@ } }, "@web3-storage/multipart-parser": { - "version": "1.0.0" + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@web3-storage/multipart-parser/-/multipart-parser-1.0.0.tgz", + "integrity": "sha512-BEO6al7BYqcnfX15W2cnGR+Q566ACXAT9UQykORCWW80lmkpWsnEob6zJS1ZVBKsSJC8+7vJkHwlp+lXG1UCdw==" }, "@xobotyi/scrollbar-width": { "version": "1.9.5" @@ -28957,7 +28990,9 @@ "version": "1.0.2" }, "cookie": { - "version": "0.4.2" + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz", + "integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==" }, "cookie-es": { "version": "0.5.0" @@ -29347,9 +29382,9 @@ "version": "file:templates/demo-store", "requires": { "@headlessui/react": "^1.7.2", - "@remix-run/dev": "1.12.0", - "@remix-run/eslint-config": "1.12.0", - "@remix-run/react": "1.12.0", + "@remix-run/dev": "1.14.0", + "@remix-run/eslint-config": "1.14.0", + "@remix-run/react": "1.14.0", "@shopify/cli": "3.29.0", "@shopify/cli-hydrogen": "^4.0.8", "@shopify/eslint-plugin": "^42.0.1", @@ -31213,8 +31248,8 @@ "hello-world": { "version": "file:templates/hello-world", "requires": { - "@remix-run/dev": "1.12.0", - "@remix-run/react": "1.12.0", + "@remix-run/dev": "1.14.0", + "@remix-run/react": "1.14.0", "@shopify/cli": "3.29.0", "@shopify/cli-hydrogen": "^4.0.8", "@shopify/hydrogen": "^2023.1.5", @@ -31957,8 +31992,7 @@ } }, "lilconfig": { - "version": "2.0.6", - "dev": true + "version": "2.0.6" }, "lines-and-columns": { "version": "1.2.4" @@ -34275,7 +34309,6 @@ }, "postcss-load-config": { "version": "4.0.1", - "dev": true, "requires": { "lilconfig": "^2.0.5", "yaml": "^2.1.1" @@ -34722,17 +34755,26 @@ "version": "17.0.2", "dev": true }, + "react-refresh": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.14.0.tgz", + "integrity": "sha512-wViHqhAd8OHeLS/IRMJjTSDHF3U9eWi62F/MledQGPdJGDhodXJ9PBLNGr6WWL7qlH12Mt3TyTpbS+hGXMjCzQ==" + }, "react-router": { - "version": "6.8.0", + "version": "6.8.2", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.8.2.tgz", + "integrity": "sha512-lF7S0UmXI5Pd8bmHvMdPKI4u4S5McxmHnzJhrYi9ZQ6wE+DA8JN5BzVC5EEBuduWWDaiJ8u6YhVOCmThBli+rw==", "requires": { - "@remix-run/router": "1.3.1" + "@remix-run/router": "1.3.3" } }, "react-router-dom": { - "version": "6.8.0", + "version": "6.8.2", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.8.2.tgz", + "integrity": "sha512-N/oAF1Shd7g4tWy+75IIufCGsHBqT74tnzHQhbiUTYILYF0Blk65cg+HPZqwC+6SqEyx033nKqU7by38v3lBZg==", "requires": { - "@remix-run/router": "1.3.1", - "react-router": "6.8.0" + "@remix-run/router": "1.3.3", + "react-router": "6.8.2" } }, "react-universal-interface": { @@ -35421,8 +35463,8 @@ "skeleton": { "version": "file:templates/skeleton", "requires": { - "@remix-run/dev": "1.12.0", - "@remix-run/react": "1.12.0", + "@remix-run/dev": "1.14.0", + "@remix-run/react": "1.14.0", "@shopify/cli": "3.29.0", "@shopify/cli-hydrogen": "^4.0.8", "@shopify/hydrogen": "^2023.1.5", @@ -37252,8 +37294,7 @@ "version": "4.0.0" }, "yaml": { - "version": "2.1.1", - "dev": true + "version": "2.1.1" }, "yargs": { "version": "17.5.1", diff --git a/packages/cli/package.json b/packages/cli/package.json index 81c95078b6..862205102e 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -26,13 +26,13 @@ "tempy": "^3.0.0" }, "peerDependencies": { - "@remix-run/react": "^1.12.0", + "@remix-run/react": "^1.14.0", "@shopify/hydrogen-react": "^2023.1.5", "@shopify/remix-oxygen": "^1.0.3" }, "dependencies": { "@oclif/core": "^1.20.4", - "@remix-run/dev": "^1.12.0", + "@remix-run/dev": "^1.14.0", "@shopify/cli-kit": "3.29.0", "@shopify/mini-oxygen": "^1.3.1", "fast-glob": "^3.2.12", diff --git a/packages/hydrogen/package.json b/packages/hydrogen/package.json index 68a3733a2b..dab5f1eabd 100644 --- a/packages/hydrogen/package.json +++ b/packages/hydrogen/package.json @@ -55,8 +55,8 @@ "@shopify/hydrogen-react": "2023.1.5" }, "peerDependencies": { - "@remix-run/react": "1.12.0", - "@remix-run/server-runtime": "1.12.0" + "@remix-run/react": "1.14.0", + "@remix-run/server-runtime": "1.14.0" }, "devDependencies": { "happy-dom": "^8.9.0", diff --git a/packages/remix-oxygen/package.json b/packages/remix-oxygen/package.json index f0841a1cc5..529feb152c 100644 --- a/packages/remix-oxygen/package.json +++ b/packages/remix-oxygen/package.json @@ -40,7 +40,7 @@ "dist" ], "dependencies": { - "@remix-run/server-runtime": "1.12.0" + "@remix-run/server-runtime": "1.14.0" }, "devDependencies": { "@shopify/oxygen-workers-types": "^3.17.2" diff --git a/templates/demo-store/app/data/cache.ts b/templates/demo-store/app/data/cache.ts new file mode 100644 index 0000000000..8025d3bd49 --- /dev/null +++ b/templates/demo-store/app/data/cache.ts @@ -0,0 +1,18 @@ +import { + CacheLong, + CacheNone, + CacheShort, + generateCacheControlHeader, +} from '@shopify/hydrogen'; + +export function routeHeaders({loaderHeaders}: {loaderHeaders: Headers}) { + // Keep the same cache-control headers when loading the page directly + // versus when transititioning to the page from other areas in the app + return { + 'Cache-Control': loaderHeaders.get('Cache-Control'), + }; +} + +export const CACHE_SHORT = generateCacheControlHeader(CacheShort()); +export const CACHE_LONG = generateCacheControlHeader(CacheLong()); +export const CACHE_NONE = generateCacheControlHeader(CacheNone()); diff --git a/templates/demo-store/app/routes/($lang)/account.tsx b/templates/demo-store/app/routes/($lang)/account.tsx index 6841075bf0..6eb70fed9a 100644 --- a/templates/demo-store/app/routes/($lang)/account.tsx +++ b/templates/demo-store/app/routes/($lang)/account.tsx @@ -35,11 +35,14 @@ import {flattenConnection} from '@shopify/hydrogen'; import {getFeaturedData} from './featured-products'; import {doLogout} from './account/__private/logout'; import {usePrefixPathWithLocale} from '~/lib/utils'; +import {CACHE_NONE, routeHeaders} from '~/data/cache'; // Combining json + Response + defer in a loader breaks the // types returned by useLoaderData. This is a temporary fix. type TmpRemixFix = ReturnType>; +export const headers = routeHeaders; + export async function loader({request, context, params}: LoaderArgs) { const {pathname} = new URL(request.url); const lang = params.lang; @@ -65,14 +68,21 @@ export async function loader({request, context, params}: LoaderArgs) { const orders = flattenConnection(customer.orders) as Order[]; - return defer({ - isAuthenticated, - customer, - heading, - orders, - addresses: flattenConnection(customer.addresses) as MailingAddress[], - featuredData: getFeaturedData(context.storefront), - }); + return defer( + { + isAuthenticated, + customer, + heading, + orders, + addresses: flattenConnection(customer.addresses) as MailingAddress[], + featuredData: getFeaturedData(context.storefront), + }, + { + headers: { + 'Cache-Control': CACHE_NONE, + }, + }, + ); } export default function Authenticated() { diff --git a/templates/demo-store/app/routes/($lang)/api/countries.tsx b/templates/demo-store/app/routes/($lang)/api/countries.tsx index e13931921c..e786b600d0 100644 --- a/templates/demo-store/app/routes/($lang)/api/countries.tsx +++ b/templates/demo-store/app/routes/($lang)/api/countries.tsx @@ -1,16 +1,15 @@ -import {json, type LoaderArgs} from '@shopify/remix-oxygen'; +import {json} from '@shopify/remix-oxygen'; +import {CACHE_LONG} from '~/data/cache'; import {countries} from '~/data/countries'; -export async function loader({context: {storefront}}: LoaderArgs) { +export async function loader() { return json( { ...countries, }, { headers: { - 'cache-control': storefront.generateCacheControlHeader( - storefront.CacheLong(), - ), + 'cache-control': CACHE_LONG, }, }, ); diff --git a/templates/demo-store/app/routes/($lang)/collections/$collectionHandle.tsx b/templates/demo-store/app/routes/($lang)/collections/$collectionHandle.tsx index 873cfb72e3..ad965b194c 100644 --- a/templates/demo-store/app/routes/($lang)/collections/$collectionHandle.tsx +++ b/templates/demo-store/app/routes/($lang)/collections/$collectionHandle.tsx @@ -14,6 +14,7 @@ import invariant from 'tiny-invariant'; import {PageHeader, Section, Text, SortFilter} from '~/components'; import {ProductGrid} from '~/components/ProductGrid'; import {PRODUCT_CARD_FRAGMENT} from '~/data/fragments'; +import {CACHE_SHORT, routeHeaders} from '~/data/cache'; const seo: SeoHandleFunction = ({data}) => ({ title: data?.collection?.seo?.title, @@ -32,6 +33,8 @@ export const handle = { seo, }; +export const headers = routeHeaders; + const PAGINATION_SIZE = 48; type VariantFilterParam = Record; @@ -142,16 +145,23 @@ export async function loader({params, request, context}: LoaderArgs) { const collectionNodes = flattenConnection(collections); - return json({ - collection, - appliedFilters, - collections: collectionNodes, - analytics: { - pageType: AnalyticsPageType.collection, - collectionHandle, - resourceId: collection.id, + return json( + { + collection, + appliedFilters, + collections: collectionNodes, + analytics: { + pageType: AnalyticsPageType.collection, + collectionHandle, + resourceId: collection.id, + }, }, - }); + { + headers: { + 'Cache-Control': CACHE_SHORT, + }, + }, + ); } export default function Collection() { diff --git a/templates/demo-store/app/routes/($lang)/collections/index.tsx b/templates/demo-store/app/routes/($lang)/collections/index.tsx index 9598e71310..2f5a660d41 100644 --- a/templates/demo-store/app/routes/($lang)/collections/index.tsx +++ b/templates/demo-store/app/routes/($lang)/collections/index.tsx @@ -15,6 +15,7 @@ import { Button, } from '~/components'; import {getImageLoadingPriority} from '~/lib/const'; +import {CACHE_SHORT, routeHeaders} from '~/data/cache'; const PAGINATION_SIZE = 8; @@ -24,6 +25,8 @@ export const handle = { }, }; +export const headers = routeHeaders; + export const loader = async ({request, context: {storefront}}: LoaderArgs) => { const variables = getPaginationVariables(request, PAGINATION_SIZE); const {collections} = await storefront.query<{ @@ -36,7 +39,14 @@ export const loader = async ({request, context: {storefront}}: LoaderArgs) => { }, }); - return json({collections}); + return json( + {collections}, + { + headers: { + 'Cache-Control': CACHE_SHORT, + }, + }, + ); }; export const meta: MetaFunction = () => { diff --git a/templates/demo-store/app/routes/($lang)/index.tsx b/templates/demo-store/app/routes/($lang)/index.tsx index ce8530cea5..6be7af549a 100644 --- a/templates/demo-store/app/routes/($lang)/index.tsx +++ b/templates/demo-store/app/routes/($lang)/index.tsx @@ -10,6 +10,7 @@ import type { ProductConnection, } from '@shopify/hydrogen/storefront-api-types'; import {AnalyticsPageType} from '@shopify/hydrogen'; +import {routeHeaders, CACHE_SHORT} from '~/data/cache'; interface HomeSeoData { shop: { @@ -30,6 +31,8 @@ export interface CollectionHero { top?: boolean; } +export const headers = routeHeaders; + export async function loader({params, context}: LoaderArgs) { const {language, country} = context.storefront.i18n; @@ -49,56 +52,63 @@ export async function loader({params, context}: LoaderArgs) { variables: {handle: 'freestyle'}, }); - return defer({ - shop, - primaryHero: hero, - // These different queries are separated to illustrate how 3rd party content - // fetching can be optimized for both above and below the fold. - featuredProducts: context.storefront.query<{ - products: ProductConnection; - }>(HOMEPAGE_FEATURED_PRODUCTS_QUERY, { - variables: { - /** - * Country and language properties are automatically injected - * into all queries. Passing them is unnecessary unless you - * want to override them from the following default: - */ - country, - language, - }, - }), - secondaryHero: context.storefront.query<{hero: CollectionHero}>( - COLLECTION_HERO_QUERY, - { + return defer( + { + shop, + primaryHero: hero, + // These different queries are separated to illustrate how 3rd party content + // fetching can be optimized for both above and below the fold. + featuredProducts: context.storefront.query<{ + products: ProductConnection; + }>(HOMEPAGE_FEATURED_PRODUCTS_QUERY, { variables: { - handle: 'backcountry', + /** + * Country and language properties are automatically injected + * into all queries. Passing them is unnecessary unless you + * want to override them from the following default: + */ country, language, }, - }, - ), - featuredCollections: context.storefront.query<{ - collections: CollectionConnection; - }>(FEATURED_COLLECTIONS_QUERY, { - variables: { - country, - language, - }, - }), - tertiaryHero: context.storefront.query<{hero: CollectionHero}>( - COLLECTION_HERO_QUERY, - { + }), + secondaryHero: context.storefront.query<{hero: CollectionHero}>( + COLLECTION_HERO_QUERY, + { + variables: { + handle: 'backcountry', + country, + language, + }, + }, + ), + featuredCollections: context.storefront.query<{ + collections: CollectionConnection; + }>(FEATURED_COLLECTIONS_QUERY, { variables: { - handle: 'winter-2022', country, language, }, + }), + tertiaryHero: context.storefront.query<{hero: CollectionHero}>( + COLLECTION_HERO_QUERY, + { + variables: { + handle: 'winter-2022', + country, + language, + }, + }, + ), + analytics: { + pageType: AnalyticsPageType.home, }, - ), - analytics: { - pageType: AnalyticsPageType.home, }, - }); + { + headers: { + 'Cache-Control': CACHE_SHORT, + }, + }, + ); } export default function Homepage() { diff --git a/templates/demo-store/app/routes/($lang)/journal/$journalHandle.tsx b/templates/demo-store/app/routes/($lang)/journal/$journalHandle.tsx index e2fe28dfdc..6b14338a59 100644 --- a/templates/demo-store/app/routes/($lang)/journal/$journalHandle.tsx +++ b/templates/demo-store/app/routes/($lang)/journal/$journalHandle.tsx @@ -13,6 +13,7 @@ import {PageHeader, Section} from '~/components'; import {ATTR_LOADING_EAGER} from '~/lib/const'; import styles from '../../../styles/custom-font.css'; import type {SeoHandleFunction} from '@shopify/hydrogen'; +import {routeHeaders, CACHE_LONG} from '~/data/cache'; const BLOG_HANDLE = 'journal'; @@ -26,6 +27,8 @@ export const handle = { seo, }; +export const headers = routeHeaders; + export async function loader({params, context}: LoaderArgs) { const {language, country} = context.storefront.i18n; @@ -57,7 +60,7 @@ export async function loader({params, context}: LoaderArgs) { {article, formattedDate}, { headers: { - // TODO cacheLong() + 'Cache-Control': CACHE_LONG, }, }, ); diff --git a/templates/demo-store/app/routes/($lang)/journal/index.tsx b/templates/demo-store/app/routes/($lang)/journal/index.tsx index f054ebba07..26b168fab7 100644 --- a/templates/demo-store/app/routes/($lang)/journal/index.tsx +++ b/templates/demo-store/app/routes/($lang)/journal/index.tsx @@ -4,6 +4,7 @@ import {flattenConnection, Image} from '@shopify/hydrogen'; import type {Article, Blog} from '@shopify/hydrogen/storefront-api-types'; import {Grid, PageHeader, Section, Link} from '~/components'; import {getImageLoadingPriority, PAGINATION_SIZE} from '~/lib/const'; +import {CACHE_SHORT, routeHeaders} from '~/data/cache'; const BLOG_HANDLE = 'Journal'; @@ -13,6 +14,8 @@ export const handle = { }, }; +export const headers = routeHeaders; + export const loader = async ({context: {storefront}}: LoaderArgs) => { const {language, country} = storefront.i18n; const {blog} = await storefront.query<{ @@ -45,7 +48,7 @@ export const loader = async ({context: {storefront}}: LoaderArgs) => { {articles}, { headers: { - // TODO cacheLong() + 'Cache-Control': CACHE_SHORT, }, }, ); diff --git a/templates/demo-store/app/routes/($lang)/pages/$pageHandle.tsx b/templates/demo-store/app/routes/($lang)/pages/$pageHandle.tsx index ec8bdca8e0..9de1d99486 100644 --- a/templates/demo-store/app/routes/($lang)/pages/$pageHandle.tsx +++ b/templates/demo-store/app/routes/($lang)/pages/$pageHandle.tsx @@ -9,12 +9,15 @@ import {useLoaderData} from '@remix-run/react'; import invariant from 'tiny-invariant'; import {PageHeader} from '~/components'; import type {SeoHandleFunction} from '@shopify/hydrogen'; +import {CACHE_LONG, routeHeaders} from '~/data/cache'; const seo: SeoHandleFunction = ({data}) => ({ title: data?.page?.seo?.title, description: data?.page?.seo?.description, }); +export const headers = routeHeaders; + export const handle = { seo, }; @@ -37,7 +40,7 @@ export async function loader({request, params, context}: LoaderArgs) { {page}, { headers: { - // TODO cacheLong() + 'Cache-Control': CACHE_LONG, }, }, ); diff --git a/templates/demo-store/app/routes/($lang)/policies/$policyHandle.tsx b/templates/demo-store/app/routes/($lang)/policies/$policyHandle.tsx index adf7eba648..9b37c87fb3 100644 --- a/templates/demo-store/app/routes/($lang)/policies/$policyHandle.tsx +++ b/templates/demo-store/app/routes/($lang)/policies/$policyHandle.tsx @@ -4,6 +4,9 @@ import {useLoaderData} from '@remix-run/react'; import {PageHeader, Section, Button} from '~/components'; import invariant from 'tiny-invariant'; import {ShopPolicy} from '@shopify/hydrogen/storefront-api-types'; +import {routeHeaders, CACHE_LONG} from '~/data/cache'; + +export const headers = routeHeaders; export async function loader({request, params, context}: LoaderArgs) { invariant(params.policyHandle, 'Missing policy handle'); @@ -37,7 +40,7 @@ export async function loader({request, params, context}: LoaderArgs) { {policy}, { headers: { - // TODO cacheLong() + 'Cache-Control': CACHE_LONG, }, }, ); diff --git a/templates/demo-store/app/routes/($lang)/policies/index.tsx b/templates/demo-store/app/routes/($lang)/policies/index.tsx index 4db719ce0d..01a4c9cac5 100644 --- a/templates/demo-store/app/routes/($lang)/policies/index.tsx +++ b/templates/demo-store/app/routes/($lang)/policies/index.tsx @@ -4,6 +4,7 @@ import type {ShopPolicy} from '@shopify/hydrogen/storefront-api-types'; import invariant from 'tiny-invariant'; import {PageHeader, Section, Heading, Link} from '~/components'; +import {routeHeaders, CACHE_LONG} from '~/data/cache'; export const handle = { seo: { @@ -11,6 +12,8 @@ export const handle = { }, }; +export const headers = routeHeaders; + export async function loader({context: {storefront}}: LoaderArgs) { const data = await storefront.query<{ shop: Record; @@ -29,7 +32,7 @@ export async function loader({context: {storefront}}: LoaderArgs) { }, { headers: { - // TODO cacheLong() + 'Cache-Control': CACHE_LONG, }, }, ); diff --git a/templates/demo-store/app/routes/($lang)/products/$productHandle.tsx b/templates/demo-store/app/routes/($lang)/products/$productHandle.tsx index 84ae2cec75..277d02d1df 100644 --- a/templates/demo-store/app/routes/($lang)/products/$productHandle.tsx +++ b/templates/demo-store/app/routes/($lang)/products/$productHandle.tsx @@ -46,6 +46,9 @@ import type { import {MEDIA_FRAGMENT, PRODUCT_CARD_FRAGMENT} from '~/data/fragments'; import type {Storefront} from '~/lib/type'; import type {Product} from 'schema-dts'; +import {routeHeaders, CACHE_SHORT} from '~/data/cache'; + +export const headers = routeHeaders; export async function loader({params, request, context}: LoaderArgs) { const {productHandle} = params; @@ -103,18 +106,25 @@ export async function loader({params, request, context}: LoaderArgs) { }, } satisfies SeoConfig; - return defer({ - product, - shop, - recommended, - seo, - analytics: { - pageType: AnalyticsPageType.product, - resourceId: product.id, - products: [productAnalytics], - totalValue: parseFloat(selectedVariant.price.amount), + return defer( + { + product, + shop, + recommended, + seo, + analytics: { + pageType: AnalyticsPageType.product, + resourceId: product.id, + products: [productAnalytics], + totalValue: parseFloat(selectedVariant.price.amount), + }, }, - }); + { + headers: { + 'Cache-Control': CACHE_SHORT, + }, + }, + ); } export default function Product() { diff --git a/templates/demo-store/app/routes/($lang)/products/index.tsx b/templates/demo-store/app/routes/($lang)/products/index.tsx index 89efb00bbf..b8096e8815 100644 --- a/templates/demo-store/app/routes/($lang)/products/index.tsx +++ b/templates/demo-store/app/routes/($lang)/products/index.tsx @@ -1,4 +1,4 @@ -import {type LoaderArgs} from '@shopify/remix-oxygen'; +import {json, type LoaderArgs} from '@shopify/remix-oxygen'; import {useLoaderData} from '@remix-run/react'; import type {ProductConnection} from '@shopify/hydrogen/storefront-api-types'; import invariant from 'tiny-invariant'; @@ -13,9 +13,12 @@ import { } from '~/components'; import {PRODUCT_CARD_FRAGMENT} from '~/data/fragments'; import {getImageLoadingPriority} from '~/lib/const'; +import {routeHeaders, CACHE_SHORT} from '~/data/cache'; const PAGE_BY = 8; +export const headers = routeHeaders; + export async function loader({request, context: {storefront}}: LoaderArgs) { const variables = getPaginationVariables(request, PAGE_BY); @@ -31,7 +34,11 @@ export async function loader({request, context: {storefront}}: LoaderArgs) { invariant(data, 'No data returned from Shopify API'); - return data.products; + return json(data.products, { + headers: { + 'Cache-Control': CACHE_SHORT, + }, + }); } export const handle = { diff --git a/templates/demo-store/package.json b/templates/demo-store/package.json index f6359d766c..b1aee4486e 100644 --- a/templates/demo-store/package.json +++ b/templates/demo-store/package.json @@ -16,7 +16,7 @@ "prettier": "@shopify/prettier-config", "dependencies": { "@headlessui/react": "^1.7.2", - "@remix-run/react": "1.12.0", + "@remix-run/react": "1.14.0", "@shopify/cli": "3.29.0", "@shopify/cli-hydrogen": "^4.0.8", "@shopify/hydrogen": "^2023.1.5", @@ -36,8 +36,8 @@ "typographic-base": "^1.0.4" }, "devDependencies": { - "@remix-run/dev": "1.12.0", - "@remix-run/eslint-config": "1.12.0", + "@remix-run/dev": "1.14.0", + "@remix-run/eslint-config": "1.14.0", "@shopify/eslint-plugin": "^42.0.1", "@shopify/oxygen-workers-types": "^3.17.2", "@shopify/prettier-config": "^1.1.2", diff --git a/templates/hello-world/package.json b/templates/hello-world/package.json index 92ddecf8f7..7f8246aad2 100644 --- a/templates/hello-world/package.json +++ b/templates/hello-world/package.json @@ -13,7 +13,7 @@ }, "prettier": "@shopify/prettier-config", "dependencies": { - "@remix-run/react": "1.12.0", + "@remix-run/react": "1.14.0", "@shopify/cli": "3.29.0", "@shopify/cli-hydrogen": "^4.0.8", "@shopify/hydrogen": "^2023.1.5", @@ -24,7 +24,7 @@ "react-dom": "^18.2.0" }, "devDependencies": { - "@remix-run/dev": "1.12.0", + "@remix-run/dev": "1.14.0", "@shopify/oxygen-workers-types": "^3.17.2", "@shopify/prettier-config": "^1.1.2", "@types/eslint": "^8.4.10", diff --git a/templates/skeleton/package.json b/templates/skeleton/package.json index decf73a201..e9485c4a5c 100644 --- a/templates/skeleton/package.json +++ b/templates/skeleton/package.json @@ -12,7 +12,7 @@ }, "prettier": "@shopify/prettier-config", "dependencies": { - "@remix-run/react": "1.12.0", + "@remix-run/react": "1.14.0", "@shopify/cli": "3.29.0", "@shopify/cli-hydrogen": "^4.0.8", "@shopify/hydrogen": "^2023.1.5", @@ -23,7 +23,7 @@ "react-dom": "^18.2.0" }, "devDependencies": { - "@remix-run/dev": "1.12.0", + "@remix-run/dev": "1.14.0", "@shopify/oxygen-workers-types": "^3.17.2", "@shopify/prettier-config": "^1.1.2", "@types/eslint": "^8.4.10",