Skip to content

fix: replaceAll is not a function#2142

Merged
upupming merged 2 commits intomainfrom
fix/replaceAll
Jan 28, 2026
Merged

fix: replaceAll is not a function#2142
upupming merged 2 commits intomainfrom
fix/replaceAll

Conversation

@upupming
Copy link
Copy Markdown
Collaborator

@upupming upupming commented Jan 27, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Fixed snapshot entry name handling in development mode to ensure correct string substitution at runtime.
    • Resolved a compatibility issue that could cause a TypeError in older ES5 environments.

✏️ Tip: You can customize this high-level summary in your review settings.

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).
  • Changeset added, and when a BREAKING CHANGE occurs, it needs to be clearly marked (or not required).

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jan 27, 2026

🦋 Changeset detected

Latest commit: 84c6e3f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@lynx-js/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

This change replaces replaceAll with a global regular expression in DEV_ONLY_SetSnapshotEntryName to substitute the globDynamicComponentEntry placeholder with the JSON-stringified entryName, and adds a new changeset documenting a patch release for @lynx-js/react.

Changes

Cohort / File(s) Summary
Changeset Documentation
.changeset/cool-peas-wait.md
New changeset marking a patch release for @lynx-js/react, noting a fix for a TypeError caused by replaceAll in ES5 environments.
Runtime Snapshot Patching
packages/react/runtime/src/lifecycle/patch/snapshotPatchApply.ts
Replaced use of replaceAll with a global regular expression in DEV_ONLY_SetSnapshotEntryName to perform placeholder substitution for globDynamicComponentEntry with JSON.stringify(entryName).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • hzy

Poem

🐇 I found a string that wouldn't play,
replaceAll failed and went astray.
I hopped in with a regex tune,
now entries dance beneath the moon.
Patch in place — a carrot celebration! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'fix: replaceAll is not a function' directly matches the main change: replacing the unsupported replaceAll method with a global regex pattern to fix a TypeError in ES5 environments.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Jan 27, 2026

CodSpeed Performance Report

Merging this PR will degrade performance by 7.22%

Comparing fix/replaceAll (84c6e3f) with main (1fa1ddc)1

Summary

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 61 untouched benchmarks
⏩ 3 skipped benchmarks2

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
transform 1000 view elements 47.7 ms 42.1 ms +13.22%
basic-performance-nest-level-100 6.9 ms 7.4 ms -7.22%

Footnotes

  1. No successful run was found on main (8002508) during the generation of this report, so 1fa1ddc was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@relativeci
Copy link
Copy Markdown

relativeci bot commented Jan 27, 2026

Web Explorer

#7397 Bundle Size — 382.04KiB (-0.7%).

84c6e3f(current) vs 1fa1ddc main#7383(baseline)

Bundle metrics  Change 1 change
                 Current
#7397
     Baseline
#7383
No change  Initial JS 154.71KiB 154.71KiB
No change  Initial CSS 35.05KiB 35.05KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 8 8
No change  Assets 8 8
No change  Modules 237 237
No change  Duplicate Modules 16 16
Change  Duplicate Code 3%(+0.33%) 2.99%
No change  Packages 4 4
No change  Duplicate Packages 0 0
Bundle size by type  Change 1 change Improvement 1 improvement
                 Current
#7397
     Baseline
#7383
No change  JS 252.66KiB 252.66KiB
Improvement  Other 94.33KiB (-2.78%) 97.02KiB
No change  CSS 35.05KiB 35.05KiB

Bundle analysis reportBranch fix/replaceAllProject dashboard


Generated by RelativeCIDocumentationReport issue

@upupming upupming marked this pull request as ready for review January 27, 2026 05:30
@upupming upupming requested review from HuJean and hzy as code owners January 27, 2026 05:30
Fix 'TypeError: not a function' error caused by `replaceAll` not supported in ES5.

Signed-off-by: Yiming Li <yimingli.cs@gmail.com>
@upupming upupming merged commit 35f520a into main Jan 28, 2026
46 of 47 checks passed
@upupming upupming deleted the fix/replaceAll branch January 28, 2026 09:56
colinaaa pushed a commit that referenced this pull request Feb 1, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @lynx-js/motion@0.0.2

