Skip to content

Export renderToHTML from @cloudflare/waterfall/render for Node.js - #366

Open
RaphaelFakhri wants to merge 1 commit into
cloudflare:mainfrom
RaphaelFakhri:fix/waterfall-render-node-export
Open

RaphaelFakhri wants to merge 1 commit into
cloudflare:mainfrom
RaphaelFakhri:fix/waterfall-render-node-export

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Fixes #361.

Problem

The README documents rendering a HAR in a Node.js build script with import { renderToHTML } from '@cloudflare/waterfall'. That import fails in plain Node.js:

  • The main entry point imports ./waterfall.css, so Node.js throws ERR_UNKNOWN_FILE_EXTENSION.
  • With a CSS loader, it then re-exports WaterfallChart, which extends HTMLElement and throws ReferenceError: HTMLElement is not defined.

dist/render.js has no CSS or DOM dependencies, but it is not listed in exports, so @cloudflare/waterfall/dist/render.js fails with ERR_PACKAGE_PATH_NOT_EXPORTED.

Changes

  • Add a ./render subpath export (types, import, default) that points at dist/render.js. The main entry point stays unchanged for bundler and browser consumers.
  • Update the README build-script example and the build artifacts table to use @cloudflare/waterfall/render.
  • Add __tests__/node-import.test.ts, which spawns a plain node process (no loaders, no DOM shims) that imports @cloudflare/waterfall/render through the package exports map and renders an empty HAR and the demo HAR.
  • Add a patch changeset for @cloudflare/waterfall.

Testing

npm run build -w packages/waterfall
npm test -w packages/waterfall
  • Without the exports entry, the new test fails with ERR_PACKAGE_PATH_NOT_EXPORTED (2 failed).
  • With it, the new test passes (2 passed) and the full package suite passes (13 files, 175 tests).
  • import { renderToHTML } from '@cloudflare/waterfall/render' also type-checks with moduleResolution: nodenext from a consumer project.

The main entry point imports waterfall.css and defines the
<waterfall-chart> custom element, so importing it in plain Node.js fails
with ERR_UNKNOWN_FILE_EXTENSION and then HTMLElement is not defined.
dist/render.js has no browser dependencies but was not listed in
exports, so it could not be imported either.

Add a ./render subpath export and point the README build-script
example at it.

Fixes cloudflare#361
Copilot AI balanced review requested due to automatic review settings October 20, 2026 09:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@cloudflare/waterfall: Attempting to use renderToHTML from Node.js fails

2 participants