Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ssr/rsc): Update tsconfig when enabling streaming-ssr #10701

Merged
merged 6 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions __fixtures__/test-project-rsa/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
"allowJs": true,
"esModuleInterop": true,
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"baseUrl": "./",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"skipLibCheck": false,
"rootDirs": [
"./src",
Expand Down Expand Up @@ -34,20 +33,22 @@
},
"typeRoots": [
"../node_modules/@types",
"./node_modules/@types"
"./node_modules/@types",
"../node_modules/@testing-library"
],
"types": [
"jest",
"@testing-library/jest-dom",
"jest-dom",
"react/experimental"
],
"jsx": "preserve"
},
"include": [
"src",
"config",
"../.redwood/types/includes/all-*",
"../.redwood/types/includes/web-*",
"../types",
"./types"
]
}
}
23 changes: 17 additions & 6 deletions __fixtures__/test-project-rsc-kitchen-sink/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"allowJs": true,
"esModuleInterop": true,
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"skipLibCheck": false,
"rootDirs": [
"./src",
Expand All @@ -20,16 +20,27 @@
"../api/src/*",
"../.redwood/types/mirror/api/src/*"
],
"$api/*": ["../api/*"],
"types/*": ["./types/*", "../types/*"],
"@redwoodjs/testing": ["../node_modules/@redwoodjs/testing/web"]
"$api/*": [
"../api/*"
],
"types/*": [
"./types/*",
"../types/*"
],
"@redwoodjs/testing": [
"../node_modules/@redwoodjs/testing/web"
]
},
"typeRoots": [
"../node_modules/@types",
"./node_modules/@types",
"../node_modules/@testing-library"
],
"types": ["jest", "jest-dom", "react/experimental"],
"types": [
"jest",
"jest-dom",
"react/experimental"
],
"jsx": "preserve"
},
"include": [
Expand Down
24 changes: 19 additions & 5 deletions __fixtures__/test-project/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,26 @@
"../api/src/*",
"../.redwood/types/mirror/api/src/*"
],
"$api/*": [ "../api/*" ],
"types/*": ["./types/*", "../types/*"],
"@redwoodjs/testing": ["../node_modules/@redwoodjs/testing/web"]
"$api/*": [
"../api/*"
],
"types/*": [
"./types/*",
"../types/*"
],
"@redwoodjs/testing": [
"../node_modules/@redwoodjs/testing/web"
]
},
"typeRoots": ["../node_modules/@types", "./node_modules/@types", "../node_modules/@testing-library"],
"types": ["jest", "jest-dom"],
"typeRoots": [
"../node_modules/@types",
"./node_modules/@types",
"../node_modules/@testing-library"
],
"types": [
"jest",
"jest-dom"
],
"jsx": "preserve"
},
"include": [
Expand Down
23 changes: 23 additions & 0 deletions packages/cli/src/commands/experimental/setupStreamingSsrHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,29 @@ export const handler = async ({ force, verbose }) => {
})
},
},
{
title: `Update web/{ts,js}config.json...`,
task: async () => {
const tsconfigTemplate = fs.readFileSync(
path.resolve(
__dirname,
'templates',
'streamingSsr',
'tsconfig.json.template',
),
'utf-8',
)

const tsconfigPath = path.join(
rwPaths.web.base,
ts ? 'tsconfig.json' : 'jsconfig.json',
)

writeFile(tsconfigPath, tsconfigTemplate, {
overwriteExisting: force,
})
},
},
{
title:
'Adding resolution for "@apollo/client-react-streaming/superjson"',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"compilerOptions": {
"noEmit": true,
"allowJs": true,
"esModuleInterop": true,
"target": "esnext",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"skipLibCheck": false,
"rootDirs": [
"./src",
"../.redwood/types/mirror/web/src",
"../api/src",
"../.redwood/types/mirror/api/src"
],
"paths": {
"src/*": [
"./src/*",
"../.redwood/types/mirror/web/src/*",
"../api/src/*",
"../.redwood/types/mirror/api/src/*"
],
"$api/*": [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please try to keep this file as close as possible to the template in CRWA? So that it's easier for users to see what changes the setup command actually did by just running a git diff. Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Hmm...

Why did you have to do this?

Copy link
Collaborator Author

@dac09 dac09 May 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing. The CRWA template isn't formatted with prettier (which is why you see a big diff. I used prettier on all of the ones I changed.

Would you like me to prettify crwa or change all the others to the unformatted version?

(the ones in the fixture were paritally formatted and not confgruent with crwa)

"../api/*"
],
"types/*": [
"./types/*",
"../types/*"
],
"@redwoodjs/testing": [
"../node_modules/@redwoodjs/testing/web"
]
},
"typeRoots": [
"../node_modules/@types",
"./node_modules/@types",
"../node_modules/@testing-library"
],
"types": [
"jest",
"jest-dom",
"react/experimental"
],
"jsx": "preserve"
},
"include": [
"src",
"config",
"../.redwood/types/includes/all-*",
"../.redwood/types/includes/web-*",
"../types",
"./types"
]
}
24 changes: 19 additions & 5 deletions packages/create-redwood-app/templates/ts/web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,26 @@
"../api/src/*",
"../.redwood/types/mirror/api/src/*"
],
"$api/*": [ "../api/*" ],
"types/*": ["./types/*", "../types/*"],
"@redwoodjs/testing": ["../node_modules/@redwoodjs/testing/web"]
"$api/*": [
"../api/*"
],
"types/*": [
"./types/*",
"../types/*"
],
"@redwoodjs/testing": [
"../node_modules/@redwoodjs/testing/web"
]
},
"typeRoots": ["../node_modules/@types", "./node_modules/@types", "../node_modules/@testing-library"],
"types": ["jest", "jest-dom"],
"typeRoots": [
"../node_modules/@types",
"./node_modules/@types",
"../node_modules/@testing-library"
],
"types": [
"jest",
"jest-dom"
],
"jsx": "preserve"
},
"include": [
Expand Down
Loading