Skip to content

fix(store): stop connecting the @Select decorator automatically - #2510

Merged
arturovt merged 1 commit into
masterfrom
fix/opt-in-select-decorator-support
Sep 2, 2026
Merged

fix(store): stop connecting the @Select decorator automatically#2510
arturovt merged 1 commit into
masterfrom
fix/opt-in-select-decorator-support

Conversation

@arturovt

@arturovt arturovt commented Sep 2, 2026

Copy link
Copy Markdown
Member

SelectFactory writes the request's Store into a module-level static so the
@Select getter can reach it without DI. On the server that static outlives the
request, retaining the whole state graph for the life of the process.
rootStoreInitializer() forced SelectFactory to exist on every
provideStore() / NgxsModule.forRoot(), whether or not @Select was used.

It is now opt-in, so apps that do not use @Select (the deprecated path) no
longer pay for it.

BREAKING CHANGES:

Apps using the deprecated @Select decorator must now connect it explicitly,
otherwise accessing a @Select property throws.

Standalone:

provideStore([CountriesState], withNgxsSelectDecoratorSupport());

NgModule:

@NgModule({
  imports: [
    NgxsModule.forRoot([CountriesState]),
    NgxsSelectDecoratorSupportModule.forRoot()
  ]
})
export class AppModule {}

Prefer migrating to store.select(), the functional select(), or
store.selectSignal():
https://ngxs.io/deprecations/select-decorator-deprecation

`SelectFactory` writes the request's `Store` into a module-level static so the
`@Select` getter can reach it without DI. On the server that static outlives the
request, retaining the whole state graph for the life of the process.
`rootStoreInitializer()` forced `SelectFactory` to exist on every
`provideStore()` / `NgxsModule.forRoot()`, whether or not `@Select` was used.

It is now opt-in, so apps that do not use `@Select` (the deprecated path) no
longer pay for it.

BREAKING CHANGES:

Apps using the deprecated `@Select` decorator must now connect it explicitly,
otherwise accessing a `@Select` property throws.

Standalone:

```ts
provideStore([CountriesState], withNgxsSelectDecoratorSupport());
```

NgModule:

```ts
@NgModule({
  imports: [
    NgxsModule.forRoot([CountriesState]),
    NgxsSelectDecoratorSupportModule.forRoot()
  ]
})
export class AppModule {}
```

Prefer migrating to `store.select()`, the functional `select()`, or
`store.selectSignal()`:
https://ngxs.io/deprecations/select-decorator-deprecation
@arturovt
arturovt merged commit ad22925 into master Sep 2, 2026
4 of 5 checks passed
@arturovt
arturovt deleted the fix/opt-in-select-decorator-support branch September 2, 2026 15:39
@bundlemon

bundlemon Bot commented Sep 2, 2026

Copy link
Copy Markdown

BundleMon

Unchanged files (6)
Status Path Size Limits
fesm2022/ngxs-store.mjs
131.38KB 118KB / +0.5%
fesm2022/ngxs-store-operators.mjs
16.81KB 16KB / +0.5%
fesm2022/ngxs-store-internals.mjs
14.85KB 15KB / +0.5%
fesm2022/ngxs-store-internals-testing.mjs
10.33KB 13KB / +0.5%
fesm2022/ngxs-store-plugins.mjs
5.39KB 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
45.92KB +1%

Final result: ❌

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@bundlemon

bundlemon Bot commented Sep 2, 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
6.1KB +0.5%
Plugins(fesm2022)[gzip]
router-plugin/fesm2022/ngxs-router-plugin.mjs
4.5KB +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
1.21KB +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
24.48KB +0.5%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@bundlemon

bundlemon Bot commented Sep 2, 2026

Copy link
Copy Markdown

BundleMon (Integration Projects)

Unchanged files (1)
Status Path Size Limits
Main bundles(Gzip)
hello-world-ng22/dist-integration/browser/mai
n-(hash).js
69.48KB +1%

No change in files bundle size

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

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