diff --git a/.github/workflow_scripts/get-entry-server-template-shas.js b/.github/workflow_scripts/get-entry-server-template-shas.js new file mode 100644 index 00000000000..868fcfbb6d2 --- /dev/null +++ b/.github/workflow_scripts/get-entry-server-template-shas.js @@ -0,0 +1,83 @@ +let fs = require("fs"); +let { spawnSync } = require("child_process"); +let { createHash } = require("crypto"); + +let results = {}; + +function hash(entryServerPath, commitId) { + let entryServerContents = fs.readFileSync(entryServerPath, "utf8"); + let sha = createHash("sha256").update(entryServerContents).digest("hex"); + + if (!results[sha]) { + results[sha] = { + templates: [], + commits: [], + }; + } + + if (!results[sha].templates.includes(entryServerPath)) { + results[sha].templates.push(entryServerPath); + } + if (!results[sha].commits.includes(commitId)) { + results[sha].commits.push(commitId); + } +} + +async function main() { + let r = spawnSync( + "git", + [ + "log", + '--pretty=format:"%h"', + "templates/*/app/entry.server.*", + "packages/remix-dev/config/defaults/entry.server.*", + ], + { + shell: true, + } + ); + let commitIds = r.stdout.toString("utf8").trim().split("\n"); + + for (let commitId of commitIds) { + console.log({ commitId }); + spawnSync("git", ["checkout", commitId]); + + // find templates + for (let template of fs.readdirSync("templates")) { + // skip dotfiles + if (template.startsWith(".")) continue; + + let entryServerName = fs + .readdirSync(`templates/${template}/app`) + .find((f) => f.startsWith("entry.server.")); + if (!entryServerName) { + continue; + } + + let entryServerPath = `templates/${template}/app/${entryServerName}`; + hash(entryServerPath, commitId); + } + + // find defaults + try { + for (let def of fs.readdirSync("packages/remix-dev/config/defaults")) { + if (!def.startsWith("entry.server.")) continue; + hash(`packages/remix-dev/config/defaults/${def}`, commitId); + } + } catch (err) { + // `entry.server` was required at some point, so there were no defaults + if (err.code !== "ENOENT") throw err; + } + } + + console.log(results); + fs.writeFileSync( + "entry-server-shas.json", + JSON.stringify(results, null, 2) + "\n" + ); +} + +main().catch((err) => { + console.error(err); + process.exitCode = 1; +}); diff --git a/packages/vercel-remix/entry-server-shas.json b/packages/vercel-remix/entry-server-shas.json new file mode 100644 index 00000000000..d9f6b247468 --- /dev/null +++ b/packages/vercel-remix/entry-server-shas.json @@ -0,0 +1,922 @@ +{ + "4612f0809ed40a1e1cd545a9ea2e97303a5b9e63588530c6be6e10c1487ddcd6": { + "templates": [ + "templates/arc/app/entry.server.tsx", + "templates/express/app/entry.server.tsx", + "templates/fly/app/entry.server.tsx", + "templates/remix/app/entry.server.tsx", + "templates/vite/app/entry.server.tsx", + "templates/vite-express/app/entry.server.tsx" + ], + "commits": [ + "99b3e55f1", + "f60bcf4d2", + "9d525986a", + "93b8272f1", + "095bfa00f", + "e496df07e", + "131bcca18", + "335605ec7", + "3fb419501" + ] + }, + "dbf949a245a3181036cec3ba4a1f5bfd3f5c919ac3bd6489be0c5cbbb076f423": { + "templates": [ + "templates/cloudflare-pages/app/entry.server.tsx", + "templates/cloudflare-workers/app/entry.server.tsx", + "templates/vite-cloudflare/app/entry.server.tsx" + ], + "commits": [ + "99b3e55f1", + "f60bcf4d2", + "9d525986a", + "93b8272f1", + "095bfa00f", + "e496df07e", + "131bcca18", + "335605ec7", + "3fb419501" + ] + }, + "a00db73c0d5d652468971b1ea6b05296d6d5e222705c50e2224af2833ee94d64": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "99b3e55f1", + "f60bcf4d2", + "9d525986a", + "93b8272f1", + "095bfa00f", + "e496df07e", + "335605ec7" + ] + }, + "89dfd137c78a385514cbf799b49659b7e8df7a27c329c9acf29eaf1550aa29ee": { + "templates": [ + "templates/remix-javascript/app/entry.server.jsx" + ], + "commits": [ + "99b3e55f1", + "f60bcf4d2", + "9d525986a", + "93b8272f1", + "095bfa00f", + "e496df07e", + "131bcca18", + "335605ec7", + "3fb419501" + ] + }, + "b46e9f6f56bb588a06ebdb9d3974fca4b8c2ea3c74ae832f0344b89dbd7eea35": { + "templates": [ + "templates/spa/app/entry.server.tsx" + ], + "commits": [ + "99b3e55f1", + "8ff9dcd9b", + "d7c9ea57b", + "f60bcf4d2", + "9d525986a" + ] + }, + "0be57e7fe19ac9943f2ba1834ea3876646a86482d7d1add46d6d45ef6db3bef0": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.cloudflare.tsx" + ], + "commits": [ + "99b3e55f1", + "f60bcf4d2", + "9d525986a", + "93b8272f1", + "095bfa00f", + "e496df07e", + "131bcca18" + ] + }, + "a30b28bcadbc30cd74cf6bcbe979cb6652bf94f2915a5f8cd8300fba406fe4ce": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.deno.tsx" + ], + "commits": [ + "99b3e55f1", + "f60bcf4d2", + "9d525986a", + "93b8272f1", + "095bfa00f", + "e496df07e", + "131bcca18" + ] + }, + "a05fb54d9081dcde3fdf563c6d3af09e01df25f83bed97085dde1671821d1feb": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.node.tsx" + ], + "commits": [ + "99b3e55f1", + "f60bcf4d2", + "9d525986a", + "93b8272f1", + "095bfa00f", + "e496df07e", + "131bcca18" + ] + }, + "ea3bf521afd1e670a8af60280e0429b7890b7622eb03b05113b029ac710e5015": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.spa.tsx" + ], + "commits": [ + "99b3e55f1", + "8ff9dcd9b", + "d7c9ea57b", + "f60bcf4d2", + "9d525986a" + ] + }, + "b94b9e24e8c7b566b07039bc2198c67b5096af1e49426c505be9252b85155f0a": { + "templates": [ + "templates/arc/app/entry.server.tsx", + "templates/express/app/entry.server.tsx", + "templates/fly/app/entry.server.tsx", + "templates/remix/app/entry.server.tsx", + "templates/vite/app/entry.server.tsx", + "templates/vite-express/app/entry.server.tsx" + ], + "commits": [ + "8ff9dcd9b", + "d7c9ea57b" + ] + }, + "727b5fbcf8e9965effbdc5bff0291ad9853ccc5ae9c5fe136e4103f78ff24749": { + "templates": [ + "templates/cloudflare-pages/app/entry.server.tsx", + "templates/cloudflare-workers/app/entry.server.tsx", + "templates/vite-cloudflare/app/entry.server.tsx" + ], + "commits": [ + "8ff9dcd9b", + "d7c9ea57b" + ] + }, + "bd980112251fc3a1ecbed3fa55c7320a9de547a71244c12f8b97bdc94a0a70c4": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "8ff9dcd9b" + ] + }, + "7c7cecb432d07849122eefa7ae95bb4c74ccc2b03b008eb794c53dc6e0834fbc": { + "templates": [ + "templates/remix-javascript/app/entry.server.jsx" + ], + "commits": [ + "8ff9dcd9b", + "d7c9ea57b" + ] + }, + "561ce20a531b9d2487a9730eafea0da5d80badce61a6c541cfd8a70fe6e51a4a": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.cloudflare.tsx" + ], + "commits": [ + "8ff9dcd9b", + "d7c9ea57b" + ] + }, + "f3351e43dca52cabafc456c59bf3f908123c64573aa5e14787eeb6aea2fe0f35": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.deno.tsx" + ], + "commits": [ + "8ff9dcd9b", + "d7c9ea57b" + ] + }, + "4c57160d667a46c7ff88c450abb38731f044e13ecb5565ec0d8fa825689c1660": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.node.tsx" + ], + "commits": [ + "8ff9dcd9b", + "d7c9ea57b" + ] + }, + "dd0b21da01fae5be2609ff3a3177861cf8b4b6dd903a902cdd0227d65eae361c": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "d7c9ea57b" + ] + }, + "c72cea77e934fcc310d85e69e0d615088d3e67424943f0e1f57fe879810ea7f2": { + "templates": [ + "templates/spa/app/entry.server.tsx" + ], + "commits": [ + "93b8272f1" + ] + }, + "988f5559ee25ffe6a8ddb55b14b410b4da3cf5eb91ad3c74a0113e5baae8b1a5": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.spa.tsx" + ], + "commits": [ + "93b8272f1" + ] + }, + "010f26a1ff207e79575e7f0785b4934349ba53b8df364efd67bf00a26ed3bade": { + "templates": [ + "templates/spa/app/entry.server.tsx" + ], + "commits": [ + "095bfa00f" + ] + }, + "94af995f1a9409de807a23d60d67377f871ae4b72d915465b1404f6903344483": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.spa.tsx" + ], + "commits": [ + "095bfa00f" + ] + }, + "3ac9f91bfe0ab2dc65fefc23e664444588d71f784668edf9825be74b9f9daaf9": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "131bcca18", + "3fb419501" + ] + }, + "9be583c2b74b76fda385ce8d0842c99162a526f353df4127def9ac70e684fc2e": { + "templates": [ + "templates/arc/app/entry.server.tsx", + "templates/express/app/entry.server.tsx", + "templates/fly/app/entry.server.tsx", + "templates/remix/app/entry.server.tsx" + ], + "commits": [ + "7c2291eb4", + "1a3026144", + "e8dd6456e" + ] + }, + "b17b1e8be9377cdb0ad9b633b86ddb5f7140d4accfba84a3cd93152e357e4244": { + "templates": [ + "templates/cloudflare-pages/app/entry.server.tsx", + "templates/cloudflare-workers/app/entry.server.tsx" + ], + "commits": [ + "7c2291eb4", + "1a3026144", + "e8dd6456e" + ] + }, + "754f5d2b007e08f83d88d3f6f3d10feec8c8d089ccd0852699d06dc917ff4858": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "7c2291eb4", + "1a3026144" + ] + }, + "5f500a0be5bf78a3945afdc0b2973098f958431a1fc44eff5f89aa5a714faca1": { + "templates": [ + "templates/remix-javascript/app/entry.server.jsx" + ], + "commits": [ + "7c2291eb4", + "1a3026144", + "e8dd6456e", + "1039f9837" + ] + }, + "daf4d9bcaa42ff83f30faab55288a755f4fa57f6987c9443f33ee580f165a6f8": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.cloudflare.tsx" + ], + "commits": [ + "7c2291eb4", + "1a3026144", + "e8dd6456e", + "1039f9837", + "d281439b1", + "1fdf8685c", + "da2d9fb4e" + ] + }, + "9d7a78dc5246448062cec3eac18407e5ed126254bd7d8e593cccae62e59cb8a2": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.deno.tsx" + ], + "commits": [ + "7c2291eb4", + "1a3026144", + "e8dd6456e", + "1039f9837", + "d281439b1", + "1fdf8685c", + "da2d9fb4e" + ] + }, + "e04ab497c3bab4e81fe365296783b11a55dca57fb4d71e337898b694d7100e8a": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.node.tsx" + ], + "commits": [ + "7c2291eb4", + "1a3026144", + "e8dd6456e", + "1039f9837", + "d281439b1" + ] + }, + "b9d84ab2a78aec8fb7f3631581f968ea55e2001c60c2f9e73a210bff8b6716b6": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.cloudflare.tsx" + ], + "commits": [ + "335605ec7", + "3fb419501" + ] + }, + "6aba4531f1a74ed6914fba5f69705ae200db997b6aa83db724b9bc4d3bfcbf54": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.deno.tsx" + ], + "commits": [ + "335605ec7", + "3fb419501" + ] + }, + "d123f5ff1a0c1ed0e3aa99e93b3f7c1abd43d710bdc81d7018347659e8347cc8": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.node.tsx" + ], + "commits": [ + "335605ec7", + "3fb419501" + ] + }, + "480be6180224d15adadcb880201e206e58e8f2c5547e6ac7ea7cc57170815b99": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "e8dd6456e" + ] + }, + "ed0ce43719c56582cbbe3d7c85cb86226fad004be6e43ffd487ba958a5b2b794": { + "templates": [ + "templates/arc/app/entry.server.tsx", + "templates/express/app/entry.server.tsx", + "templates/fly/app/entry.server.tsx", + "templates/remix/app/entry.server.tsx" + ], + "commits": [ + "1039f9837", + "d281439b1" + ] + }, + "955463e205b8432b0eec5cefc2fcdf2d745c80086502aea3c3e425a879f0f10e": { + "templates": [ + "templates/cloudflare-pages/app/entry.server.tsx", + "templates/cloudflare-workers/app/entry.server.tsx" + ], + "commits": [ + "1039f9837", + "d281439b1", + "1fdf8685c", + "da2d9fb4e", + "cd0ecf590", + "ca0133e5f" + ] + }, + "5a747616bef988abb64ef21a5a2a8c84eaeae25204c0b10af272c9b9e73ae559": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "1039f9837", + "d281439b1", + "1fdf8685c", + "da2d9fb4e", + "cd0ecf590", + "ca0133e5f" + ] + }, + "75b3829453af5474f02941a464f0632059d5f91dc6321209a313ce50a2ce7a74": { + "templates": [ + "templates/remix-javascript/app/entry.server.jsx" + ], + "commits": [ + "d281439b1" + ] + }, + "66689692b4bd32f12d7f6a868c7820142bc16e65e605fbdc7f9d07eb99cc51d2": { + "templates": [ + "templates/arc/app/entry.server.tsx", + "templates/express/app/entry.server.tsx", + "templates/fly/app/entry.server.tsx", + "templates/remix/app/entry.server.tsx" + ], + "commits": [ + "1fdf8685c" + ] + }, + "76fa862d5096fb5650ef8524c411e4b8c22be3765042b299e2ffba838369fb77": { + "templates": [ + "templates/remix-javascript/app/entry.server.jsx" + ], + "commits": [ + "1fdf8685c" + ] + }, + "d1cf5729a11cbc2d2c3d00121feb56308013848543d07d9d13e54aed28d8a940": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.node.tsx" + ], + "commits": [ + "1fdf8685c" + ] + }, + "2c11ca85613cf0c9fce3d89f2af73dc1437f3390c0168048196e68eb231f1930": { + "templates": [ + "templates/arc/app/entry.server.tsx", + "templates/express/app/entry.server.tsx", + "templates/fly/app/entry.server.tsx", + "templates/remix/app/entry.server.tsx", + "templates/netlify/app/entry.server.tsx", + "templates/vercel/app/entry.server.tsx" + ], + "commits": [ + "da2d9fb4e", + "cd0ecf590", + "ca0133e5f" + ] + }, + "2bcd41d6c72f00a1de527c69b64900912a346bb36b3526c776658f850646b567": { + "templates": [ + "templates/remix-javascript/app/entry.server.jsx" + ], + "commits": [ + "da2d9fb4e", + "cd0ecf590" + ] + }, + "697cc0781f4d8fe49f9a3ccd8e5db48eb478dace73c462918a8ee6b2346afcb6": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.node.tsx" + ], + "commits": [ + "da2d9fb4e" + ] + }, + "2fc402c3e812f14e5e06e9b8f9280a5f5de2ab4d63ec9ef8399f8b425239dd0c": { + "templates": [ + "templates/arc/app/entry.server.tsx", + "templates/express/app/entry.server.tsx", + "templates/fly/app/entry.server.tsx", + "templates/netlify/app/entry.server.tsx", + "templates/remix/app/entry.server.tsx", + "templates/vercel/app/entry.server.tsx" + ], + "commits": [ + "c6d8c37a8" + ] + }, + "3017c7d67a4c875a81417dcf8db408d6ae50bd9205fdb69ac4f70f47f935df18": { + "templates": [ + "templates/cloudflare-pages/app/entry.server.tsx", + "templates/cloudflare-workers/app/entry.server.tsx" + ], + "commits": [ + "c6d8c37a8" + ] + }, + "7d38ec8c88ef333ba7bd042647101b878d122d794287d099e012f0f7f6a5273b": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "c6d8c37a8" + ] + }, + "08780e2dbf3b5c24ea59d5902a9fb9beb3d80d4643c4538d07a76004add1476c": { + "templates": [ + "templates/arc/app/entry.server.tsx", + "templates/express/app/entry.server.tsx", + "templates/fly/app/entry.server.tsx", + "templates/netlify/app/entry.server.tsx", + "templates/remix/app/entry.server.tsx", + "templates/vercel/app/entry.server.tsx" + ], + "commits": [ + "1391efd1f", + "f0e4b941b" + ] + }, + "785e079e5d87af41ff3facda1f758b660b41ff2add8819461a08cdb606a8a89c": { + "templates": [ + "templates/cloudflare-pages/app/entry.server.tsx", + "templates/cloudflare-workers/app/entry.server.tsx" + ], + "commits": [ + "1391efd1f", + "f0e4b941b" + ] + }, + "1a83cccf66527044a8fbed3e3d383c6a30e8a25a1b678859a5a07491fe1e1e09": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "1391efd1f" + ] + }, + "8be971e8c104a296a551aedd7eb7ea065df5fa9064c432e63f7ca074fd466e12": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "f0e4b941b" + ] + }, + "1abc71f9338007cb2823cc3a59dc564ad5d19a30b7aa2d8b874fac1d94970ce8": { + "templates": [ + "templates/arc/app/entry.server.tsx", + "templates/express/app/entry.server.tsx", + "templates/fly/app/entry.server.tsx", + "templates/netlify/app/entry.server.tsx", + "templates/remix/app/entry.server.tsx", + "templates/vercel/app/entry.server.tsx" + ], + "commits": [ + "9a7f9e7e2" + ] + }, + "2eb0cca081b4b351d67e2ba29684b806c73d92c52adb18be3117e0cd9fd98498": { + "templates": [ + "templates/cloudflare-pages/app/entry.server.tsx", + "templates/cloudflare-workers/app/entry.server.tsx" + ], + "commits": [ + "9a7f9e7e2", + "a77c70f63", + "caf25d640" + ] + }, + "6e70b56cbe466f71a3229a5a5ec62d04ca359a86e675e513d9fd3591c315b49a": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "9a7f9e7e2", + "a77c70f63" + ] + }, + "53d64478fa0b210905c13db0749dcf67c9786dd5b043e8cb3e4c32ac6fbe0ae2": { + "templates": [ + "templates/arc/app/entry.server.tsx", + "templates/express/app/entry.server.tsx", + "templates/fly/app/entry.server.tsx", + "templates/netlify/app/entry.server.tsx", + "templates/remix/app/entry.server.tsx", + "templates/vercel/app/entry.server.tsx" + ], + "commits": [ + "a77c70f63", + "caf25d640" + ] + }, + "fff2a1fa5946a1f8314fc2213b89269f83cabf2ea72aa770fc1c2e5a142433cd": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "caf25d640" + ] + }, + "5c597ab2f9a4962192a9b2efd64fb6da2297b9ad36c566be28d82a1a6e3e932a": { + "templates": [ + "templates/arc/app/entry.server.tsx", + "templates/express/app/entry.server.tsx", + "templates/fly/app/entry.server.tsx", + "templates/netlify/app/entry.server.tsx", + "templates/remix/app/entry.server.tsx", + "templates/vercel/app/entry.server.tsx" + ], + "commits": [ + "1350cf501", + "9db87f3a1", + "7cae9c108" + ] + }, + "bd2e8856eb618719cbf2c02afeae15adc3a40dfa7e5fd2f6f7fa9d90a63c22d8": { + "templates": [ + "templates/cloudflare-pages/app/entry.server.tsx", + "templates/cloudflare-workers/app/entry.server.tsx" + ], + "commits": [ + "1350cf501", + "9db87f3a1", + "7cae9c108", + "3708e2cb0", + "3510e6f06" + ] + }, + "372c659fac2939a0f1797fb8025e76e373d4a42d47a57acf4954288ad2c0c278": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "1350cf501", + "9db87f3a1", + "3708e2cb0" + ] + }, + "4ce239330174609cf013b398bdd77df557c1b70efb030f10e6291189de461d30": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.cloudflare.tsx" + ], + "commits": [ + "9db87f3a1", + "7cae9c108", + "3708e2cb0", + "3510e6f06" + ] + }, + "836ce4232294f351d4831125ca361bc48acc7388fc5339fe5a867de2070bfa3a": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.deno.tsx" + ], + "commits": [ + "9db87f3a1", + "7cae9c108", + "3708e2cb0", + "3510e6f06" + ] + }, + "e7d08e00ef062847e4a1683010e97fab08fa026553b2715a0980ed83f1b2bafe": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.node.tsx" + ], + "commits": [ + "9db87f3a1", + "7cae9c108", + "3708e2cb0", + "3510e6f06" + ] + }, + "2ffcc3898b9cc05af64ab16b7c4033a8d403098b93f5f8bc99990cb84bd8e6c4": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "7cae9c108", + "3510e6f06" + ] + }, + "d9adb1042f6881d96e4a47d33653a33ae6aa8ace3b59dd7a8f425f865fbf9c84": { + "templates": [ + "templates/arc/app/entry.server.tsx", + "templates/express/app/entry.server.tsx", + "templates/fly/app/entry.server.tsx", + "templates/netlify/app/entry.server.tsx", + "templates/remix/app/entry.server.tsx", + "templates/vercel/app/entry.server.tsx" + ], + "commits": [ + "3708e2cb0", + "3510e6f06" + ] + }, + "10eea3a92f007026d856bd582743366aaedaee8df73bd341642dc5c833905220": { + "templates": [ + "templates/arc/app/entry.server.tsx", + "templates/netlify/app/entry.server.tsx", + "templates/vercel/app/entry.server.tsx" + ], + "commits": [ + "84efa0a18", + "ecba23c40", + "bdec5d453" + ] + }, + "def15be8e0dc0ae3fc2dc559606654555e1ece39b39efcf5908e09ccebc44a52": { + "templates": [ + "templates/cloudflare-pages/app/entry.server.tsx" + ], + "commits": [ + "84efa0a18", + "ecba23c40" + ] + }, + "b2559e82c5a3f08573375be1172948b62ba3f416545f1cb436e15f8e99175826": { + "templates": [ + "templates/cloudflare-workers/app/entry.server.tsx" + ], + "commits": [ + "84efa0a18", + "ecba23c40" + ] + }, + "2150fef0161f8852bac457285b056250ef20b54feb48f18c3081c5feb6e66f74": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "84efa0a18", + "ecba23c40" + ] + }, + "b752a6ac728cb6d8e9d54fe75ab16ba2300bd6b5132ad7ebc8c7b59e5fb33d11": { + "templates": [ + "templates/express/app/entry.server.tsx", + "templates/fly/app/entry.server.tsx", + "templates/remix/app/entry.server.tsx" + ], + "commits": [ + "84efa0a18", + "ecba23c40" + ] + }, + "899449228e69519e13029a797d87ff5b4aade8e7c7218bae07135b0c87d7b576": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.cloudflare.tsx" + ], + "commits": [ + "498887585", + "ecba23c40" + ] + }, + "907df5f781bed2bf985ee03b6de7a2ada35d681ae5668f86f04972f3270becba": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.deno.tsx" + ], + "commits": [ + "498887585", + "ecba23c40" + ] + }, + "f0971d4461d3480b19e99f9963dd45774835a3196f90b2a5267e171c95558d17": { + "templates": [ + "packages/remix-dev/config/defaults/entry.server.node.tsx" + ], + "commits": [ + "498887585", + "ecba23c40" + ] + }, + "0fe5fd297c80947f7e6b4e667a031408dc73f7f7ee2dfdec16b7c93773fdf863": { + "templates": [ + "templates/cloudflare-pages/app/entry.server.tsx", + "templates/cloudflare-workers/app/entry.server.tsx" + ], + "commits": [ + "bdec5d453", + "f4d6ff6aa" + ] + }, + "a8f648f0e58d27c4c5f52222003b03744ab5d0fc59eb45e58c97099eb4d016eb": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "bdec5d453", + "f4d6ff6aa", + "ba5c84861", + "ae120a866", + "717ddda7c" + ] + }, + "a0bab0dafea4294488eb751536dd9953e7bf388f935c00e7c7cba5184830d84b": { + "templates": [ + "templates/express/app/entry.server.tsx", + "templates/fly/app/entry.server.tsx", + "templates/remix/app/entry.server.tsx" + ], + "commits": [ + "bdec5d453" + ] + }, + "42e9cd7c7faafbac0259589250f6c58db544b6bf5f4d2776304dea2cb88a221f": { + "templates": [ + "templates/arc/app/entry.server.tsx", + "templates/netlify/app/entry.server.tsx", + "templates/vercel/app/entry.server.tsx" + ], + "commits": [ + "f4d6ff6aa", + "ba5c84861" + ] + }, + "16a4073c32879076c0df56f0673e70bbaab291cd077865c247ef52cacf80f550": { + "templates": [ + "templates/express/app/entry.server.tsx", + "templates/fly/app/entry.server.tsx", + "templates/remix/app/entry.server.tsx" + ], + "commits": [ + "f4d6ff6aa" + ] + }, + "2af11466097478255c16dd5266f89d4a36638c61375fe41649f5d4b37b7aea84": { + "templates": [ + "templates/cloudflare-pages/app/entry.server.tsx", + "templates/cloudflare-workers/app/entry.server.tsx" + ], + "commits": [ + "ba5c84861", + "ae120a866", + "717ddda7c", + "aa390501b", + "326f64209", + "d86cc1ed9" + ] + }, + "269764566f5127bcd5879aa5e06d681d3bc14b5a384dee2dc80bc87a40cd16ac": { + "templates": [ + "templates/express/app/entry.server.tsx", + "templates/fly/app/entry.server.tsx", + "templates/remix/app/entry.server.tsx", + "templates/arc/app/entry.server.tsx", + "templates/netlify/app/entry.server.tsx", + "templates/vercel/app/entry.server.tsx" + ], + "commits": [ + "ba5c84861", + "ae120a866" + ] + }, + "b2bd02cc1178a7d0133c26935295348a20d48fdf50aafacf1051b6bac22956f9": { + "templates": [ + "templates/arc/app/entry.server.tsx", + "templates/express/app/entry.server.tsx", + "templates/fly/app/entry.server.tsx", + "templates/netlify/app/entry.server.tsx", + "templates/remix/app/entry.server.tsx", + "templates/vercel/app/entry.server.tsx" + ], + "commits": [ + "717ddda7c", + "aa390501b", + "326f64209", + "d86cc1ed9" + ] + }, + "aee6d11b3a5d318af51065767bcc8c413514a6d6de16ac4385aedbfffcddae2c": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "aa390501b" + ] + }, + "f5c928c1d7923531d60027fb322896d75d2605f3575633d019449b715d3eb470": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "326f64209" + ] + }, + "763ed377c70c235d294b903d0c0052c1b6786f29ef6ed16b573506982d2e2853": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "d86cc1ed9", + "2661c7e57" + ] + }, + "65e23ea971f87e28cc4dc4cbe18e65ef2d26f56e986493a97103b725b13d1bb1": { + "templates": [ + "templates/arc/app/entry.server.tsx", + "templates/cloudflare-pages/app/entry.server.tsx", + "templates/cloudflare-workers/app/entry.server.tsx", + "templates/express/app/entry.server.tsx", + "templates/fly/app/entry.server.tsx", + "templates/netlify/app/entry.server.tsx", + "templates/remix/app/entry.server.tsx", + "templates/vercel/app/entry.server.tsx" + ], + "commits": [ + "2661c7e57", + "b9e82e949" + ] + }, + "0ba7719561d09ad9f058f7887b5b923124e40577792530d7f2941882b5fa257e": { + "templates": [ + "templates/deno/app/entry.server.tsx" + ], + "commits": [ + "b9e82e949" + ] + } +} diff --git a/packages/vercel-remix/package.json b/packages/vercel-remix/package.json index 7fdc663df2a..a580abadda3 100644 --- a/packages/vercel-remix/package.json +++ b/packages/vercel-remix/package.json @@ -51,6 +51,7 @@ "files": [ "dist/", "defaults/", + "entry-server-shas.json", "globals.js", "globals.d.ts", "server.js", diff --git a/packages/vercel-remix/vite.ts b/packages/vercel-remix/vite.ts index 693ffd89dd5..79787faf4ba 100644 --- a/packages/vercel-remix/vite.ts +++ b/packages/vercel-remix/vite.ts @@ -1,11 +1,26 @@ +import { createHash } from "crypto"; import { Project } from "ts-morph"; import { join, basename, extname } from "path"; -import { mkdirSync, writeFileSync, cpSync, rmSync, readdirSync } from "fs"; +import { + mkdirSync, + writeFileSync, + cpSync, + rmSync, + readdirSync, + readFileSync, +} from "fs"; import { getConfig, type BaseFunctionConfig } from "@vercel/static-config"; import type { Preset, VitePluginConfig } from "@remix-run/dev/vite/plugin"; import type { ConfigRoute } from "@remix-run/dev/config/routes"; -function hash(config: Record): string { +interface EntryServerShas { + [sha: string]: { + commits: string[]; + templates: string[]; + }; +} + +function hashConfig(config: Record): string { let str = JSON.stringify(config); return Buffer.from(str).toString("base64url"); } @@ -18,9 +33,26 @@ function flattenAndSort(o: Record) { return n; } +function runOnce any>(fn: T) { + let ran = false; + return (...args: Parameters) => { + if (ran) return; + ran = true; + fn(...args); + }; +} + +function getEntryServerShas(): EntryServerShas { + return JSON.parse( + readFileSync(join(__dirname, "entry-server-shas.json"), "utf8") + ); +} + export function vercelPreset(): Preset { let project = new Project(); - let entryServerPath: string | undefined; + let vercelEntryServerPath: string | undefined; + let originalEntryServerPath: string | undefined; + let originalEntryServerContents: string | undefined; let routeConfigs = new Map(); let bundleConfigs = new Map(); @@ -38,6 +70,71 @@ export function vercelPreset(): Preset { return config; } + // If there are any "edge" runtime routes, then the + // `entry.server` file needs use the `@vercel/remix` package. + // + // - If there is no `entry.server` file, then we copy in the Vercel entry server + // - If there is a `entry.server` file, then we hash the contents to + // try to determine if the file has been modified from a known default + // Remix template. + // - If there's a hash match, we can safely copy in the Vercel entry server + // - If there's no match, then we run a RegExp on the contents to see if `@vercel/remix` is being used + // - If no RegExp match, we print a warning and link to docs, but continue the build + let injectVercelEntryServer = runOnce((remixUserConfig: VitePluginConfig) => { + let appDirectory = remixUserConfig.appDirectory ?? "app"; + let entryServerFile = readdirSync(appDirectory).find( + (f) => basename(f, extname(f)) === "entry.server" + ); + if (entryServerFile) { + originalEntryServerPath = join(appDirectory, entryServerFile); + originalEntryServerContents = readFileSync( + originalEntryServerPath, + "utf8" + ); + let entryServerHash = createHash("sha256") + .update(originalEntryServerContents) + .digest("hex"); + if (Object.keys(getEntryServerShas()).includes(entryServerHash)) { + console.log(`[vc] Detected unmodified "${entryServerFile}". Copying in default "entry.server.jsx".`); + rmSync(originalEntryServerPath); + vercelEntryServerPath = join(appDirectory, "entry.server.jsx"); + cpSync( + join(__dirname, "defaults/entry.server.jsx"), + vercelEntryServerPath + ); + } else { + let usesVercelRemixPackage = /["']@vercel\/remix['"]/.test( + originalEntryServerContents + ); + if (usesVercelRemixPackage) { + console.log( + `[vc] Detected "${entryServerFile}" using \`@vercel/remix\`` + ); + } else { + console.warn( + `WARN: The \`@vercel/remix\` package was not detected in your "${entryServerFile}" file.` + ); + console.warn( + `WARN: Using the Edge Runtime may not work with your current configuration.` + ); + console.warn( + `WARN: Please see the docs to learn how to use a custom "${entryServerFile}":` + ); + console.warn( + `WARN: https://vercel.com/docs/frameworks/remix#using-a-custom-app/entry.server-file` + ); + } + } + } else { + console.log(`[vc] No "entry.server" found. Copying in default "entry.server.jsx".`); + vercelEntryServerPath = join(appDirectory, "entry.server.jsx"); + cpSync( + join(__dirname, "defaults/entry.server.jsx"), + vercelEntryServerPath + ); + } + }); + let createServerBundles = (remixUserConfig: VitePluginConfig): VitePluginConfig["serverBundles"] => ({ branch }) => { @@ -46,32 +143,12 @@ export function vercelPreset(): Preset { config.runtime = "nodejs"; } - // If there are any "edge" runtime routes, then a special - // `entry.server` needs to be used. So copy that file into - // the app directory. - if (config.runtime === "edge" && !entryServerPath) { - let appDirectory = remixUserConfig.appDirectory ?? "app"; - - // Print a warning if the project has an `entry.server` file - let entryServerFile = readdirSync(appDirectory).find( - (f) => basename(f, extname(f)) === 'entry.server' - ); - if (entryServerFile) { - console.warn( - `WARN: Vercel uses its own \`enter.server\` file, so the file "${join( - appDirectory, - entryServerFile - )}" has been deleted.` - ); - console.warn(`WARN: You should commit this change.`); - } - - entryServerPath = join(appDirectory, "entry.server.jsx"); - cpSync(join(__dirname, "defaults/entry.server.jsx"), entryServerPath); + if (config.runtime === "edge") { + injectVercelEntryServer(remixUserConfig); } config = flattenAndSort(config); - let id = `${config.runtime}-${hash(config)}`; + let id = `${config.runtime}-${hashConfig(config)}`; if (!bundleConfigs.has(id)) { bundleConfigs.set(id, config); } @@ -83,8 +160,12 @@ export function vercelPreset(): Preset { remixConfig, viteConfig }) => { - if (entryServerPath) { - rmSync(entryServerPath); + // Clean up any modifications to the `entry.server` files + if (vercelEntryServerPath) { + rmSync(vercelEntryServerPath); + if (originalEntryServerPath && originalEntryServerContents) { + writeFileSync(originalEntryServerPath, originalEntryServerContents); + } } if (buildManifest?.serverBundles && bundleConfigs.size) {