deprecating window.guardian
#444
Replies: 3 comments 9 replies
-
|
Beta Was this translation helpful? Give feedback.
-
I really like this idea. I think there should be automatic deprecation built-in if we are to prevent this from growing without end. Would it be possible to have a |
Beta Was this translation helpful? Give feedback.
-
Since extracting the commercial bundle into its own executable script, @guardian/commercial-dev have been interested in ensuring we are not bundling dependencies that are already available in platform bundles, notably Raven, Ophan and potentially the AB testing framework. Would // graun.standard.js
import raven from `raven-js`;
import { hydrateEnv } from '@guardian/libs';
hydrateEnv({
raven
});
// commercial.bundle.js
import { env } from '@guardian/libs';
env.raven.captureException(error, { tags }); |
Beta Was this translation helpful? Give feedback.
-
Putting page config on a global (
window.guardian
) is inherently brittle. Any code that runs on the page can change it however it likes.It also means to meaningfully type it we have describe a platform global in a way we cannot guarantee to the consumer, thus breaking type safety (even if a prop is there we don't know for sure that its value is what we said it would be in the definition).
Proposal
@guardian/libs
(env
) that mimics current use ofwindow.guardian
window.guardian
with this objectwindow
directlyExample
Implementation
Usage
Issues
What if there are multiple instances of
@guardian/libs
on the page?Beta Was this translation helpful? Give feedback.
All reactions