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

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

Merged
merged 2 commits into from Jul 6, 2022

Commits on Jul 2, 2022

  1. fix(diagnostics): workaround Rollup duplicating error messages

    - per my investigation in the linked issues, it seems like Rollup has a bug where it duplicates some error message
      - this occurs when the error has a stack (or frame) which contains the error message itself
        - Rollup prints _both_ the error message _and_ the stack in that case, causing duplication
    
    - this fix adds a workaround for this upstream Rollup bug
      - it detects if there is a stack and if the message is duplicated in the stack
        - if so, it removes the duplication in the stack
      - this workaround should be forward-compatible if this behavior is fixed upstream
        - this code should just end up re-throwing in that case (effectively a no-op)
    agilgur5 committed Jul 2, 2022
    Configuration menu
    Copy the full SHA
    f62ac54 View commit details
    Browse the repository at this point in the history
  2. fix watch mode by spreading err

    - apparently Rollup attaches several properties to the error object, including `watchFiles`
      - so removing them / not spreading causes watch to just stop working
    
    here are some of the additional properties I logged out, for example:
    ```js
    {
        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'
        ]
      }
    }
    ```
    agilgur5 committed Jul 2, 2022
    Configuration menu
    Copy the full SHA
    d3faa2e View commit details
    Browse the repository at this point in the history