-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
chore(templates): integrate v2_dev #6650
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9554cfe
chore(templates/arc): integrate v2_dev
jacob-ebey e13d5aa
chore(templates/cloudflare-pages): integrate v2_dev
jacob-ebey 4fd3019
chore(templates/cloudflare-workers): integrate v2_dev
jacob-ebey 77fb01b
chore(templates/express): integrate v2_dev
jacob-ebey c11879f
chore(templates/fly): integrate v2_dev
pcattori 13dbf45
chore(templates/netlify): integrate v2_dev
pcattori 9977bd7
chore(templates/remix): integrate v2_dev
pcattori e5ea9f5
chore(templates/vercel): integrate v2_dev
pcattori 2faa8c2
fix(templates/arc): restart arc when rebuilds occur
pcattori File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// This should eventually be a npm package, but for now it lives here. | ||
// It's job is to notify the remix dev server of the version of the running | ||
// app to trigger HMR / HDR. | ||
|
||
import * as fs from "node:fs"; | ||
import * as path from "node:path"; | ||
import { logDevReady } from "@remix-run/node"; | ||
|
||
const buildPath = "server/index.mjs"; | ||
|
||
let lastTimeout; | ||
|
||
export default { | ||
sandbox: { | ||
async watcher() { | ||
if (lastTimeout) { | ||
clearTimeout(lastTimeout); | ||
} | ||
|
||
lastTimeout = setTimeout(async () => { | ||
const contents = fs.readFileSync( | ||
path.resolve(process.cwd(), buildPath), | ||
"utf8" | ||
); | ||
const manifestMatches = contents.matchAll(/manifest-([A-f0-9]+)\.js/g); | ||
const sent = new Set(); | ||
for (const match of manifestMatches) { | ||
const buildHash = match[1]; | ||
if (!sent.has(buildHash)) { | ||
sent.add(buildHash); | ||
logDevReady({ assets: { version: buildHash } }); | ||
} | ||
} | ||
}, 300); | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
@aws | ||
runtime nodejs14.x | ||
runtime nodejs16.x | ||
# memory 1152 | ||
# timeout 30 | ||
# concurrency 1 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.DS_Store | ||
node_modules | ||
|
||
/.cache | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
/favicon.ico | ||
Cache-Control: public, max-age=3600, s-maxage=3600 | ||
/build/* | ||
Cache-Control: public, max-age=31536000, immutable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": 1, | ||
"include": ["/*"], | ||
"exclude": ["/build/*"] | ||
"exclude": ["/favicon.ico", "/build/*"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
import { logDevReady } from "@remix-run/cloudflare"; | ||
import { createPagesFunctionHandler } from "@remix-run/cloudflare-pages"; | ||
import * as build from "@remix-run/dev/server-build"; | ||
|
||
if (process.env.NODE_ENV === "development") { | ||
logDevReady(build); | ||
} | ||
|
||
export const onRequest = createPagesFunctionHandler({ | ||
build, | ||
getLoadContext: (context) => context.env, | ||
getLoadContext: (context) => ({ env: context.env }), | ||
mode: process.env.NODE_ENV, | ||
}); |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.DS_Store | ||
node_modules | ||
|
||
/.cache | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
/// <reference types="@remix-run/dev" /> | ||
/// <reference types="@remix-run/cloudflare" /> | ||
/// <reference types="@cloudflare/workers-types" /> | ||
|
||
declare module "__STATIC_CONTENT_MANIFEST" { | ||
const manifest: string; | ||
export default manifest; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,53 @@ | ||
import { createEventHandler } from "@remix-run/cloudflare-workers"; | ||
import { getAssetFromKV } from "@cloudflare/kv-asset-handler"; | ||
import type { AppLoadContext } from "@remix-run/cloudflare"; | ||
import { createRequestHandler, logDevReady } from "@remix-run/cloudflare"; | ||
import * as build from "@remix-run/dev/server-build"; | ||
import __STATIC_CONTENT_MANIFEST from "__STATIC_CONTENT_MANIFEST"; | ||
|
||
addEventListener( | ||
"fetch", | ||
createEventHandler({ build, mode: process.env.NODE_ENV }) | ||
); | ||
const MANIFEST = JSON.parse(__STATIC_CONTENT_MANIFEST); | ||
const handleRemixRequest = createRequestHandler(build, process.env.NODE_ENV); | ||
|
||
if (build.dev) { | ||
logDevReady(build); | ||
} | ||
|
||
export default { | ||
async fetch( | ||
request: Request, | ||
env: { | ||
__STATIC_CONTENT: Fetcher; | ||
}, | ||
ctx: ExecutionContext | ||
): Promise<Response> { | ||
try { | ||
const url = new URL(request.url); | ||
const ttl = url.pathname.startsWith("/build/") | ||
? 60 * 60 * 24 * 365 // 1 year | ||
: 60 * 5; // 5 minutes | ||
return await getAssetFromKV( | ||
{ | ||
request, | ||
waitUntil: ctx.waitUntil.bind(ctx), | ||
} as FetchEvent, | ||
{ | ||
ASSET_NAMESPACE: env.__STATIC_CONTENT, | ||
ASSET_MANIFEST: MANIFEST, | ||
cacheControl: { | ||
browserTTL: ttl, | ||
edgeTTL: ttl, | ||
}, | ||
} | ||
); | ||
} catch (error) {} | ||
|
||
try { | ||
const loadContext: AppLoadContext = { | ||
env, | ||
}; | ||
return await handleRemixRequest(request, loadContext); | ||
} catch (error) { | ||
console.log(error); | ||
return new Response("An unexpected error occurred", { status: 500 }); | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment I left on the last one—IMHO this should be
["workerd", "worker", "browser"]