Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement $app/env #251

Merged
merged 2 commits into from
Dec 10, 2020
Merged

Implement $app/env #251

merged 2 commits into from
Dec 10, 2020

Conversation

Rich-Harris
Copy link
Member

This adds an $app/env module that exports browser and dev:

<script>
  import { browser, dev } from '$app/env';
</script>

<p>Hello from the {browser ? 'client' : 'server'} in {dev ? 'dev' : 'prod'} mode!</p>

Right now, browser = typeof window !== 'undefined' which is brittle (would fail if someone did global.window = 42). Ideally we'd use import.meta.env.SSR instead but there's a blocker (#194).

I'm anticipating that amp would go here too if we do #160.

@Rich-Harris Rich-Harris merged commit ed6b8fd into master Dec 10, 2020
@Rich-Harris Rich-Harris deleted the env branch December 10, 2020 19:09
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