Import the roughjs root entry instead of roughjs/bin/* - #1
Open
mikeyzhong wants to merge 1 commit into
Open
Conversation
roughjs's bin/ files are ES modules with extensionless relative imports and no exports map, so any consumer loading this package in native Node ESM fails with ERR_MODULE_NOT_FOUND (roughjs/bin/svg.js -> './core'). The root roughjs entry resolves to the self-contained bundled builds, which load everywhere; rough.canvas()/rough.svg() return the same RoughCanvas/RoughSVG instances the constructors did. Also fold the hand-patched dist/components/ReactRough/ReactRough.d.ts props interface into the source (and widen RoughProviderProps.children to ReactNode to match), so rebuilding dist no longer clobbers it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Problem
roughjs's
bin/files are ES modules with extensionless relative imports and noexportsmap, so any consumer loading this package in native Node ESM (no bundler) fails:This surfaced in sketches PR 2116 review:
import('sketches-dev')fails in plain Node because its dependency graph reaches this package'sroughjs/bin/canvas/roughjs/bin/svgrequires.Fix
Renderer.tsx: import the rootroughjsentry (resolves to the self-contained bundled builds, loadable everywhere) and use therough.canvas()/rough.svg()factories — they return the sameRoughCanvas/RoughSVGinstances the constructors did. All remainingroughjs/bin/*imports in src are type-position only and erase at compile time.dist/components/ReactRough/ReactRough.d.tsprops interface intoReactRough.tsx(and widenRoughProviderProps.childrentoReactNodeto match), so rebuilding dist no longer clobbers it.dist/, bumped version to 1.0.3.Verification
npm run buildpasses; both dist builds reference onlyroughjs(nobin/*).github:mikeyzhong/rough-react-wrapper#fix-native-esm-roughjs-importwith"type": "module":import ReactRough, { Line, Path } from "rough-react-wrapper"loads in native Node.ReactRough.d.tsmatches the old hand-patched public surface.🤖 Generated with Claude Code