npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@esmap/guard

v0.1.0

Published

CSS isolation and global pollution guards for micro-frontends

Readme

@esmap/guard

CSS isolation and global pollution detection for micro-frontends.

Prevents MFE styles from leaking into other apps and detects unexpected global variable mutations. Zero external dependencies.

Installation

pnpm add @esmap/guard

CSS Scoping

Adds an app-specific attribute to CSS selectors for style isolation:

import { applyCssScope, removeCssScope, scopeCssText } from '@esmap/guard';

// Apply CSS scope to a DOM element
const scopedRoot = applyCssScope(containerElement, {
  prefix: 'checkout', // adds data-esmap-scope="checkout" attribute
});

// Remove scope
removeCssScope(containerElement, { prefix: 'checkout' });

// Transform CSS text only (no DOM required)
const scoped = scopeCssText('.btn { color: red; }', 'checkout');
// -> '[data-esmap-scope="checkout"] .btn{ color: red; }'

Handles @media, @keyframes, and other at-rules correctly.

Global Pollution Detection

Monitors whether MFEs add unexpected properties to window:

import { createGlobalGuard, snapshotGlobals, diffGlobals } from '@esmap/guard';

// Automatic monitoring via polling
const guard = createGlobalGuard({
  allowList: ['__REDUX_DEVTOOLS__'], // globals to ignore
  interval: 1000, // polling interval in ms (default: 1000)
  onViolation: (violation) => {
    console.warn(`Global pollution: ${violation.property} (${violation.type})`);
  },
});

// Manually trigger an immediate check
guard.check();

// Stop monitoring and get list of added globals
const addedGlobals = guard.dispose();

// Manual one-shot comparison
const before = snapshotGlobals();
// ... run MFE ...
const newGlobals = diffGlobals(before); // returns string[] of new global keys

Style Isolation

Per-MFE style context with automatic scoping and dynamic style observation:

import { createStyleIsolation } from '@esmap/guard';

const isolation = createStyleIsolation({
  appName: 'checkout',
  container: document.getElementById('checkout-root')!,
  strategy: 'attribute', // 'attribute' (default) or 'shadow'
  observeDynamic: true, // watch for dynamically added styles
});

// Query
isolation.getScopedCount(); // number of scoped stylesheets

// Re-scope all styles (e.g., after DOM changes)
isolation.refresh();

// Cleanup — stops observer and removes scoping
isolation.destroy();

Style Collector

Tracks and cleans up <style> and <link> tags dynamically added by MFEs:

import { createStyleCollector } from '@esmap/guard';

const collector = createStyleCollector();

// Start tracking styles for a specific app
collector.startCapture('checkout');

// MFE runs (dynamically adds style/link tags)

// Stop tracking and get captured elements
const capturedStyles = collector.stopCapture('checkout');

// Query styles for an app
collector.getStyles('checkout');

// Remove all styles for an app from the DOM
collector.removeStyles('checkout');

// Cleanup everything
collector.destroy();