Skip to content

Commit

Permalink
chore(rsc): Remove client.ts and clean-up outdated tests (#11527)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobbe authored and Josh-Walker-GM committed Sep 11, 2024
1 parent 559a630 commit 893fc5a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ describe('page auto loader correctly imports pages', () => {
})

test('RSC specific code should not be added', () => {
expect(result?.code).not.toContain(
'import { renderFromRscServer } from "@redwoodjs/vite/client"',
)
expect(result?.code).not.toContain('DummyComponent')
expect(result?.code).not.toContain('= () => {}')
})
})
173 changes: 0 additions & 173 deletions packages/vite/src/client.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ describe('rscRoutesAutoLoader', () => {
)

// What we are interested in seeing here is:
// - The import of `renderFromRscServer` from `@redwoodjs/vite/client`
// - The call to `renderFromRscServer` for each page that wasn't already imported
// - Creation of `const EmptyUserNewEmptyUserPage = () => null;` etc for each page
// - The import of `dummyComponent` from `@redwoodjs/router/dist/dummyComponent`
expect(output).toMatchInlineSnapshot(`
"const EmptyUserNewEmptyUserPage = () => null;
const EmptyUserEmptyUsersPage = () => null;
Expand Down Expand Up @@ -364,9 +364,8 @@ describe('rscRoutesAutoLoader', () => {
undefined,
)

// We don't have to add calls for the AboutPage as it was already imported
expect(output).not.toContain('renderFromDist("AboutPage")')
expect(output).not.toContain('renderFromRscServer("AboutPage")')
// We should't create a stub component for the AboutPage as it was already imported
expect(output).not.toContain('const AboutPage = () => null')
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ describe('rscRoutesAutoLoader', () => {
)

// What we are interested in seeing here is:
// - There's a CLIENT_REFERENCE
// - There's a registerClientReference import
// - There's a Link export
// - There's a proper $$id
// - There's a registerClientReference call with the path to the built link
// component dist file
expect(output).toMatchInlineSnapshot(`
"import {registerClientReference} from "react-server-dom-webpack/server";
export const Link = registerClientReference(function() {throw new Error("Attempted to call Link() from the server but Link is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.");},"/Users/tobbe/rw-app/web/dist/rsc/assets/rsc-link.js-13.mjs","Link")
Expand Down Expand Up @@ -155,8 +156,8 @@ describe('rscRoutesAutoLoader', () => {
)

// What we are interested in seeing here is:
// - The import of `renderFromRscServer` from `@redwoodjs/vite/client`
// - The call to `renderFromRscServer` for each page that wasn't already imported
// - The import of `registerClientReference` from `react-server-dom-webpack/server`
// - The export of all of the individual components
expect(output).toMatchInlineSnapshot(`
"import {registerClientReference} from "react-server-dom-webpack/server";
export const CheckmarkIcon = registerClientReference(function() {throw new Error("Attempted to call CheckmarkIcon() from the server but CheckmarkIcon is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.");},"/Users/tobbe/rw-app/web/dist/rsc/assets/rsc-index.js-15.mjs","CheckmarkIcon")
Expand Down

0 comments on commit 893fc5a

Please sign in to comment.