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

fix: Pass tsconfig path to typescript parseJsonConfigFileContent #495

Merged
merged 11 commits into from Sep 29, 2022

Conversation

mycroes
Copy link
Contributor

@mycroes mycroes commented Sep 23, 2022

Fix #443

@changeset-bot
Copy link

changeset-bot bot commented Sep 23, 2022

🦋 Changeset detected

Latest commit: 629d539

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@preconstruct/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@netlify
Copy link

netlify bot commented Sep 23, 2022

Deploy Preview for preconstruct ready!

Name Link
🔨 Latest commit 629d539
🔍 Latest deploy log https://app.netlify.com/sites/preconstruct/deploys/6334f395fe784d00093c385e
😎 Deploy Preview https://deploy-preview-495--preconstruct.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@mycroes
Copy link
Contributor Author

mycroes commented Sep 23, 2022

Had to alter memoize to take two arguments, but since it's only used for typescript memoization that didn't seem like much of an issue. I honestly doubt the need for the dirname in the memoization though, I don't think there's another path that will result in a different dirname/tsconfig combination.

@codecov
Copy link

codecov bot commented Sep 23, 2022

Codecov Report

Base: 92.14% // Head: 91.19% // Decreases project coverage by -0.95% ⚠️

Coverage data is based on head (629d539) compared to base (0c79455).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #495      +/-   ##
==========================================
- Coverage   92.14%   91.19%   -0.96%     
==========================================
  Files          32       33       +1     
  Lines        1452     1477      +25     
  Branches      395      396       +1     
==========================================
+ Hits         1338     1347       +9     
- Misses        108      124      +16     
  Partials        6        6              
Impacted Files Coverage Δ
...c/rollup-plugins/typescript-declarations/common.ts 84.00% <100.00%> (+0.43%) ⬆️
packages/cli/src/build/config.ts 80.88% <0.00%> (-1.48%) ⬇️
packages/cli/src/prompt.ts 34.78% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@mycroes
Copy link
Contributor Author

mycroes commented Sep 23, 2022

I'm actually having slight second thoughts on this PR, as pointed out in #443 this problem occures if packages are below a src/ directory in the workspace root. Since I replaced process.cwd() with dirname argument, is there any chance that it's not properly changing CWD if it detects a src/ in the current directory? This change does mitigate the error, not sure if the root cause is properly handled though...

@mycroes
Copy link
Contributor Author

mycroes commented Sep 26, 2022

Fixed my second thoughts. Paths are relative to the config file location, so instead of CWD I'm now passing the tsconfig directory instead. That should be a definite solution to the problem and removes the need to alter the memoize calls. I hope you like this simplified version.

Copy link
Member

@emmatown emmatown left a comment

Choose a reason for hiding this comment

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

The change itself seems fine but could you add some tests? I'm not sure this will actually fix the issue

@mycroes
Copy link
Contributor Author

mycroes commented Sep 27, 2022

I'll see what I can do. It's working, I'm using the changes using yarn patch, my repo is building fine now.

@mycroes mycroes changed the title fix: Pass package path to typescript parseJsonConfigFileContent fix: Pass tsconfig path to typescript parseJsonConfigFileContent Sep 27, 2022
@mycroes
Copy link
Contributor Author

mycroes commented Sep 27, 2022

@mitchellhamilton I added a test which breaks without the path change and passes with the change. I hope this satisfies your requirements.

Also, when checking this out on Windows I get a ton of eslint errors due to line ending style, not sure if you have any advice on this. It's hugely annoying, hiding the actual style errors.

@mycroes
Copy link
Contributor Author

mycroes commented Sep 28, 2022

I'm not sure about denying outDir or declarationDir, I actually have them set because in the same monorepo I also have a sample project that's built with Vite. I believe I can't have the packages set to noEmit when the Vite sample references them and otherwise I would either have to omit tsc to validate upfront or my source dir gets cluttered with the tsc build output (which now goes to a gitignored directory).

I don't know if preconstruct offers me the same functionality in dev mode, but this approach (with path aliases for local packages in sample tsconfig) gives me HMR on package changes as well, which makes for an extremely smooth development experience.

@mycroes
Copy link
Contributor Author

mycroes commented Sep 28, 2022

Also, when checking this out on Windows I get a ton of eslint errors due to line ending style, not sure if you have any advice on this. It's hugely annoying, hiding the actual style errors.

I actually set git core.autocrlf to false now, that at least preserves LF in the source files which makes the development experience way better.

Copy link
Member

@emmatown emmatown left a comment

Choose a reason for hiding this comment

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

Thanks!

@emmatown emmatown merged commit 4e90c2b into preconstruct:main Sep 29, 2022
@github-actions github-actions bot mentioned this pull request Sep 29, 2022
@mycroes
Copy link
Contributor Author

mycroes commented Sep 29, 2022

You're welcome, thanks for preconstruct and emotion!

@mycroes mycroes deleted the typescript-paths branch September 29, 2022 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants