-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
template: v2 dev #6229
template: v2 dev #6229
Conversation
Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
(cherry picked from commit 986f4b7)
…5945) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Logan McAnsh <[email protected]>
Co-authored-by: Michaël De Boey <[email protected]>
Added a notice to the jokes tutorial
Signed-off-by: Logan McAnsh <[email protected]> (cherry picked from commit 0ff5387) Signed-off-by: Logan McAnsh <[email protected]>
|
eddf6ff
to
67ac7d9
Compare
@@ -1,6 +1,5 @@ | |||
/** @type {import('@remix-run/dev').AppConfig} */ | |||
module.exports = { | |||
devServerBroadcastDelay: 1000, | |||
export default { | |||
ignoredRouteFiles: ["**/.*"], | |||
server: "./server.ts", | |||
serverConditions: ["worker"], |
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.
I think this should be ["workerd", "worker", "browser"]
:
workerd
is the new standard for Cloudflare Workers and could have slightly different code, usually optimised for edge runtimes. This is being adopted by React with a different bundle from their browser bundle.worker
should remain, because it’ll usually work and rely on less code than the browser bundle.browser
lets us fall back to browser code in packages that don’t have one of the other builds. Anecdotally, some of my code breaks without adding this condition. I’d argue this is more likely to happen than the inverse (a user imports a code that relies on browser-specific globals that Workers doesn’t have).
import * as build from "@remix-run/dev/server-build"; | ||
import manifestJSON from "__STATIC_CONTENT_MANIFEST"; |
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.
I don’t think this line will work with serverDependenciesToBundle: "all"
, unless something has changed recently. The bundler should be complaining about being unable to find this dependency. If that’s the case, the solution is to use serverDependenciesToBundle: [/^(?!(__STATIC_CONTENT_MANIFEST)$).*$/u]
, which is hacky but at least avoids the issue.
request: Request, | ||
env: { | ||
__STATIC_CONTENT: Fetcher; | ||
__STATIC_CONTENT_MANIFEST: string; |
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.
Using __STATIC_CONTENT_MANIFEST
on the environment like this is a Miniflare / Wrangler Local bug. It will break when using Wrangler in live mode or in production. You have to import it like so, and add serverDependenciesToBundle: [/^(?!(__STATIC_CONTENT_MANIFEST)$).*$/u]
to your remix.config.js
.
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.
i tried using the server.ts
from this template with the latest versions of remix and wrangler and found that it broke my static assets in production. so i tried reverting this from using env.__STATIC_CONTENT_MANIFEST
to using
import assetManifestAsString from '__STATIC_CONTENT_MANIFEST';
const assetManifest = JSON.parse(assetManifestAsString);
and passing that as ASSET_MANIFEST
to getAssetFromKV()
(as well as updating serverDependenciesToBundle
to exclude __STATIC_CONTENT_MANIFEST
), and it seemed to fix the css files that were 404ing but my /build/root-{hash}.js
and /build/manifest-{hash}.js
still 404ed in production. so i reverted server.ts
back to:
import { createEventHandler } from "@remix-run/cloudflare-workers";
import * as build from "@remix-run/dev/server-build";
addEventListener(
"fetch",
createEventHandler({ build, mode: process.env.NODE_ENV })
);
and production is fixed (but no HMR in dev, obviously).
f5ef1ac
to
3d4c05e
Compare
import * as build from "@remix-run/dev/server-build"; | ||
|
||
if (process.env.NODE_ENV === "development") { | ||
logDevReady(build); |
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.
This logs too soon for me resulting in a failed request from the browser after HMR updates because the server is not yet listening on the port when it's restarted by wrangler. By adding a setTimeout
things work fine but definitely is hacky (I'm on 100ms to be safe).
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.
Per my comment on #6415, I think this is only a problem in Wrangler v2. The appropriate fix for this should probably be to upgrade the dependency to v3.
I think this is likely a problem for the Workers template too, but I haven’t tested with Wrangler v2 on my setup.
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.
You're right, it works great without setTimeout
with Wrangler v3, so definitely recommend updating the dev dependency for the templates. Thanks!
Superceded by #6650 |
Closes: #
Testing Strategy: