Skip to content

ESM bundle contains untranspiled require('dompurify') calls #571

Backlog

Description

@riccardo-forina

Describe the bug

The ESM build (dist/index.es.js, dist/quickstarts-full.es.js) of @patternfly/quickstarts@6.6.0 contains untranspiled CommonJS require('dompurify') calls, coming from the markdown sanitizer code (the admonition/accordion hooks around markdown-it + DOMPurify). There are at least 3 occurrences, e.g.:

fa = require("dompurify");

To Reproduce

  1. npm i @patternfly/quickstarts@6.6.0
  2. Build an app with Vite (production build)
  3. grep -o "require('dompurify')" node_modules/@patternfly/quickstarts/dist/index.es.js → 3 matches

Expected behavior

The ESM bundle should be pure ESM (import/export), so bundlers that don't transform mixed modules can consume it.

Actual behavior

Since the file is marked ESM, Vite/Rollup do not run @rollup/plugin-commonjs on it (transformMixedEsModules is off by default), and the raw require() calls ship to the browser, causing:

ReferenceError: require is not defined

at runtime. In our case this crashed Chromatic's story-extraction step when our Storybook (Vite builder) included @patternfly/quickstarts.

Workaround

Consumers can enable:

build: { commonjsOptions: { transformMixedEsModules: true } }

in their Vite config.

Environment

  • @patternfly/quickstarts: 6.6.0 (latest at time of filing)
  • Bundler: Vite 7 / Rollup
  • Node: 20/24

Activity

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