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

@g-casau/rsfc-core

v1.1.0

Published

Zero-runtime-dependency RSFC parser and code generator

Readme

@g-casau/rsfc-core

Zero-dependency parser and code generator for React Single File Components (.rsfc).

This is the foundation package consumed by @g-casau/rsfc-vite-plugin, @g-casau/rsfc-webpack-loader, and @g-casau/rsfc-cli. You only need this directly if you're building a custom integration.

Installation

npm install @g-casau/rsfc-core

What is an .rsfc file?

A React Single File Component combines script, template, and styles in one file — similar to Vue SFCs.

<script setup>
import { useState } from "react";

const [count, setCount] = useState(0);
</script>

<template>
<div className={styles.container}>
  <p>Count: {count}</p>
  <button onClick={() => setCount(c => c + 1)}>+</button>
</div>
</template>

<style module>
.container { padding: 1rem; }
</style>

API

parse(source, options)

Parses an .rsfc file and returns an RsfcDescriptor.

import { parse } from "@g-casau/rsfc-core";

const descriptor = parse(source, { filename: "App.rsfc" });
// descriptor.scriptSetup?.content
// descriptor.template?.content
// descriptor.styles[]
// descriptor.errors[]

generate(descriptor)

Generates a JavaScript module from a parsed descriptor.

import { parse, generate } from "@g-casau/rsfc-core";

const descriptor = parse(source, { filename: "App.rsfc" });
const output = generate(descriptor);
// output.code          — JS string to emit
// output.map           — V3 source map
// output.virtualModules — style virtual modules for the bundler to resolve

compileCss(virtualModule)

Compiles a style virtual module using the appropriate preprocessor (sass, less, or stylus) based on its file extension. Returns raw CSS for plain .css modules. Throws a descriptive error if the required preprocessor is not installed.

import { compileCss } from "@g-casau/rsfc-core";

const css = await compileCss(vm); // vm is a VirtualModule from generate()

buildStyleIIFE(css, index)

Wraps compiled CSS in an SSR-safe IIFE that appends a <style> tag to the DOM. Used by webpack and CLI integrations where Vite's virtual module pipeline is unavailable.

import { buildStyleIIFE } from "@g-casau/rsfc-core";

const iife = buildStyleIIFE(".btn { color: red }", 0);

Supported block types

| Block | Description | |---|---| | <script> | Module-level code (exports, loaders) | | <script setup> | Component setup — imports are hoisted, rest goes into the component function | | <template> | JSX template | | <style> | Plain CSS | | <style module> | CSS Modules — exports a scoped class map | | <style lang="scss\|sass\|less\|stylus"> | CSS preprocessors (requires peer dep) | | <docs> | Documentation block — parsed but not emitted |

Types

import type {
  RsfcDescriptor,
  RsfcBlock,
  StyleBlock,
  CustomBlock,
  GeneratedOutput,
  VirtualModule,
  RsfcParseError,
} from "@g-casau/rsfc-core";

License

MIT