fix(typescript) replace getOutputFileNames #726
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rollup Plugin Name:
{@rollup/plugin-typescript}
This PR contains:
Are tests included?
Breaking Changes?
List any relevant issue numbers:
An issue I experienced (details below) and rather than logging it, I set out to fix it.
Potentially resolves #287
Potentially resolves #608
Description
The problem I experienced was that when I used the Rollup API, if I set
tsconfig:false
and passed in all of my compilerOptions to the typescript plugin, the system would fail ... with a very unhelpful message.Turns out is was a failing assertion deep inside typescript as part of the
getOutputFileNames
call chain. (Little did I realise at the time that it had been causing grief for others in a different fashion).So I set out to see if there was another approach...
It turns out that TS knows (obviously) and _already tells the typescript plugin where it has generated files and what the corresponding source files are, this comes via the BuildProgram
writeFile
callback. By utilising the extra information this PR obviates the need forgetOutputFileNames
an external call we no longer need to make. 🥳I've added a new test (that failed pre these changes) and I've slightly tweaked a couple of others as the order of files reported to the test harness has changed and the FakeTypescript test needed to also pass in the newly used source file information.
I also changed the way that the
generateBundle
figures out the baseDir path to use ... basing it on the approach MS document on their TS site (URL in the source) ... however, whilst it works and does not break tests ... I feel that there is perhaps a better way to calculate this ... perhaps just copying the hierarchy that the TS program generates? 🤔There is a possibility that this may also address issue #287 however I was unsuccessful in getting the test that @benmccann added ... but I think it is close ... 🤞