Skip to content

Commit

Permalink
Use project references from web-app and server (#2444)
Browse files Browse the repository at this point in the history
  • Loading branch information
sodic authored Jan 21, 2025
1 parent 8f3384e commit 51f1e90
Show file tree
Hide file tree
Showing 48 changed files with 472 additions and 315 deletions.
25 changes: 16 additions & 9 deletions waspc/data/Cli/templates/skeleton/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
// =============================== IMPORTANT =================================
// This file is mainly used for Wasp IDE support.
//
// This file is only used for Wasp IDE support. You can change it to configure
// your IDE checks, but none of these options will affect the TypeScript
// compiler. Proper TS compiler configuration in Wasp is coming soon :)
// Wasp will compile your code with slightly different (less strict) compilerOptions.
// You can increase the configuration's strictness (e.g., by adding
// "noUncheckedIndexedAccess": true), but you shouldn't reduce it (e.g., by
// adding "strict": false). Just keep in mind that this will only affect your
// IDE support, not the actual compilation.
//
// Full TypeScript configurability is coming very soon :)
{
"compilerOptions": {
"module": "esnext",
// Needed because this is used as a project reference.
"composite": true,
"target": "esnext",
// We're bundling all code in the end so this is the most appropriate option,
// it's also important for autocomplete to work properly.
Expand All @@ -20,6 +27,7 @@
"dom.iterable",
"esnext"
],
"skipLibCheck": true,
"allowJs": true,
"typeRoots": [
// This is needed to properly support Vitest testing with jest-dom matchers.
Expand All @@ -32,10 +40,9 @@
// Source 2: https://github.com/testing-library/jest-dom/issues/546#issuecomment-1889884843
"node_modules/@types"
],
// Since this TS config is used only for IDE support and not for
// compilation, the following directory doesn't exist. We need to specify
// it to prevent this error:
// https://stackoverflow.com/questions/42609768/typescript-error-cannot-write-file-because-it-would-overwrite-input-file
"outDir": ".wasp/phantom"
}
"outDir": ".wasp/out/user"
},
"include": [
"src"
]
}
20 changes: 20 additions & 0 deletions waspc/data/Generator/templates/react-app/tsconfig.app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "@tsconfig/vite-react/tsconfig.json",
"compilerOptions": {
// Temporary loosen the type checking until we can address all the errors.
"jsx": "preserve",
"allowJs": true,
"strict": false,
"skipLibCheck": true,
// Allow importing pages with the .tsx extension.
"allowImportingTsExtensions": true,
"noEmit": true,
},
"include": [
"src"
],
"references": [
// TODO: It would be better to inject this knowledge from Haskell.
{ "path": "../../../tsconfig.json" }
]
}
20 changes: 4 additions & 16 deletions waspc/data/Generator/templates/react-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
{
"extends": "@tsconfig/vite-react/tsconfig.json",
"compilerOptions": {
// Temporary loosen the type checking until we can address all the errors.
"jsx": "preserve",
"allowJs": true,
"strict": false,
// Allow importing pages with the .tsx extension.
"allowImportingTsExtensions": true,
},
"include": [
"src"
],
"files": [],
"references": [
{
"path": "./tsconfig.node.json"
}
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" },
]
}
}
10 changes: 7 additions & 3 deletions waspc/data/Generator/templates/react-app/tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"noEmit": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
"allowSyntheticDefaultImports": true,
},
"include": ["vite.config.ts", "./src/ext-src/vite.config.ts"]
}
"include": [
"vite.config.ts",
"./src/ext-src/vite.config.ts"
]
}
29 changes: 12 additions & 17 deletions waspc/data/Generator/templates/server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@
"compilerOptions": {
// Overriding this until we implement more complete TypeScript support.
"strict": false,
// When left unspecified, the 'rootDir' defaults to the longest common path of
// all non-declaration input files. TypeScript mimics the source structure
// inside the output directory (i.e., 'dist').

// This property currently doesn't matter because we haven't been running
// TSC on server code since https://github.com/wasp-lang/wasp/pull/1714.
//
// Since Wasp apps can (but don't have to) import user files from
// '../../../src', it makes the rootDir's default value inconsistent:
// - When the app doesn't import user files (e.g., the user didn't specify
// any operations), the rootDir is set to the server source dir (/src).
// - When the app imports user files (as is the case for most Wasp apps),
// the rootDir is set to the Wasp project root (../../../).
//
// Our build script (in package.json) requires a consistent structure of
// the output directory, which is why we always make sure to point the rootDir
// to the Wasp project root (../../../).
//
// See this comment for more details: https://github.com/wasp-lang/wasp/pull/1584#discussion_r1404019301
"rootDir": "../../../",
// When we start running TSC again (after we fix all current errors and
// make project references work for the TS config), then I believe the
// correct configuration is "rootDir": "." (the project reference should
// take care of the user code), but we should double-check.
"rootDir": ".",
// Overriding this because we want to use top-level await
"module": "esnext",
"target": "es2017",
Expand All @@ -36,5 +28,8 @@
},
"include": [
"src"
],
"references": [
{ "path": "../../../tsconfig.json" }
]
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 51f1e90

Please sign in to comment.