grunge-stack
grunge-stack copied to clipboard
Type error on initial validate of the stack
Have you experienced this bug with the latest version of the template?
yes
Steps to Reproduce
❯ npx create-remix --template remix-run/grunge-stack
either select the validate option -- or -- ❯ npm run validate
server.ts:9:3 - error TS2739: Type 'typeof import("/Users/jtushman/code/remix-playground/notes/node_modules/@remix-run/dev/server-build")' is missing the following properties from type 'ServerBuild': publicPath, assetsBuildDirectory
9 build,
~~~~~
node_modules/@remix-run/architect/dist/server.d.ts:18:5
18 build: ServerBuild;
~~~~~
The expected type comes from property 'build' which is declared here on type '{ build: ServerBuild; getLoadContext?: GetLoadContextFunction | undefined; mode?: string | undefined; }'
Expected Behavior
I'd expect the initial clean pull to validate
Actual Behavior
we are getting a type error
note when I look at the dev branch of remix I see the interface fullfilled:
https://github.com/remix-run/remix/blob/dev/packages/remix-dev/server-build.ts
/* eslint-disable no-unreachable */
import type { ServerBuild } from "@remix-run/server-runtime";
throw new Error(
"@remix-run/dev/server-build is not meant to be used directly from node_modules." +
" It exists to provide type definitions for a virtual module provided" +
" by the Remix compiler at build time."
);
export const assets: ServerBuild["assets"] = undefined!;
export const entry: ServerBuild["entry"] = undefined!;
export const routes: ServerBuild["routes"] = undefined!;
export const publicPath: ServerBuild["publicPath"] = undefined!;
// prettier-ignore
export const assetsBuildDirectory: ServerBuild["assetsBuildDirectory"] = undefined!;
think this was the PR that caused it:
https://github.com/remix-run/remix/commit/3951fbf0ddf671331d5176590e4d05bb9f70c0a3
cc @mcansh
think this was the PR that caused it:
https://github.com/remix-run/remix/commit/3951fbf0ddf671331d5176590e4d05bb9f70c0a3
cc @mcansh
that PR actually fixed it, but hasn't been released to stable yet, you can try out the nightly
tag in the interim as noted here https://github.com/remix-run/grunge-stack/issues/85#issuecomment-1185558428
this is the one that initially caused the build error with bundled servers https://github.com/remix-run/remix/pull/3349
gotcha -- thx ( should I close this? )
we can keep this one open until a new (stable) remix release is out
Is there any fix? I am still getting the error.
This fixed the error for me:
import { createRequestHandler } from "@remix-run/architect";
import * as build from "@remix-run/dev/server-build";
import type { ServerBuild } from "@remix-run/server-runtime/dist/build";
if (process.env.NODE_ENV !== "production") {
require("./mocks");
}
export const handler = createRequestHandler({
build: build as ServerBuild,
mode: process.env.NODE_ENV,
});
sorry for the delay folks! a stable release for this should be going out today or tomorrow, in the meantime you can upgrade to the nightly channel or do what @peterpostmann posted or use // @ts-expect-error
and when you upgrade typescript will throw when that's no longer broken