Repository navigation
feat: publish react-error-boundary under the systemfsoftware scope - #1
Open
systemfsoftware-bot wants to merge 9 commits into
Open
systemfsoftware-bot wants to merge 9 commits into
systemfsoftware-bot wants to merge 9 commits into
Conversation
The library moves to packages/react-error-boundary as @systemfsoftware/react-error-boundary. Its source, tests and public API are the react-error-boundary 6.1.6 code. The docs site, the eslint, prettier and husky setup, and the Vite configuration are removed. - pnpm workspace with dprint, oxlint (recommended and frontend configs), commitlint and changesets - CI, release, merge-queue and squash-message workflows from the shared systemfsoftware workflows - the build is tsdown (ESM and CJS); tsdown defines import.meta.env.DEV as false, as the upstream build did - tests keep the upstream vitest imports and names; see packages/react-error-boundary/oxlint.config.ts for the reasons
|
Tick the box to add this pull request to the merge queue (same as
|
Lint runs on the frontend config alone. Thrown values are narrowed through type guards, branching is split into small functions, handlers are arrow properties, and the HOC is typed without casts. Tests move to tests/, import the package by name, and use DAMP names and the wrapper's checks. The dprint exclusion is removed.
Extract hasArrayChanged so its comparison can carry an in-source property test. Type withErrorBoundary without any, and add the Storybook and browser Vitest dependencies the scenarios will run under.
Replace the jsdom tests with storybook-gherkin scenarios, including the class ref and defaultProps cases. Keep an in-source property test for hasArrayChanged, and type withErrorBoundary so the wrapped component props and ref are preserved.
…render The boundary now derives its reset in getDerivedStateFromProps from the reset keys it recorded when the error was caught, so a key change that is itself what triggered the error records the new keys without resetting. onReset for a key reset moves to getSnapshotBeforeUpdate so callers are told while the failing fallback is still in the DOM; componentDidUpdate stays as its React- required pair. Public behavior and the browser stories are unchanged.
- The storybook project runs in real Chromium, so the test job fetches the build the lockfile's playwright version names, with the system libraries headless Chromium needs. - Only a push to main writes the browser cache, as with the pnpm store.
- `resetKeys` resets now run in `componentDidUpdate`: `onReset` is called, then the boundary state is cleared, so a caller that clears its failed state in `onReset` has the children retry with that state already in place. The one `react/no-did-update-set-state` line is suppressed with its reason. - `useErrorBoundary().resetBoundary` forwards its arguments to `onReset` and returns the exported `UseErrorBoundaryApi` type. - `withErrorBoundary` renders the wrapped component with `createElement` and names memoized and forwarded components in `displayName`. The data-last overload keeps the component props, proved by a tstyche test that `typecheck` now runs. - Browser scenarios cover the upstream reset order, reporting exactly once under `StrictMode`, and the arguments the hook reset forwards; a changeset records the fix.
- A tstyche type test asserts that `withErrorBoundary(props)(Component)` still refuses a missing required prop, for a component type, a function, a forwarded and a memoized component. - `typecheck` runs tstyche after `tsc`, so the assertion gates the build.
…properties
- Replace the single-valued absent pair with one property over absent-or-empty on both sides, covering each side separately.
- Draw the sign property from {0, -0} plus finite numbers, covering negative, zero and opposite-zero draws.
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.
What this is
@systemfsoftware/react-error-boundaryis the react-error-boundary 6.1.6 library, published under the systemfsoftware scope. It is a port of that library, not a re-export and not a rewrite. The exports insrc/index.tsare unchanged.How it differs from upstream, and why
import.meta.env.DEVis defined asfalsein the published build, which is what the upstream 6.1.6 build shipped. The"use client"directive is kept.withErrorBoundaryis typed as<Props extends object, Type extends ComponentType<Props>>(Component: Type & ComponentType<Props>, …). The wrapped component's props and ref type are preserved, including classdefaultProps, and atest-types/assertion proves the data-last call keeps them. Upstream widened the component toComponentType<any>.resetKeyschange resets incomponentDidUpdateas upstream does:onResetis called first, then the boundary state is cleared, so a caller that clears its failed state inonResethas the children retry with that state in place. The rule that flags asetStateincomponentDidUpdateis suppressed on that one line with its reason.useErrorBoundaryreturns the exportedUseErrorBoundaryApi, and itsresetBoundaryforwards its arguments toonReset, as the fallback'sresetErrorBoundarydoes.withErrorBoundaryrenders the wrapped component withcreateElementand names memoized and forwarded components indisplayName.withErrorBoundaryandhasArrayChangedcarry a pipeable overload (withErrorBoundary(props)(Component),hasArrayChanged(next)(prev)); the two-argument calls are unchanged.hasArrayChangedhas an in-source property test. There is no*.test.tsxlane.Checks run locally
pnpm lint(frontend preset, type-aware): pass. Two per-line suppressions carry their reasons:react/no-did-update-set-stateon the resetsetState, andtypescript/consistent-type-assertionson the child props thatcreateElementtakes, which upstream casts the same way. No file-wide overrides.pnpm typecheck: pass, including the tstyche assertion intest-types/pnpm build: passpnpm testwith a real Chromium: 6 files, 37 tests passed, including the reset-key ordering, exactly-once reporting underStrictMode, and the arguments the hook reset forwardsonResetonly after the children had retried and thrown again, and the hook reset dropped its arguments) and passed after the change; it was deleted.CI in
.github/workflows/ci.yml(pnpm format:check,pnpm lint,pnpm typecheck,pnpm build,attw --pack .,publint,pnpm testincluding the storybook browser lane, and the changeset check) andsquash-message.ymlare pending on this pull request headddda2e4.