Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@arturovt
Copy link
Member

@arturovt arturovt commented Sep 7, 2025

Previously, the router plugin always patched NGXS state on every router event, even if the new router snapshot was identical to the current one. This caused unnecessary updates to the internal NGXS state signal, triggering recomputations of selectSignal selectors and extra Angular change detection cycles.

With this change, we now compare the current and incoming router state (trigger, navigationId, and serialized snapshot). If they are equal, the state update is skipped. This avoids redundant signal emissions, leading to fewer recomputations and improved performance in large apps.

…router snapshots

Previously, the router plugin always patched NGXS state on every router
event, even if the new router snapshot was identical to the current one.
This caused unnecessary updates to the internal NGXS state signal,
triggering recomputations of `selectSignal` selectors and extra Angular
change detection cycles.

With this change, we now compare the current and incoming router state
(trigger, navigationId, and serialized snapshot). If they are equal,
the state update is skipped. This avoids redundant signal emissions,
leading to fewer recomputations and improved performance in large apps.
@nx-cloud
Copy link

nx-cloud bot commented Sep 7, 2025

View your CI Pipeline Execution ↗ for commit 348f67d

Command Status Duration Result
nx run-many --target=test --all --configuration... ✅ Succeeded 29s View ↗
nx run-many --target=lint --all --configuration... ✅ Succeeded 4s View ↗
nx lint-types store ✅ Succeeded <1s View ↗
nx run-many --target=build --all ✅ Succeeded 32s View ↗

☁️ Nx Cloud last updated this comment at 2025-09-07 21:53:07 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 7, 2025

Open in StackBlitz

@ngxs/devtools-plugin

npm i https://pkg.pr.new/@ngxs/devtools-plugin@2372

@ngxs/form-plugin

npm i https://pkg.pr.new/@ngxs/form-plugin@2372

@ngxs/hmr-plugin

npm i https://pkg.pr.new/@ngxs/hmr-plugin@2372

@ngxs/router-plugin

npm i https://pkg.pr.new/@ngxs/router-plugin@2372

@ngxs/storage-plugin

npm i https://pkg.pr.new/@ngxs/storage-plugin@2372

@ngxs/store

npm i https://pkg.pr.new/@ngxs/store@2372

@ngxs/websocket-plugin

npm i https://pkg.pr.new/@ngxs/websocket-plugin@2372

commit: 348f67d

@bundlemon
Copy link

bundlemon bot commented Sep 7, 2025

BundleMon

Unchanged files (6)
Status Path Size Limits
fesm2022/ngxs-store.mjs
104.27KB 105KB / +0.5%
fesm2022/ngxs-store-internals.mjs
13.46KB 15KB / +0.5%
fesm2022/ngxs-store-internals-testing.mjs
10.32KB 13KB / +0.5%
fesm2022/ngxs-store-operators.mjs
6.05KB 7KB / +0.5%
fesm2022/ngxs-store-plugins.mjs
2.37KB 3KB / +0.5%
fesm2022/ngxs-store-experimental.mjs
574B 2KB / +0.5%

No change in files bundle size

Unchanged groups (1)
Status Path Size Limits
@ngxs/store(fesm2022)[gzip]
./fesm2022/*.mjs
33.67KB +1%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@bundlemon
Copy link

bundlemon bot commented Sep 7, 2025

BundleMon (NGXS Plugins)

Files updated (1)
Status Path Size Limits
Plugins(fesm2022)[gzip]
router-plugin/fesm2022/ngxs-router-plugin.mjs
3.4KB (+479B +15.96%) +0.5%
Unchanged files (8)
Status Path Size Limits
Plugins(fesm2022)[gzip]
storage-plugin/fesm2022/ngxs-storage-plugin.m
js
4.05KB +0.5%
Plugins(fesm2022)[gzip]
hmr-plugin/fesm2022/ngxs-hmr-plugin.mjs
2.72KB +0.5%
Plugins(fesm2022)[gzip]
websocket-plugin/fesm2022/ngxs-websocket-plug
in.mjs
2.58KB +0.5%
Plugins(fesm2022)[gzip]
form-plugin/fesm2022/ngxs-form-plugin.mjs
2.47KB +0.5%
Plugins(fesm2022)[gzip]
devtools-plugin/fesm2022/ngxs-devtools-plugin
.mjs
2.23KB +0.5%
Plugins(fesm2022)[gzip]
logger-plugin/fesm2022/ngxs-logger-plugin.mjs
2.03KB +0.5%
Plugins(fesm2022)[gzip]
storage-plugin/fesm2022/ngxs-storage-plugin-i
nternals.mjs
947B +0.5%
Plugins(fesm2022)[gzip]
router-plugin/fesm2022/ngxs-router-plugin-int
ernals.mjs
453B +0.5%

Total files change +479B +2.3%

Groups updated (1)
Status Path Size Limits
All Plugins(fesm2022)[gzip]
./-plugin/fesm2022/.mjs
20.84KB (+479B +2.3%) +0.5%

Final result: ❌

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@bundlemon
Copy link

bundlemon bot commented Sep 7, 2025

BundleMon (Integration Projects)

Files updated (1)
Status Path Size Limits
Main bundles(Gzip)
hello-world-ng20/dist-integration/browser/mai
n-(hash).js
67.2KB (+54B +0.08%) +1%

Total files change +54B +0.08%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@arturovt arturovt marked this pull request as ready for review September 7, 2025 22:04
@arturovt arturovt merged commit aa28942 into master Sep 7, 2025
10 of 13 checks passed
@arturovt arturovt deleted the fix/router-plugin-equal branch September 7, 2025 23:08
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.

2 participants