fix(#2736): canonicalize PURE annotations in dist-es5 (module) output#2744
Merged
hectorhdzg merged 2 commits intoJun 18, 2026
Merged
Conversation
…e) output
Modern bundlers (Rolldown / Vite 8) prefer the package "module" entry,
which resolves to the per-module dist-es5 tsc output. TypeScript emits
parenthesized PURE annotations with whitespace after the opening paren
(e.g. `( /*#__PURE__*/"http.")`), which Rolldown rejects with
[INVALID_ANNOTATION]. The existing rollup fixPureAnnotations() pass only
covers the bundled dist/es5 ("main") output, so the ESM consumer path
stayed broken (microsoft#2737 only fixed the bundle).
Changes:
- Add shared tools/pureAnnotations.js (single source of truth for the
canonicalization regex), reused by both rollup.base.config.js and the
new grunt task.
- Add "fix-pure" grunt multitask that canonicalizes dist-es5/**/*.js after
the tsc compile; wired into the shared tsBuildActions pipeline for all
packages.
- Extract shared getDistPackageRoots() in gruntfile.js (reused by
validate-es5 and fix-pure).
- Keep the wrapping parens (required for older Rollup/Webpack/Terser to
tree-shake the constants), per maintainer guidance.
- Extend AISKU/AppInsightsCore size tests to assert canonical PURE form in
the dist-es5 module output.
- Document the fix in RELEASES.md (3.4.2).
rads-1996
approved these changes
Jun 18, 2026
JacksonWeber
approved these changes
Jun 18, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes ESM consumer builds by canonicalizing parenthesized PURE annotations in the per-module dist-es5 TypeScript output (the module entry), aligning it with the existing rollup-bundle normalization done for dist/es5 (the main entry) to avoid Rolldown/Vite 8 [INVALID_ANNOTATION] warnings.
Changes:
- Introduces a shared PURE-annotation canonicalization helper (
tools/pureAnnotations.js) and reuses it in both rollup and a new grunt post-process step. - Adds a new
fix-puregrunt multitask and wires it into the sharedtsBuildActions()pipeline to rewritedist-es5/**/*.jsafter compile. - Extends AISKU and AppInsightsCore size tests to assert non-canonical PURE spacing is not present in
dist-es5module outputs.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/pureAnnotations.js | Adds shared regex + helper to canonicalize spaced PURE annotations to the flush form. |
| tools/grunt-tasks/fixPureAnnotations.js | New grunt multitask (fix-pure) to rewrite emitted dist-es5 JS files after tsc compile. |
| rollup.base.config.js | Reuses shared canonicalization helper inside fixPureAnnotations() renderChunk step. |
| gruntfile.js | Adds fix-pure config + integrates the task into tsBuildActions(); extracts shared package-root mapping. |
| shared/AppInsightsCore/Tests/Unit/src/ai/AppInsightsCoreSize.Tests.ts | Adds a dist-es5 PURE-annotation validation fetch/test alongside existing dist validation. |
| AISKU/Tests/Unit/src/AISKUSize.Tests.ts | Adds a dist-es5 PURE-annotation validation fetch/test alongside existing dist validation. |
| RELEASES.md | Documents the Rolldown/Vite 8 PURE annotation fix and references #2736. |
…resolves it rollup's --bundleConfigAsCjs writes the bundled config into the subpackage dir and does not run the commonjs plugin, so a relative require()/CJS import of the shared helper failed to resolve. Convert the shared helper to an ES module and import it directly in rollup.base.config.js (rollup inlines it); the CommonJS grunt task now loads it via async dynamic import().
rads-1996
approved these changes
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Modern bundlers (Rolldown / Vite 8) prefer the package "module" entry, which resolves to the per-module dist-es5 tsc output. TypeScript emits parenthesized PURE annotations with whitespace after the opening paren (e.g.
( /*#__PURE__*/"http.")), which Rolldown rejects with [INVALID_ANNOTATION]. The existing rollup fixPureAnnotations() pass only covers the bundled dist/es5 ("main") output, so the ESM consumer path stayed broken (#2737 only fixed the bundle).Changes:
Fixes #2736