vuejs/core · error · Error

Found the following treeshaking errors:\n\n- ${errors.join('

Error message

Found the following treeshaking errors:\n\n- ${errors.join('\n\n- ')}

What it means

Thrown by scripts/verify-treeshaking.js, a CI guard for Vue's bundle output. It inspects the production build artifact for code that should have been tree-shaken away (e.g. isHTMLTag / domTagConfig lists appearing in runtime code paths). When the accumulated `errors` array is non-empty, line 45 lists every violation. This is build/CI tooling, not user runtime code.

Source

Thrown at scripts/verify-treeshaking.js:45

    errors.push(
      'prod build contains unexpected warning-related code.\n' +
        'This means there are calls of warn() that are not guarded by the __DEV__ condition.',
    )
  }

  if (
    prodBuild.includes('html,body,base') ||
    prodBuild.includes('svg,animate,animateMotion') ||
    prodBuild.includes('annotation,annotation-xml,maction')
  ) {
    errors.push(
      'prod build contains unexpected domTagConfig lists.\n' +
        'This means helpers like isHTMLTag() is used in runtime code paths when it should be compiler-only.',
    )
  }

  if (errors.length) {
    throw new Error(
      `Found the following treeshaking errors:\n\n- ${errors.join('\n\n- ')}`,
    )
  }
})

View on GitHub (pinned to a2b40db9a8)

Solutions

  1. Ensure compiler-only helpers (isHTMLTag, SVG tags, domTagConfig) are not imported from runtime packages — keep them in @vue/compiler-core / @vue/shared compiler entry points.
  2. Mark compiler-only modules with sideEffects:false and split entries so rollup can drop them from runtime bundles.
  3. Guard any runtime-sensitive import with a build flag so it is excluded from the runtime build.
  4. Re-run the verify-treeshaking job locally and fix each error message in the list before pushing.

Example fix

// before — runtime file imports a compiler-only helper
import { isHTMLTag } from '@vue/compiler-core'

// after — gate it behind the compiler build only
// (remove the import; resolve tag names at compile time and emit literals)
Defensive patterns

Strategy: validation

Validate before calling

// (Vue build/CI) keep compiler-only helpers out of runtime bundles.
// In rollup config, mark compiler-only modules side-effect free and split them:
export default {
  treeshake: { moduleSideEffects: false },
  // ensure @vue/compiler-core helpers are only imported by compiler entries
}

Type guard

function runtimeBundleIsClean(prodBuildSource: string): boolean {
  return !prodBuildSource.includes('isHTMLTag')
    && !prodBuildSource.includes('svg,animate,animateMotion')
    && !prodBuildSource.includes('annotation,annotation-xml,maction')
}

Prevention

When it happens

Trigger: A change to @vue/compiler-core or @vue/shared causes compiler-only helpers (like the domTagConfig arrays referenced at the top of the guard) to leak into the runtime production bundle. Running the verify-treeshaking CI job after such a change.

Common situations: Refactoring that makes runtime code import a compiler-only utility; side-effectful imports pulling in tag-config tables; bundler config changes weakening tree-shaking; adding a new DOM-tag helper used from runtime.

Related errors


AI-assisted analysis of vuejs/core@a2b40db9a8 (2026-08-12). Data as JSON: /api/errors/3d842ac86ae6161d. Report an issue: GitHub.