/
githubmirror
/
webpack
Обзор
Документация
Войти
/
githubmirror
/
webpack
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
examples/universal/env.js
20 строк
562 B
Sebastian Beltran
feat(universal): add example for universal target with ESM support (#21244)
23 июн 2026, 10:12
Не верифицирован
23 июн 2026, 10:12
2e43eb4
Код
Авторство
О чём код?
// Universal feature detection. The bundle assumes no platform-specific global at // build time, so the environment is resolved at runtime instead. Deno and Bun // are checked before Node because both also expose a Node-compatible `process`. export function platform() { if (typeof Deno !== "undefined") return "Deno"; if (typeof Bun !== "undefined") return "Bun"; if (typeof window !== "undefined") return "browser"; if ( typeof process !== "undefined" && process.versions && process.versions.node ) { return "Node.js"; } return "unknown"; }