@browser-compat/runtime
v0.1.2
Published
Small runtime feature detection, class injection, and reporting for browser-compat.
Downloads
149
Readme
@browser-compat/runtime
Small browser runtime for the Browser Compat toolkit.
Browser Compat helps applications generate browser compatibility manifests from
their own browserslist targets, check those manifests in CI, and use the
result at runtime through small framework adapters.
What This Package Does
@browser-compat/runtime reads a compatibility manifest, validates it, detects
declared features, injects compat-* classes, and can report the resulting
state asynchronously.
Use this package directly when your application does not use React. React apps
usually use @browser-compat/react, which depends on this package.
Installation
npm install @browser-compat/runtimeUsage
import { initCompatRuntime } from "@browser-compat/runtime";
import manifest from "../generated/browser-compat.manifest.json";
const state = await initCompatRuntime({ manifest });
if (state.decision.status === "unsupported") {
// Render an unsupported-browser fallback.
}You can also load the manifest by URL:
const state = await initCompatRuntime({
manifestUrl: "/browser-compat.manifest.json"
});Related Packages
@browser-compat/cligenerates manifests and reports.@browser-compat/reactexposes runtime state to React apps.@browser-compat/coreprovides shared manifest types and validation.
Full documentation: https://github.com/relaxcloud-cn/browser-compat-package
