-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
getOutputFileNames is returning incorrect path #41780
Labels
Milestone
Comments
TypeScript/src/compiler/emitter.ts Line 141 in d163ab6
None of these four functions have tests in the TypeScript repo. |
sheetalkamat
added a commit
that referenced
this issue
Dec 3, 2020
sheetalkamat
added a commit
that referenced
this issue
Dec 7, 2020
…am emit file path calculation (#41811) * Baseline showing #41801 and other issues with output path calculation * Add a way to note descripencies between clean and incremental build * Add descripency when no rootDir is specified but project is composite * if rootDir is specified, irrespective of whether all files belong to rootDir, the paths should be calculated from rootDir * Fix the output file names api to use the correct common source directory * Tests for #41780 * Spelling
scalder27
pushed a commit
to scalder27/TypeScript
that referenced
this issue
Dec 7, 2020
…am emit file path calculation (microsoft#41811) * Baseline showing microsoft#41801 and other issues with output path calculation * Add a way to note descripencies between clean and incremental build * Add descripency when no rootDir is specified but project is composite * if rootDir is specified, irrespective of whether all files belong to rootDir, the paths should be calculated from rootDir * Fix the output file names api to use the correct common source directory * Tests for microsoft#41780 * Spelling
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Importance
The Rollup TypeScript plugin cannot handle files that are located in a sub-directory: rollup/plugins#287
This is the #1 most reported bug in the Rollup ecosystem (i.e. including both the core package and all plugins) with over 100 thumbs up on the issue
Overview
tsc
usesgetSourceFilePathInNewDir
to find out where the output is placed. However, this method is not exposed. Thus, the Rollup plugin must usegetOutputFileNames
, which often returns incorrectly.TypeScript Version: 4.1.2
Search Terms: getOutputFileNames
Code
I wrote a unit test that fails.
I know the TypeScript team gets an insane amount of bug reports. I hope you might bear with me a little bit on this one given how widely used Rollup is and how many people this is impacting as noted above.
The call to
getOutputFileNames
is made insrc/outputFile.ts
. I added someconsole.log
statements that show the options it's being called with. It seems pretty clear to me that this is a bug because none of the option values reference thesrc
directory specifically. TheoutDir
is correctly showing thedist/
directory.I pushed this to my fork of the Rollup plugins. (You can install pnpm with
npm install -g pnpm
if you do not have it)pnpm ts-bug
is an npm script that runs a single unit test I added, which fails because of this bug. Running it will print to the console the arguments passed togetOutputFileNames
and result from itExpected behavior:
getOutputFileNames
should returndist/index.js
Actual behavior:
getOutputFileNames
returnsdist/src/index.js
Playground Link:
Related Issues:
getOutputJavaScriptFileName
from tsbuild #26410 - issue where it was requested that this functionality be exposedThe text was updated successfully, but these errors were encountered: