Skip to content

Commit 93963ef

Browse files
committed
chore: bring in line with latest arc template
1 parent af4c898 commit 93963ef

15 files changed

+95
-28
lines changed

.env.example

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
NODE_ENV="development"
21
SESSION_SECRET="super-duper-s3cret"

.eslintrc.js .eslintrc.cjs

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ module.exports = {
1111
"cypress/globals": true,
1212
},
1313
plugins: ["cypress"],
14-
// we're using vitest which has a very similar API to jest
15-
// (so the linting plugins work nicely), but it we have to explicitly
16-
// set the jest version.
14+
// We're using vitest which has a very similar API to jest
15+
// (so the linting plugins work nicely), but it means we
16+
// have to set the jest version explicitly.
1717
settings: {
1818
jest: {
1919
version: 28,

.eslintrc.repo.js .eslintrc.repo.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const WARN = 1;
66
/** @type {import('eslint').Linter.Config} */
77
module.exports = {
88
extends: [
9-
"./.eslintrc.js",
9+
"./.eslintrc.cjs",
1010
"@remix-run/eslint-config/internal",
1111
"plugin:markdown/recommended",
1212
],

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ pnpm-lock.yml
88
node_modules
99

1010
/public/build
11+
/server/index.mjs
12+
/server/index.mjs.map
13+
/server/metafile.*
1114
preferences.arc
1215
sam.json
1316
sam.yaml

app.arc

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
@app
22
grunge-stack-template
33

4-
# @aws
5-
# region us-east-2
4+
@aws
5+
runtime nodejs16.x
6+
# concurrency 1
7+
# memory 1152
68
# profile default
9+
# region us-west-1
10+
# timeout 30
711

812
@http
913
/*
1014
method any
1115
src server
1216

17+
@plugins
18+
plugin-remix
19+
src plugin-remix.js
20+
1321
@static
1422

1523
@tables

app/root.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import stylesheet from "~/tailwind.css";
1616
export const links: LinksFunction = () => [
1717
{ rel: "stylesheet", href: stylesheet },
1818
...(cssBundleHref ? [{ rel: "stylesheet", href: cssBundleHref }] : []),
19-
// NOTE: Architect deploys the public directory to /_static/
20-
{ rel: "icon", href: "/_static/favicon.ico" },
2119
];
2220

2321
export const loader = async ({ request }: LoaderArgs) => {
@@ -30,6 +28,7 @@ export default function App() {
3028
<head>
3129
<meta charSet="utf-8" />
3230
<meta name="viewport" content="width=device-width,initial-scale=1" />
31+
<link rel="icon" href="/_static/favicon.ico" />
3332
<Meta />
3433
<Links />
3534
</head>
File renamed without changes.

mocks/index.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1-
const { setupServer } = require("msw/node");
1+
import { rest } from "msw";
2+
import { setupServer } from "msw/node";
23

3-
const server = setupServer();
4+
// put one-off handlers that don't really need an entire file to themselves here
5+
const miscHandlers = [
6+
rest.post(`${process.env.REMIX_DEV_HTTP_ORIGIN}/ping`, (req) =>
7+
req.passthrough(),
8+
),
9+
];
10+
11+
const server = setupServer(...miscHandlers);
412

513
server.listen({ onUnhandledRequest: "bypass" });
614

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
"name": "grunge-stack-template",
33
"private": true,
44
"sideEffects": false,
5+
"type": "module",
56
"scripts": {
67
"build": "remix build",
78
"dev": "remix dev --manual -c \"arc sandbox -e testing\"",
89
"format": "prettier --write .",
910
"format:repo": "npm run format && npm run lint:repo -- --fix",
1011
"lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .",
11-
"lint:repo": "npm run lint -- --config ./.eslintrc.repo.js",
12+
"lint:repo": "npm run lint -- --config ./.eslintrc.repo.cjs",
13+
"start": "cross-env NODE_ENV=production arc sandbox",
1214
"test": "vitest",
1315
"test:e2e:dev": "start-server-and-test dev http://localhost:3000 \"npx cypress open\"",
1416
"test:e2e:run": "cross-env PORT=8811 start-server-and-test dev http://localhost:8811 \"npx cypress run\"",
@@ -75,6 +77,6 @@
7577
"vitest": "^0.34.2"
7678
},
7779
"engines": {
78-
"node": ">=14"
80+
"node": ">=14.0.0"
7981
}
8082
}

plugin-remix.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// This should eventually be a npm package, but for now it lives here.
2+
// Its job is to notify the remix dev server of the version of the running
3+
// app to trigger HMR / HDR.
4+
5+
import * as fs from "node:fs";
6+
import * as path from "node:path";
7+
8+
import { logDevReady } from "@remix-run/node";
9+
10+
const buildPath = "server/index.mjs";
11+
12+
let lastTimeout;
13+
14+
export default {
15+
sandbox: {
16+
async watcher() {
17+
if (lastTimeout) {
18+
clearTimeout(lastTimeout);
19+
}
20+
21+
lastTimeout = setTimeout(async () => {
22+
const contents = fs.readFileSync(
23+
path.resolve(process.cwd(), buildPath),
24+
"utf8"
25+
);
26+
const manifestMatches = contents.matchAll(/manifest-([A-f0-9]+)\.js/g);
27+
const sent = new Set();
28+
for (const match of manifestMatches) {
29+
const buildHash = match[1];
30+
if (!sent.has(buildHash)) {
31+
sent.add(buildHash);
32+
logDevReady({ assets: { version: buildHash } });
33+
}
34+
}
35+
}, 300);
36+
},
37+
},
38+
set: {
39+
env() {
40+
// Pass matching env variables through to the application in dev mode.
41+
const passthruKeys = /^NODE_ENV$|^REMIX_DEV_/;
42+
return {
43+
testing: Object.fromEntries(
44+
Object.entries(process.env).filter(([key]) => passthruKeys.test(key))
45+
),
46+
};
47+
},
48+
},
49+
};
File renamed without changes.

remix.config.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const path = require("path");
1+
import path from "node:path";
22

33
/** @type {import('@remix-run/dev').AppConfig} */
4-
module.exports = {
4+
export default {
55
cacheDirectory: "./node_modules/.cache/remix",
66
future: {
77
v2_dev: true,
@@ -14,22 +14,21 @@ module.exports = {
1414
ignoredRouteFiles: ["**/.*", "**/*.test.{js,jsx,ts,tsx}"],
1515
publicPath: "/_static/build/",
1616
postcss: true,
17-
server: "./server.ts",
18-
serverBuildPath: "server/index.js",
19-
serverModuleFormat: "cjs",
17+
server: "server.ts",
18+
serverBuildPath: "server/index.mjs",
19+
serverModuleFormat: "esm",
2020
tailwind: true,
21-
routes(defineRoutes) {
22-
return defineRoutes((route) => {
21+
routes: (defineRoutes) =>
22+
defineRoutes((route) => {
2323
if (process.env.NODE_ENV === "production") return;
2424

2525
console.log("⚠️ Test routes enabled.");
2626

27-
const appDir = path.join(__dirname, "app");
27+
const appDir = path.join(process.cwd(), "app");
2828

2929
route(
3030
"__tests/create-user",
3131
path.relative(appDir, "cypress/support/test-routes/create-user.ts"),
3232
);
33-
});
34-
},
33+
}),
3534
};

remix.init/gitignore

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
node_modules
22

3-
/server/index.js
4-
/server/index.js.map
5-
/server/metafile.*
63
/public/build
4+
/server/index.mjs
5+
/server/index.mjs.map
6+
/server/metafile.*
77
preferences.arc
88
sam.json
99
sam.yaml

remix.init/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ const main = async ({ isTypeScript, packageManager, rootDirectory }) => {
201201
fs.rm(path.join(rootDirectory, ".github", "workflows", "no-response.yml")),
202202
fs.rm(path.join(rootDirectory, ".github", "dependabot.yml")),
203203
fs.rm(path.join(rootDirectory, ".github", "PULL_REQUEST_TEMPLATE.md")),
204-
fs.rm(path.join(rootDirectory, ".eslintrc.repo.js")),
204+
fs.rm(path.join(rootDirectory, ".eslintrc.repo.cjs")),
205205
fs.rm(path.join(rootDirectory, "LICENSE.md")),
206206
];
207207

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"isolatedModules": true,
88
"esModuleInterop": true,
99
"jsx": "react-jsx",
10-
"module": "CommonJS",
10+
"module": "ES2020",
1111
"moduleResolution": "node",
1212
"resolveJsonModule": true,
1313
"target": "ES2019",

0 commit comments

Comments
 (0)