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

@lass-lang/plugin-utils

v0.1.0

Published

Shared utilities for Lass bundler plugins

Downloads

161

Readme

@lass-lang/plugin-utils

Shared utilities for Lass bundler plugins. Provides bundler-agnostic infrastructure for building Lass integration plugins.

Installation

pnpm add @lass-lang/plugin-utils

Overview

This package provides utilities shared across all Lass bundler plugins (Vite, Bun, etc.):

  • Virtual path conventions - Consistent .lass to .css path mapping
  • Import rewriting - Resolve relative imports for isolated execution
  • Constants - Shared extensions and patterns

API

Virtual Path Utilities

toVirtualCssPath(lassPath: string): string

Converts a .lass file path to its virtual CSS path.

import { toVirtualCssPath } from '@lass-lang/plugin-utils';

toVirtualCssPath('src/styles.lass');           // => 'src/styles.lass.css'
toVirtualCssPath('src/button.module.lass');    // => 'src/button.lass.module.css'

fromVirtualCssPath(virtualPath: string): string

Converts a virtual CSS path back to its .lass source path.

import { fromVirtualCssPath } from '@lass-lang/plugin-utils';

fromVirtualCssPath('src/styles.lass.css');         // => 'src/styles.lass'
fromVirtualCssPath('src/button.lass.module.css');  // => 'src/button.module.lass'

isVirtualCssPath(path: string): boolean

Checks if a path is a virtual CSS path (regular or module).

import { isVirtualCssPath } from '@lass-lang/plugin-utils';

isVirtualCssPath('styles.lass.css');         // => true
isVirtualCssPath('button.lass.module.css');  // => true
isVirtualCssPath('styles.css');              // => false

isVirtualModuleCssPath(path: string): boolean

Checks if a path is a virtual CSS Modules path.

import { isVirtualModuleCssPath } from '@lass-lang/plugin-utils';

isVirtualModuleCssPath('button.lass.module.css');  // => true
isVirtualModuleCssPath('styles.lass.css');         // => false

Import Rewriting

rewriteImportsForExecution(code: string, baseDir: string): string

Rewrites relative imports to absolute file:// URLs for isolated execution.

When executing transpiled Lass code in isolation (via data URL or temp file), relative imports won't resolve correctly. This function converts them to absolute URLs that work from any execution context.

import { rewriteImportsForExecution } from '@lass-lang/plugin-utils';

const code = `import tokens from './tokens.json';`;
const rewritten = rewriteImportsForExecution(code, '/project/src');
// => `import tokens from 'file:///project/src/tokens.json' with { type: 'json' };`

Features:

  • Converts relative paths to absolute file:// URLs
  • Auto-adds JSON import assertions when missing (required by runtimes)
  • Preserves existing import assertions

Path Utilities

normalizePath(path: string): string

Normalizes path separators for cross-platform compatibility.

import { normalizePath } from '@lass-lang/plugin-utils';

normalizePath('src\\styles\\main.lass');  // => 'src/styles/main.lass'

Constants

import {
  LASS_EXT,              // '.lass'
  VIRTUAL_CSS_EXT,       // '.lass.css'
  VIRTUAL_MODULE_CSS_EXT // '.lass.module.css'
} from '@lass-lang/plugin-utils';

Usage in Plugins

This package is used by official Lass bundler plugins:

Example Plugin Pattern

import { transpile } from '@lass-lang/core';
import {
  toVirtualCssPath,
  fromVirtualCssPath,
  isVirtualCssPath,
  rewriteImportsForExecution
} from '@lass-lang/plugin-utils';

// In resolve hook: redirect .lass imports to virtual .lass.css
if (path.endsWith('.lass')) {
  return toVirtualCssPath(path);
}

// In load hook: transpile and execute .lass files
if (isVirtualCssPath(id)) {
  const lassPath = fromVirtualCssPath(id);
  const source = await readFile(lassPath, 'utf-8');
  const { code } = transpile(source, { filename: lassPath });
  const executableCode = rewriteImportsForExecution(code, dirname(lassPath));
  const css = await executeModule(executableCode);
  return { contents: css, loader: 'css' };
}

Requirements

  • Node.js >= 20.0.0

License

MIT