dev
import { deprecate } from '@bbc/front-end-kit/js/utils/dev';
Development utilities for deprecation warnings and debugging.
deprecate(key, message, replacement, removalVersion)
Emits a styled console.warn deprecation notice once per unique key. Subsequent calls with the same key are silently ignored, so the warning only appears once per session regardless of how many times the deprecated code path is hit.
Parameters
key(string): A unique identifier for this deprecation (e.g. the old import path). Used to deduplicate warnings.message(string): Human-readable description of what is deprecated.replacement(string): The recommended replacement code or import path shown in the warning.removalVersion(string, default'2.0.0'): The version in which the deprecated feature will be removed.
Returns
undefined
Example
import { deprecate } from '@bbc/front-end-kit/js/utils/dev';
deprecate(
'@bbc/front-end-kit/js/utils/gsap-scroll',
'gsap-scroll.js is deprecated.',
"import { gsap } from 'gsap'; // use GSAP directly",
'2.0.0'
);
The warning is printed once with orange bold styling in the browser console and includes:
- The deprecation message
- The recommended replacement
- The removal version
- A link to the migration guide