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

Duplicate error message (esp. when pretty: true) #103

Closed
kitsonk opened this issue Aug 8, 2018 · 7 comments · Fixed by #373
Closed

Duplicate error message (esp. when pretty: true) #103

kitsonk opened this issue Aug 8, 2018 · 7 comments · Fixed by #373
Labels
kind: bug Something isn't working properly priority: in progress problem: stale Issue has not been responded to in some time scope: upstream Issue in upstream dependency solution: Rollup behavior This is Rollup's behavior and not specific to this plugin

Comments

@kitsonk
Copy link

kitsonk commented Aug 8, 2018

What happens and why it is wrong

Duplicate semantic errors get logged to the console, which causes confusion. For example:

./node_modules/rollup/bin/rollup -c ../../rollup.config.js -i ../../js/main.ts -o gen/bundle/main.js --silent
[!] (rpt2 plugin) Error: ../../js/main.ts:8:1 - error TS2304: Cannot find name 'confounded'.

8 confounded;
  ~~~~~~~~~~

../../js/main.ts
Error: ../../js/main.ts:8:1 - error TS2304: Cannot find name 'confounded'.

8 confounded;
  ~~~~~~~~~~

    at error (/Users/kkelly/github/deno/third_party/node_modules/rollup/dist/rollup.js:3365:15)
    at Object.error (/Users/kkelly/github/deno/third_party/node_modules/rollup/dist/rollup.js:20727:13)
    at RollupContext.error (/Users/kkelly/github/deno/third_party/node_modules/rollup-plugin-typescript2/src/rollupcontext.ts:36:18)
    at lodash_2 (/Users/kkelly/github/deno/third_party/node_modules/rollup-plugin-typescript2/src/print-diagnostics.ts:37:10)
    at arrayEach (/Users/kkelly/github/deno/third_party/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:516:11)
    at forEach (/Users/kkelly/github/deno/third_party/node_modules/rollup-plugin-typescript2/node_modules/lodash/lodash.js:9342:14)
    at printDiagnostics (/Users/kkelly/github/deno/third_party/node_modules/rollup-plugin-typescript2/src/print-diagnostics.ts:9:2)
    at Object.transform (/Users/kkelly/github/deno/third_party/node_modules/rollup-plugin-typescript2/src/index.ts:238:5)
    at /Users/kkelly/github/deno/third_party/node_modules/rollup/dist/rollup.js:20750:41
    at process._tickCallback (internal/process/next_tick.js:68:7)

I am not entirely sure how much this is rollup-plugin-typescript2 and how much of this is just the way rollup behaves, but I couldn't find an answer either way.

Versions

  • typescript: 3.0.1
  • rollup: 0.63.2
  • rollup-plugin-typescript2: 0.16.1
@vineetit1991
Copy link

any input on this ? I am also facing this issue

@ezolenko
Copy link
Owner

ezolenko commented Nov 5, 2019

I don't get it with just any error, could you create a test repo with reproduction?

Might depend on error type (typescript only, or something that would trip rollup itself) execution mode (clean build / rebuild / watch) and rollup/plugin settings.

This is what I usually get:
(3 there were errors or warnings lines for 3 bundles that are generated in that build)

rpt2: there were errors or warnings.
rpt2: rolling caches
rpt2: there were errors or warnings.
rpt2: rolling caches
rpt2: there were errors or warnings.
rpt2: rolling caches
(!) Plugin rpt2: src/index.ts:316:18 - error TS2304: Cannot find name 'Plugin5Context'.

316     _onwrite(this: Plugin5Context, _output: OutputOptions): void
                       ~~~~~~~~~~~~~~

src\index.ts

@ezolenko ezolenko added the problem: needs more info This issue needs more information in order to handle it label Nov 5, 2019
@agilgur5 agilgur5 added problem: stale Issue has not been responded to in some time problem: no repro No reproduction was provided (and have not tried to repro without one) solution: can't repro An attempt to reproduce has been tried and failed and removed problem: no repro No reproduction was provided (and have not tried to repro without one) labels Apr 26, 2022
@agilgur5
Copy link
Collaborator

Going to close this out as a reproduction was unsuccessful and this issue has not received any activity in a few years (and may not be relevant in newer versions anymore).

Can re-open later if warranted on current versions and with a repro.

Repository owner locked as resolved and limited conversation to collaborators Jun 8, 2022
@agilgur5 agilgur5 changed the title Duplicate error messages Duplicate error messages -- can't repro Jun 9, 2022
@agilgur5 agilgur5 changed the title Duplicate error messages -- can't repro Duplicate error messages Jul 2, 2022
@agilgur5 agilgur5 added kind: bug Something isn't working properly scope: upstream Issue in upstream dependency and removed problem: needs more info This issue needs more information in order to handle it solution: can't repro An attempt to reproduce has been tried and failed labels Jul 2, 2022
Repository owner unlocked this conversation Jul 2, 2022
@agilgur5 agilgur5 reopened this Jul 2, 2022
@agilgur5
Copy link
Collaborator

agilgur5 commented Jul 2, 2022

So I ended up reproducing this issue while testing #372 .

Per #372 (comment), the last error will indeed get printed out twice in all cases. It just happens to be a lot more visible when using tsconfig's pretty option. That is what OP was using and is what #372 makes the default.

Per #372 (comment), this duplication actually happens within Rollup though, and not because of this plugin. Rollup prints out the error message, and then also prints the error stack, which can actually contain the error message in it, causing duplication.

This may depend on runtime though as Error.stack is non-standardized. It may also depend on how one uses Rollup as well, since this code is in the Rollup CLI specifically.

I'll have a PR out here to workaround this in rpt2 shortly. Will also have to make a similar PR to Rollup itself to handle this upstream. The PR here will be written to be forward-compatible with newer versions of Rollup if that gets merged upstream as well.

@agilgur5
Copy link
Collaborator

agilgur5 commented Jul 2, 2022

rollup/plugins#376 shows and mentions a "duplicated code frame" for @rollup/plugin-babel as well, so this seems to be a long-standing issue that has never quite been fixed.
I couldn't find references to this in Rollup proper, in other issues in rollup/plugins, or elsewhere here, so I guess this hasn't been noticed that often, and seemingly only noticed by people looking to get "prettified" output (either in TS or in Babel).

@agilgur5 agilgur5 changed the title Duplicate error messages Duplicate error message (esp. when pretty: true) Jul 2, 2022
@agilgur5 agilgur5 added the solution: Rollup behavior This is Rollup's behavior and not specific to this plugin label Jul 2, 2022
@agilgur5
Copy link
Collaborator

#373 works around this Rollup bug and has been released in 0.33.0

@agilgur5
Copy link
Collaborator

This has been fixed upstream in Rollup in rollup/rollup#4749 and released in Rollup v3.7.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working properly priority: in progress problem: stale Issue has not been responded to in some time scope: upstream Issue in upstream dependency solution: Rollup behavior This is Rollup's behavior and not specific to this plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants