-
-
Notifications
You must be signed in to change notification settings - Fork 294
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
feat(dev-server-esbuild): allow extended tsconfig #2161
base: master
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 99ae905 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
So if I understand this correctly, I can trigger an automatic release of the package, by applying a change set? |
Apply the changeset to clarify that there are changes requiring a release. Full the changeset with a lingual representation of the changes so that they are included in the CHANGELOG.md. |
7cfa66c
to
4fc32b2
Compare
Let me know if the formatting of the changeset should be adjusted! |
@@ -61,7 +62,15 @@ export class EsbuildPlugin implements Plugin { | |||
this.config = config; | |||
this.logger = logger; | |||
if (this.esbuildConfig.tsconfig) { | |||
this.tsconfigRaw = await promisify(fs.readFile)(this.esbuildConfig.tsconfig, 'utf8'); | |||
try { | |||
const { stderr, stdout } = await promisify(child_process.exec)( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does reading the file not work? We have to shell out to tsc
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading 1 tsconfig.json
file works, but only if you only have 1 tsconfig.json
, without extending from another another tsconfig.json
file.
Technically you could try parsing the file that you initially read, and then recursively call the same function over and over again until all the extends
's are resolved. This is exactly what tsc --show-config
does, so I chose to lean on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, interesting! I'm wondering if we should really be using the .tsconfig
setter instead of .tsconfigRaw
. I'm not sure, but from reading the docs, it seems like that setting will work with extending configs?
If not, I think this is good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean with the .tsconfig
setter? And are you referring to the dev-server-esbuild setting, or esbuild itself?
I think I tested this already, but I can try it again. If you revert my change from the code, but keep the test you’ll get a failing test.
From dev-server-esbuild side we can’t set a .tsconfigRaw
. We pass in the .tsconfig
, convert it and then pass it as tsconfigRaw
to esbuild.
Logically, I’d think .tsconfigRaw
would use the tsconfig as you passed it in, without expanding it further automagically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@koddsson I just tested this again, and with the test case I added the test fails, without the change I've proposed here.
ff9f749
to
99ae905
Compare
I rebased the PR to be up to date with latest changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! I'm slightly worried about performance here since we'll be shelling out to tsc
but it's probably fine.
We should probably have some performance testing in the future to help us get insights into how changes affect performance.
We've got #2180 queued up to merge to |
No worries, I've come across another way to possibly solve it while going through the dependabot PR's at work. Would something like this be preferred over shelling out You are still using the EDIT: Also sorry for the re-review, I was worried you might not have seen this message, before potentially merging this PR. |
Oh, yeah! I would love to do this instead. Looks like we need to upgrade to TypeScript 5 first, which I think is also a positive, so I'd prefer that. What do you think? |
Yeah, I think it might be better, but it does indeed seem to require typescript 5. Would that then be considered a breaking change for dev-server-esbuild? |
Probably! But that's no worries, we can just make a breaking change. |
We should be on TypeScript 5 now if you pull master 👯 |
I'll modify my PR somewhere this weekend, I have busy schedule for this week unfortunately. |
No worries! Let me know if we can help :) |
What I did
tsconfig.json
in theesbuildPlugin
that uses extends to extend from a basetsconfig.json
--showConfig
when runningtsc
. See https://www.typescriptlang.org/docs/handbook/compiler-options.htmltarget
of the fixture, since es2022 was reported as invalid bytsc
I'm not sure about the actual implementation, but it covers my test case, without breaking the other tests of
dev-server-esbuild
(at least on Mac) 🤷🏽