### Patch Changes

- Add initial support for `@lynx-js/motion`
([#1062](#1062))

## @lynx-js/react@0.116.2

### Patch Changes

- Fix "TypeError: not a function" error caused by `replaceAll` not
supported in ES5.
([#2142](#2142))

- Bump `swc_core` v56.
([#2154](#2154))

- Use `disableDeprecatedWarning` option to suppress BROKEN warnings
during compilation.
([#2157](#2157))

1. BROKEN: `getNodeRef`/`getNodeRefFromRoot`/`createSelectorQuery` on
component instance is broken and MUST be migrated in ReactLynx 3.0,
please use ref or lynx.createSelectorQuery instead.
2. BROKEN: `getElementById` on component instance is broken and MUST be
migrated in ReactLynx 3.0, please use ref or lynx.getElementById
instead.

- Fix memory leak by clearing list callbacks when \_\_DestroyLifetime
event is triggered.
([#2112](#2112))

## @lynx-js/rspeedy@0.13.3

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-rsbuild-server-middleware@0.19.7

## @lynx-js/qrcode-rsbuild-plugin@0.4.4

### Patch Changes

- Bump `@clack/prompts` v1.0
([#2171](#2171))

## @lynx-js/react-rsbuild-plugin@0.12.7

### Patch Changes

- Updated dependencies
\[[`92881e7`](92881e7),
[`1a5f2a1`](1a5f2a1)]:
    -   @lynx-js/template-webpack-plugin@0.10.3
    -   @lynx-js/css-extract-webpack-plugin@0.7.0
    -   @lynx-js/react-webpack-plugin@0.7.3
    -   @lynx-js/react-alias-rsbuild-plugin@0.12.7
    -   @lynx-js/use-sync-external-store@1.5.0
    -   @lynx-js/react-refresh-webpack-plugin@0.3.4

## @lynx-js/web-constants@0.19.7

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-worker-rpc@0.19.7

## @lynx-js/web-core@0.19.7

### Patch Changes

- feat: add browser config of lynx-view, now you can customize the
browser config of lynx-view:
([#2140](#2140))

        lynxView.browserConfig = {
          pixelRatio: 1,
          pixelWidth: 1234,
          pixelHeight: 5678,
        }

-   Updated dependencies \[]:
    -   @lynx-js/web-constants@0.19.7
    -   @lynx-js/web-mainthread-apis@0.19.7
    -   @lynx-js/web-worker-rpc@0.19.7
    -   @lynx-js/web-worker-runtime@0.19.7

## @lynx-js/web-core-wasm@0.0.2

### Patch Changes

- Updated dependencies
\[[`43fc7e7`](43fc7e7)]:
    -   @lynx-js/web-elements@0.11.1
    -   @lynx-js/web-worker-rpc@0.19.7

## @lynx-js/web-elements@0.11.1

### Patch Changes

- feat: add wheel event handling and corresponding tests for
x-foldview-ng
([#2145](#2145))

## @lynx-js/web-mainthread-apis@0.19.7

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-constants@0.19.7

## @lynx-js/web-worker-runtime@0.19.7

### Patch Changes

-   Updated dependencies \[]:
    -   @lynx-js/web-constants@0.19.7
    -   @lynx-js/web-mainthread-apis@0.19.7
    -   @lynx-js/web-worker-rpc@0.19.7

## @lynx-js/template-webpack-plugin@0.10.3

### Patch Changes

- Fix "Failed to load CSS update file" for lazy bundle
([#2150](#2150))

- Fix "TypeError: cannot read property 'call' of undefined" error of
lazy bundle HMR.
([#2146](#2146))

## create-rspeedy@0.13.3



## @lynx-js/react-alias-rsbuild-plugin@0.12.7



## upgrade-rspeedy@0.13.3



## @lynx-js/web-core-server@0.19.7



## @lynx-js/web-rsbuild-server-middleware@0.19.7



## @lynx-js/web-worker-rpc@0.19.7

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants