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

Rename ext-src to src in SDK #2486

Merged
merged 4 commits into from
Feb 7, 2025
Merged

Rename ext-src to src in SDK #2486

merged 4 commits into from
Feb 7, 2025

Conversation

sodic
Copy link
Contributor

@sodic sodic commented Feb 5, 2025

User's code is type checked as a part of the SDK (until we close #1718), meaning that TypeScript reports errors:

  1. In the wrong place (./node_modules/wasp/ext-src instead of ./src).
  2. Using the wrong config (./node_modules/wasp/tsconfig.json instead of ./tsconfig.json).

Renaming ./node_modules/wasp/ext-src to ./node_modules/wasp/src mitigates the first point - the errors now contain a path users would expect. It's not really the correct path as it's still under ./node_modules/wasp, but it's similar enough.

Before:

image

After:

image

Comment on lines -76 to -77
extCodeDirInSdkRootDir :: Path' (Rel SdkRootDir) Dir'
extCodeDirInSdkRootDir = [reldir|ext-src|]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We accidentally had two constants describing the same thing, so I removed this one.

@@ -8,7 +8,6 @@
"allowSyntheticDefaultImports": true,
},
"include": [
"vite.config.ts",
"./src/ext-src/vite.config.ts"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you drop this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

./src/ext-src/vite.config.ts isn't a thing since #1626, but we forgot to remove it from here.

These days, we're importing the user's config directly:

import customViteConfig from '../../../vite.config'
const _waspUserProvidedConfig = customViteConfig

Hm, should we perhaps add ../../../vite.config to the include array? Vite doesn't type-check anything anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've put @ts-ignore about the import of user's Vite config because it's outside of the root (TS complained) - maybe that has changed? If not, then the include might not be necessary since it's ignored anyways?

Copy link
Contributor Author

@sodic sodic Feb 6, 2025

Choose a reason for hiding this comment

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

I've removed the @ts-ignore (you were right, it's no longer necessary since we're using references), but TS doesn't check anything anyway. It won't even report errors in web-app/vite.config.ts.

I think that's by design - the tsconfig.node.js is intended only for IDE support. We can therefore safely remove the user's Vite config.

One remaining question: What about users writing their vite.config.ts? Which tsconfig.json controls IDE support for that? At the moment, since root tsconfig.json doesn't target it, I think TS checks it with its default settings. @infomiho I created an issue for this: #2489

Copy link
Contributor

@infomiho infomiho left a comment

Choose a reason for hiding this comment

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

Tested it locally, built with Docker. All good.

@sodic sodic merged commit f9c2bc7 into main Feb 7, 2025
6 checks passed
@sodic sodic deleted the filip-rename-ext-src branch February 7, 2025 14:31
@sodic sodic self-assigned this Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explicitly type-check user code during wasp compile
2 participants