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

glimmer-jscodeshift

v1.0.2

Published

Parser, type definitions, and utilities for working with GJS/GST templates in jscodeshift scripts.

Readme

Glimmer Jscodeshift

This package provides a plugin for AST Types as well as a parser for jscodeshift to parse GJS and JTS files including their embedded templates.

[!NOTE] ember-template-recast is used to parse template content of files, however the type strings for AST Nodes have to be prepended with Glimmer to avoid conflicts with existing types in ast-types. For best use, use TypeScript and use the exported g object with JSCodeShift and recast comparison operators to find nodes and avoid confusion over the type string differences.

Installation

pnpm install -D glimmer-jscodeshift jscodeshift

Usage In Programatic JSCodeShift Scripts

import j from 'jscodeshift';
import { glimmerCodeshift, print } from 'glimmer-jscodeshift';

const fileContents = `
import { service } from '@ember/service';
import Component from '@glimmer/component';

export class ExampleComponent extends Component {
  @service('store') store;
  property = true;

   ask() {
    return 'hello world'
  }

  <template>
<h2>My Component</h2>
  </template>
}`;

const g = glimmerCodeshift(j);

const doc = g(fileContents);

doc.find(g.GlimmerTextNode).forEach((element) => {
  if (element.node.chars.trim()) {
    element.node.chars = element.node.chars.toUpperCase();
  }
});

console.log(print(doc));

Ember Parser

The EmberParser class declares a parse method that jscodeshift can use to parse file contents. When calling new, there is an optional argument to pass a different jscodeshift parser which will be used to parse the non-template parts of the GTS/GJS file. When omitted, this will use the default parser from jscodeshift.

// Example using the babylon parser instead of ts
import { EmberParser } from 'glimmer-jscodeshift';

const parser = new EmberParser('babylon');

AST Types

When working with the ast-types package, you need to be able to setup the proper def calls for the local instance of ast-types used by recast or jscodeshift. This package exports a GlimmerPlugin function that will add defs to an ast-types registry and return typed named nodes for Glimmer templates.

import { EmberParser } from 'glimmer-jscodeshift';
import { use } from 'ast-types';

const glimmerTypes = use(GlimmerPlugin);

You can see the full list of available nodes in the named-types.ts file.

Print

Since this mixes AST node types from raw JS recast and ember-template-recast, using .toSource() on the jscodeshift collection will not work as expected. This package exports a print function that can be used to print the modified AST back to source code.

import { print } from 'glimmer-jscodeshift';

// doc is a jscodeshift collection or recast node
console.log(print(doc));