Skip to content

[Bug] Vite 8 / Rolldown build warnings: INVALID_ANNOTATION for misplaced /#PURE/ comments #2736

Closed

Description

@SaebAmini

Description
When building a project using Vite 8 (which now uses Rolldown as its bundler), the build output is spammed with INVALID_ANNOTATION warnings originating from @microsoft/applicationinsights-web and @microsoft/applicationinsights-core-js.

Rolldown is much stricter than Rollup/Webpack regarding the AST positioning of /#PURE/ comments. It flags pure annotations placed before string literals, null values, or inside grouping parentheses as invalid:

https://rolldown.rs/in-depth/dead-code-elimination#pure

Steps to Reproduce

  • Create a new Vite 8 project.

  • Install @microsoft/applicationinsights-web.

  • Import and initialize Application Insights.

  • Run npm run build.

Expected behavior
The project should build without pure annotation warnings.

Logs

[INVALID_ANNOTATION] A comment "/*#__PURE__*/" in "node_modules/@microsoft/applicationinsights-web/dist-es5/internal/trace/spanUtils.js" contains an annotation that Rolldown cannot interpret due to the position of the comment.
    ╭─[ node_modules/@microsoft/applicationinsights-web/dist-es5/internal/trace/spanUtils.js:33:18 ]
 33 │ var HTTP_DOT = ( /*#__PURE__*/"http.");
    │                ──────┬──────  
    │                      ╰──────── comment ignored due to position

[INVALID_ANNOTATION] A comment "/* #__PURE__*/" in "node_modules/@microsoft/applicationinsights-web/dist-es5/internal/trace/spanUtils.js" contains an annotation that Rolldown cannot interpret due to the position of the comment.
    ╭─[ node_modules/@microsoft/applicationinsights-web/dist-es5/internal/trace/spanUtils.js:34:45 ]
 34 │ var _MS_PROCESSED_BY_METRICS_EXTRACTORS = ( /* #__PURE__*/"_MS.ProcessedByMetricExtractors");
    │                                             ───────┬──────  
    │                                                    ╰──────── comment ignored due to position

[INVALID_ANNOTATION] A comment "/* #__PURE__*/" in "node_modules/@microsoft/applicationinsights-core-js/dist-es5/ext/extUtils.js" contains an annotation that Rolldown cannot interpret due to the position of the comment.
    ╭─[ node_modules/@microsoft/applicationinsights-core-js/dist-es5/ext/extUtils.js:54:29 ]
 54 │ var uInt8ArraySupported = ( /* #__PURE__*/null);
    │                             ───────┬──────  
    │                                    ╰──────── comment ignored due to position

Activity

  1. PetterRuud commented on May 22, 2026

    @PetterRuud

    Quick "fix" for now
    In vite.config

    under resolve

    noExternal: [
          '@microsoft/applicationinsights-web',
          '@microsoft/applicationinsights-core-js',
          '@microsoft/applicationinsights-react-js',
        ],
    

    vite 7
    under build.rollupOptions.output

            // Suppress the PURE annotation warnings
            onwarn(warning, warn) {
              if (
                warning.code === 'COMMENT_ANCHOR_NOT_FOUND' ||
                (warning.message &&
                  warning.message.includes('contains an annotation that Rollup cannot interpret'))
              ) {
                return;
              }
              warn(warning);
            },
          },
    

    vite 8

    build: {
      rolldownOptions: {
        onwarn(warning, warn) {
          if (
            warning.code === 'COMMENT_ANCHOR_NOT_FOUND' ||
            (warning.message &&
              warning.message.includes('contains an annotation that Rollup cannot interpret'))
          ) {
            return;
          }
          warn(warning);
        },
      },
    }
    
    
  2. hrithik-infinite commented on May 25, 2026

    @hrithik-infinite

    The root cause for one of the three reported files is now fixed upstream: the @nevware21/ts-utils annotations (ts-utils.js) were corrected in nevware21/ts-utils#569 (merged, tracking issue #568).

    However, the warnings in this issue's logs originate from App Insights' own shipped ES5 bundles, not from ts-utils:

    • @microsoft/applicationinsights-web/dist-es5/internal/trace/spanUtils.js:33,34
    • @microsoft/applicationinsights-core-js/dist-es5/ext/extUtils.js:54

    These have the same misplaced /*#__PURE__*/ pattern (inside grouping parens, before string/null literals) that Rolldown rejects. They won't be resolved by the ts-utils fix alone. Two things are needed here:

    1. Correct the /*#__PURE__*/ placement in applicationinsights-web / applicationinsights-core-js source so it survives the ES5 build, and
    2. Pick up the released @nevware21/ts-utils containing HandledAt is not tracked in Exception #569.

    Reproduced on applicationinsights-web@3.4.1 / applicationinsights-core-js@3.4.1 with Vite 8 (vite@8.0.14, Rolldown).

    I'm happy to raise a PR for the applicationinsights-web / applicationinsights-core-js source fix — let me know if that'd be welcome.

  3. danciudev commented on Jun 14, 2026

    @danciudev

    Any updates on this?

  4. added a commit that references this issue on Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions