Skip to content

Instantly share code, notes, and snippets.

View jacob-ebey's full-sized avatar

Jacob Ebey jacob-ebey

View GitHub Profile
{"requestedUrl":"https://shopify.vercel.store/","finalUrl":"https://shopify.vercel.store/","lighthouseVersion":"9.0.0","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/95.0.4638.69 Safari/537.36","fetchTime":"2022-01-02T09:51:04.078Z","environment":{"networkUserAgent":"Mozilla/5.0 (Linux; Android 7.0; Moto G (4)) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4695.0 Mobile Safari/537.36 Chrome-Lighthouse","hostUserAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/95.0.4638.69 Safari/537.36","benchmarkIndex":1548},"runWarnings":[],"configSettings":{"emulatedFormFactor":"mobile","formFactor":"mobile","locale":"en-US","onlyCategories":["performance","accessibility","best-practices","seo"],"channel":"lr"},"audits":{"aria-required-attr":{"id":"aria-required-attr","title":"`[role]`s have all required `[aria-*]` attributes","description":"Some ARIA roles have required attributes that describe the state of the element to
@jacob-ebey
jacob-ebey / styles.server.ts
Created January 11, 2022 19:00
Remix PostCSS Dev Resource Route
import fsp from "fs/promises";
import type { LoaderFunction } from "remix";
import postcss from "postcss";
import postcssrc from "postcss-load-config";
export let loader: LoaderFunction = async () => {
let { options, plugins } = await postcssrc();
let { css } = await postcss(plugins).process(
await fsp.readFile("styles/global.css", "utf8"),
@jacob-ebey
jacob-ebey / entry.server.tsx
Last active April 1, 2022 03:12
CF React 18 Streaming
import { renderToReadableStream } from "react-dom/server";
import { RemixServer } from "remix";
import type { EntryContext } from "remix";
import isbot from "isbot";
export default async function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext
@jacob-ebey
jacob-ebey / deferred.tsx
Created April 30, 2022 01:36
Remix deferred example
import { deferred, LoaderFunction } from "@remix-run/node";
import {
Deferred,
Link,
useDeferred,
useLoaderData,
useSearchParams,
} from "@remix-run/react";
import { getAllPokemon } from "~/pokemon";
@jacob-ebey
jacob-ebey / api.chat.ts
Created May 8, 2022 22:20
Simple Remix SSE Chat Application on new fetch polyfill
import type { LoaderFunction } from "@remix-run/node";
import type { ChatMessageEvent } from "~/events.server";
import { chatEvents } from "~/events.server";
export let loader: LoaderFunction = ({ request }) => {
if (!request.signal) {
throw new Error("No request signal provided by the platform");
}
@jacob-ebey
jacob-ebey / dynamic-import-cache-bust-loader.js
Created June 5, 2022 21:10
Node.js dynamic import cache buster
import { readFile } from "fs/promises";
import { createRequire } from "module";
import * as URL from "url";
import { readConfig } from "./config.mjs";
let require = createRequire(import.meta.url);
let config = await readConfig(process.cwd(), "development");
let outputFile = URL.pathToFileURL(config.serverBuildPath);
@jacob-ebey
jacob-ebey / inline-css-middleware.js
Created July 2, 2022 06:41
Inline CSS for Remix express applications
let fs = require("fs");
// TODO: Make it configurable based on publicPath and assetsBuildDirectory
function inlineCssMiddleware() {
/**
*
* @param {import("express").Request} req
* @param {import("express").Response} res
* @param {import("express").NextFunction} next
*/
@jacob-ebey
jacob-ebey / dashboard.pokemon.tsx
Created September 7, 2022 02:05
Remix Deferred Infinite Scrolling
import * as React from "react";
import { defer, type LoaderArgs } from "@remix-run/node";
import {
Await,
Link,
Outlet,
useLoaderData,
useLocation,
useNavigate,
useTransition,
@jacob-ebey
jacob-ebey / upstash-session-storage.ts
Last active July 15, 2023 18:52
Remix Upstash Session Storage
import { type Agent } from "https";
import {
createSessionStorage,
type RequestInit,
type SessionData,
type SessionIdStorageStrategy,
} from "@remix-run/node";
export interface UpstashSessionStorageOptions {
cookie?: SessionIdStorageStrategy["cookie"];
@jacob-ebey
jacob-ebey / example.test.ts
Created October 9, 2022 05:26
Run tests in a browser web-worker using puppeteer
import invariant from "tiny-invariant";
export function thisTestShouldFail() {
invariant(false, "update this test 🙂");
}