Repository navigation
Export renderToHTML from @cloudflare/waterfall/render for Node.js - #366
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
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
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.
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:./waterfall.css, so Node.js throwsERR_UNKNOWN_FILE_EXTENSION.WaterfallChart, which extendsHTMLElementand throwsReferenceError: HTMLElement is not defined.dist/render.jshas no CSS or DOM dependencies, but it is not listed inexports, so@cloudflare/waterfall/dist/render.jsfails withERR_PACKAGE_PATH_NOT_EXPORTED.Changes
./rendersubpath export (types,import,default) that points atdist/render.js. The main entry point stays unchanged for bundler and browser consumers.@cloudflare/waterfall/render.__tests__/node-import.test.ts, which spawns a plainnodeprocess (no loaders, no DOM shims) that imports@cloudflare/waterfall/renderthrough the packageexportsmap and renders an empty HAR and the demo HAR.@cloudflare/waterfall.Testing
npm run build -w packages/waterfall npm test -w packages/waterfallexportsentry, the new test fails withERR_PACKAGE_PATH_NOT_EXPORTED(2 failed).import { renderToHTML } from '@cloudflare/waterfall/render'also type-checks withmoduleResolution: nodenextfrom a consumer project.