Skip to content

fix(store): expose originalFn on memoized selector in dev mode for clearer warnings#2448

Merged
arturovt merged 1 commit into
masterfrom
fix/expose_originalFn
Jun 8, 2026
Merged

fix(store): expose originalFn on memoized selector in dev mode for clearer warnings#2448
arturovt merged 1 commit into
masterfrom
fix/expose_originalFn

Conversation

@arturovt

@arturovt arturovt commented Jun 8, 2026

Copy link
Copy Markdown
Member

Gate the reset and originalFn properties on the memoized function behind ngDevMode, so they are tree-shaken in production builds. In dev mode, expose the original (unwrapped) selector function via selector.originalFn, and use it in the warnOnNewReferenceWithIdenticalValue console.error so the logged function is navigable in DevTools rather than the internal memoized wrapper. The && originalFn guard also implicitly suppresses the warning in production where the property is not set.

Add unit tests covering: warning fires when a new reference with an identical value is returned, no warning when the option is not configured, and no warning when the value genuinely changes.

@nx-cloud

nx-cloud Bot commented Jun 8, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit b7048d6

Command Status Duration Result
nx run-many --target=test --all --configuration... ✅ Succeeded 3m 4s View ↗
nx run-many --target=lint --all --exclude=creat... ✅ Succeeded 6s View ↗
nx lint-types store ✅ Succeeded <1s View ↗
nx run-many --target=build --all ✅ Succeeded 1m 37s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-06-08 19:53:35 UTC

@pkg-pr-new

pkg-pr-new Bot commented Jun 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

@ngxs/devtools-plugin

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

@ngxs/form-plugin

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

@ngxs/hmr-plugin

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

@ngxs/router-plugin

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

@ngxs/storage-plugin

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

@ngxs/store

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

@ngxs/websocket-plugin

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

commit: b7048d6

@bundlemon

bundlemon Bot commented Jun 8, 2026

Copy link
Copy Markdown

BundleMon

Files updated (2)
Status Path Size Limits
fesm2022/ngxs-store.mjs
116.56KB (+96B +0.08%) 114KB / +0.5%
fesm2022/ngxs-store-internals.mjs
12.79KB (+78B +0.6%) 15KB / +0.5%
Unchanged files (4)
Status Path Size Limits
fesm2022/ngxs-store-operators.mjs
15.7KB 16KB / +0.5%
fesm2022/ngxs-store-internals-testing.mjs
10.32KB 13KB / +0.5%
fesm2022/ngxs-store-plugins.mjs
2.37KB 3KB / +0.5%
fesm2022/ngxs-store-experimental.mjs
574B 2KB / +0.5%

Total files change +174B +0.11%

Groups updated (1)
Status Path Size Limits
@ngxs/store(fesm2022)[gzip]
./fesm2022/*.mjs
39.54KB (+29B +0.07%) +1%

Final result: ❌

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@bundlemon

bundlemon Bot commented Jun 8, 2026

Copy link
Copy Markdown

BundleMon (NGXS Plugins)

Unchanged files (9)
Status Path Size Limits
Plugins(fesm2022)[gzip]
storage-plugin/fesm2022/ngxs-storage-plugin.m
js
4.17KB +0.5%
Plugins(fesm2022)[gzip]
router-plugin/fesm2022/ngxs-router-plugin.mjs
3.43KB +0.5%
Plugins(fesm2022)[gzip]
hmr-plugin/fesm2022/ngxs-hmr-plugin.mjs
2.78KB +0.5%
Plugins(fesm2022)[gzip]
websocket-plugin/fesm2022/ngxs-websocket-plug
in.mjs
2.61KB +0.5%
Plugins(fesm2022)[gzip]
form-plugin/fesm2022/ngxs-form-plugin.mjs
2.51KB +0.5%
Plugins(fesm2022)[gzip]
devtools-plugin/fesm2022/ngxs-devtools-plugin
.mjs
2.26KB +0.5%
Plugins(fesm2022)[gzip]
logger-plugin/fesm2022/ngxs-logger-plugin.mjs
2.07KB +0.5%
Plugins(fesm2022)[gzip]
storage-plugin/fesm2022/ngxs-storage-plugin-i
nternals.mjs
1004B +0.5%
Plugins(fesm2022)[gzip]
router-plugin/fesm2022/ngxs-router-plugin-int
ernals.mjs
453B +0.5%

No change in files bundle size

Unchanged groups (1)
Status Path Size Limits
All Plugins(fesm2022)[gzip]
./-plugin/fesm2022/.mjs
21.25KB +0.5%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@bundlemon

bundlemon Bot commented Jun 8, 2026

Copy link
Copy Markdown

BundleMon (Integration Projects)

Files updated (1)
Status Path Size Limits
Main bundles(Gzip)
hello-world-ng21/dist-integration/browser/mai
n-(hash).js
67.97KB (-17B -0.02%) +1%

Total files change -17B -0.02%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

…earer warnings

Gate the `reset` and `originalFn` properties on the memoized function behind
`ngDevMode`, so they are tree-shaken in production builds. In dev mode, expose
the original (unwrapped) selector function via `selector.originalFn`, and use
it in the `warnOnNewReferenceWithIdenticalValue` console.error so the logged
function is navigable in DevTools rather than the internal memoized wrapper.
The `&& originalFn` guard also implicitly suppresses the warning in production
where the property is not set.

Add unit tests covering: warning fires when a new reference with an identical
value is returned, no warning when the option is not configured, and no warning
when the value genuinely changes.
@arturovt arturovt force-pushed the fix/expose_originalFn branch from 0070610 to b7048d6 Compare June 8, 2026 19:44
@arturovt arturovt marked this pull request as ready for review June 8, 2026 21:04
@arturovt arturovt merged commit 842513d into master Jun 8, 2026
13 of 14 checks passed
@arturovt arturovt deleted the fix/expose_originalFn branch June 8, 2026 21:04
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.

1 participant