ezolenko / rollup-plugin-typescript2

Rollup plugin for typescript with compiler errors.
MIT License
822 stars 71 forks source link

fix(diagnostics): workaround Rollup duplicating error messages #373

Closed agilgur5 closed 2 years ago

agilgur5 commented 2 years ago

Summary

Adds a workaround for a Rollup bug that causes duplicate error messages

Details

Review Notes

This is gonna merge conflict pretty hard with #345 's current code (as these both add the buildEnd hook), but I made them both compatible with each other. Will just have to update one or the other when one is merged

Future Work

I'll make a PR to Rollup proper and link it here as well

agilgur5 commented 2 years ago

sh*t, I was reading https://github.com/ezolenko/rollup-plugin-typescript2/issues/103#issuecomment-549948943 and this seems to break watch mode for some reason.... back to the drawing board again....

agilgur5 commented 2 years ago

Oh... well apparently Rollup needs some other properties that it attaches to the error:

{
    id: '/project-dir/src/difference.ts',
    hook: 'transform',
    code: 'PLUGIN_ERROR',
    plugin: 'rpt2',
    watchFiles: [
      '/project-dir/src/index.ts',
      '/project-dir/tsconfig.json',
      '/project-dir/src/types.ts',
      '/project-dir/src/difference.ts'
    ]
  }
}

So need to spread those in. And spreading them in makes watch mode work again, thankfully

agilgur5 commented 1 year ago

This has been fixed upstream in Rollup in https://github.com/rollup/rollup/pull/4749 and released in Rollup v3.7.5