Skip to content

Commit

Permalink
refactor(storage-plugin): mark engine tokens as pure (#2249)
Browse files Browse the repository at this point in the history
`new` expressions are considered side-effectful. The `/* @__PURE__ */` hint tells the bundler
that `new InjectionToken` has no side effects and that the output of this expression can be safely
removed if unused. Therefore, if `LOCAL_STORAGE_ENGINE` is never used, it can be dropped.
  • Loading branch information
arturovt authored Nov 10, 2024
1 parent 699f0a0 commit d4388f5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ $ npm install @ngxs/store@dev
- Performance(store): Replace `instanceof Function` with `typeof` [#2247](https://github.com/ngxs/store/pull/2247)
- Refactor(store): Use `Object.is` as default equality check [#2245](https://github.com/ngxs/store/pull/2245)
- Refactor(router-plugin): Mark selectors as pure [#2248](https://github.com/ngxs/store/pull/2248)
- Refactor(storage-plugin): Mark engine tokens as pure [#2249](https://github.com/ngxs/store/pull/2249)

### 18.1.4 2024-10-23

Expand Down
4 changes: 2 additions & 2 deletions packages/storage-plugin/src/engines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ declare const ngDevMode: boolean;

const NG_DEV_MODE = typeof ngDevMode !== 'undefined' && ngDevMode;

export const LOCAL_STORAGE_ENGINE = new InjectionToken<StorageEngine | null>(
export const LOCAL_STORAGE_ENGINE = /* @__PURE__ */ new InjectionToken<StorageEngine | null>(
NG_DEV_MODE ? 'LOCAL_STORAGE_ENGINE' : '',
{
providedIn: 'root',
factory: () => (isPlatformBrowser(inject(PLATFORM_ID)) ? localStorage : null)
}
);

export const SESSION_STORAGE_ENGINE = new InjectionToken<StorageEngine | null>(
export const SESSION_STORAGE_ENGINE = /* @__PURE__ */ new InjectionToken<StorageEngine | null>(
NG_DEV_MODE ? 'SESSION_STORAGE_ENGINE' : '',
{
providedIn: 'root',
Expand Down

0 comments on commit d4388f5

Please sign in to comment.