Registry / testing / ember-tracked-storage-polyfill

ember-tracked-storage-polyfill

JSON →
library1.0.1jsnpmunverified

Polyfills the tracked storage primitive from Ember/Glimmer, enabling use of createStorage, getValue, and setValue in Ember.js apps before the native API is available. Latest version: 1.0.1. Released as an ember-addon, it avoids the complexity of polyfilling exact Ember import paths, ensuring compatibility with Embroider. Supports Ember.js v3.15+, Ember CLI v3.20+, Node.js 12 or 14+. Ships TypeScript types. Once Ember supports the primitive natively, this polyfill will re-export from @glimmer/tracking, making migration seamless.

npm install ember-tracked-storage-polyfill
INSTALL
IMPORT
SIG · EMBER-TRACKED-STOR
E
ember-tracked-storage-polyfill
testingjavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

createStorage
import { createStorage, getValue, setValue } from 'ember-tracked-storage-polyfill'
import { createStorage } from '@glimmer/tracking/primitives/storage'
Do NOT import from @glimmer/tracking primitives; those paths are not polyfilled for compatibility with Embroider.
createStorage (require)
const { createStorage } = require('ember-tracked-storage-polyfill');
CJS require is available, but ESM imports are preferred.
Types
import type { Storage } from 'ember-tracked-storage-polyfill';
TypeScript types are shipped but Storage type is not explicitly documented; use type inference from createStorage.

Demonstrates creating a tracked storage cell, getting and setting its value.

import { createStorage, getValue, setValue } from 'ember-tracked-storage-polyfill'; let storage = createStorage(true); console.log(getValue(storage)); // true setValue(storage, false); console.log(getValue(storage)); // false
Debug
Known issues
gotchaDo not import from @glimmer/tracking/primitives/storage; the polyfill does not support that path and will break under Embroider.
fix
Import from 'ember-tracked-storage-polyfill' instead.
affects: >=1.0.0
gotchaThe polyfill only works in Ember.js v3.15 or above. Using it in older Ember versions will cause runtime errors.
fix
Upgrade Ember.js to v3.15+ or do not use this polyfill.
affects: >=1.0.0
gotchaNode.js versions 12 and 14 are supported, but Node 12 is end-of-life and may cause security issues.
fix
Use Node 14 or later.
affects: >=1.0.0
deprecatedThe polyfill will be deprecated once Ember natively supports tracked storage. Migrate to native imports when available.
fix
When Ember 4.x ships tracked storage, switch imports to '@glimmer/tracking/primitives/storage'.
affects: >=1.0.0
Errors
Common errors & fixes
Could not find module `@glimmer/tracking/primitives/storage` imported from
Importing from the wrong path that the polyfill does not polyfill.
fix
Use `import { createStorage } from 'ember-tracked-storage-polyfill'` instead.
Uncaught TypeError: storage is not a function
Using `storage()` directly instead of `getValue(storage)`.
fix
Use `getValue(storage)` and `setValue(storage, value)` to access or mutate the storage cell.
Assertion Failed: You can only track values that are provided by the tracked storage primitive
Passing a non-storage object (e.g., a plain variable) to `getValue` or `setValue`.
fix
Ensure you pass a storage cell created by `createStorage`.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Resources
ember-tracked-storage-polyfill — npm install ember-tracked-storage-polyfill · libregistry