`remix setup node` breaks jest when using pnpm
Closed this issue · 2 comments
esamattis commented
Using Jest v27.5.1, babel-jest and pnpm v6.27.0.
What version of Remix are you using?
1.2.2
Steps to Reproduce
This works when using npm but not when using pnpm.
git clone https://github.com/esamattis/remix-jest-bug.git
cd remix-jest-bug
pnpm install
This is otherwise standard npx create-remix@latest
project but I've disabled the default post install script (remix setup node
) so I can demonstrate the issue.
pnpm run jest
works now but if you run
pnpm run setup-remix # remix setup node
Jest breaks with:
❯ pnpm run jest
> jest
/Users/esamatti1/tmp/remix-jest-bug/node_modules/.pnpm/@babel+types@7.17.0/node_modules/@babel/types/lib/ast-types/generated/index.js:1
export { createFileSessionStorage, unstable_createFileUploadHandler, unstable_createMemoryUploadHandler, unstable_parseMultipartFormData } from "@remix-run/node";
^^^^^^
SyntaxError: Unexpected token 'export'
If I look at the @babel/types
package it indeed has remix exports now 😮
❯ head -n 5 /Users/esamatti1/tmp/remix-jest-bug/node_modules/.pnpm/@babel+types@7.17.0/node_modules/@babel/types/lib/ast-types/generated/index.js
export { createFileSessionStorage, unstable_createFileUploadHandler, unstable_createMemoryUploadHandler, unstable_parseMultipartFormData } from "@remix-run/node";
export type { UploadHandler, UploadHandlerArgs } from "@remix-run/node";
export type { ServerBuild, ServerEntryModule, HandleDataRequestFunction, HandleDocumentRequestFunction, CookieParseOptions, CookieSerializeOptions, CookieSignatureOptions, CookieOptions, Cookie, AppLoadContext, AppData, EntryContext, LinkDescriptor, HtmlLinkDescriptor, PageLinkDescriptor, ErrorBoundaryComponent, ActionFunction, HeadersFunction, LinksFunction, LoaderFunction, MetaDescriptor, HtmlMetaDescriptor, MetaFunction, RouteComponent, RouteHandle, RequestHandler, SessionData, Session, SessionStorage, SessionIdStorageStrategy } from "@remix-run/server-runtime";
export { createCookie, isCookie, createSession, isSession, createSessionStorage, createCookieSessionStorage, createMemorySessionStorage, json, redirect } from "@remix-run/server-runtime";
Expected Behavior
jest should work after remix setup node
Actual Behavior
remix setup node
injects remix exports to @babel/types
package breaking jest.
esamattis commented
Oh, thanks for the heads up!