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 🙏

© 2024 – Pkg Stats / Ryan Hefner

rescript-atdgen-generator

v0.1.1

Published

Atdgen prebuilt binaries for 3 major OS platforms.

Downloads

145

Readme

rescript-atdgen-generator

Atdgen prebuilt binaries for 3 major OS platforms.

This is capped at version 2.15.0, after which BuckleScript support (which ReScript relies on) was removed. https://github.com/ahrefs/atd/pull/375

If atd proves to be a popular tool for ReScript projects it can be restored fairly easily.

Getting started

(Prefer example? Check the test folder)

Runtime library installation

This tool will not work without a library that implements the ATD BuckleScript runtime API. A ReScript implementation is in progress, in the meantime bs-atdgen-codec-runtime still works - but not on ReScript 11.

Generator installation

With yarn or npm:

yarn add -D rescript-atdgen-generator
npm i -D rescript-atdgen-generator

We then need to define atd as a generator in rescript.json. For compatibility with windows development, the recommended approach is a direct reference to atdgen.exe. Generators are run in the lib/bs folder context, so a leading ../.. is required:

"generators": [
  {
    "name": "atd_types",
    "command": "../../node_modules/.bin/atdgen -t $in"
  },
  {
    "name": "atd_runtime",
    "command": "../../node_modules/.bin/atdgen -bs $in"
  }
],

If windows compatibility is not required, or for more complex monorepo scenarios, these commands can be replaced by the shorter npx atdgen -t $in and npx atdgen -bs $in (or using yarn run instead of npx). This approach is however a little slower due to the extra nodejs invocations.

Now that the generator is defined, add the files that need to be processed to sources. ReScript requires a manual definition for every file that the generator will process. For atd, this means a pair of entries must be defined for every .atd file in your project. Both "types" and "runtime" representations are required, and each generates both an interface and a code file.

"sources": {
  // given a `my-generated-source` folder, define generators for the file `meetup.atd` in that folder.
  // it is not necessary to have a dedicated folder for generated sources,
  // but it does help avoid generated files getting in the way.
  {
    "dir": "my-generated-source",
    "generators": [
      {
        "name": "atd_types",
        "edge": ["meetup_t.ml", "meetup_t.mli", ":", "meetup.atd"]
      },
      {
        "name": "atd_runtime",
        "edge": ["meetup_bs.ml", "meetup_bs.mli", ":", "meetup.atd"]
      }
    ]
  },
  // ...other source folders
  "src1",
  "src2"
},

The syntax here is a little weird, the edge array defines a build syntax recognised by the compiler. The order of this array is very important; it must be the two files that atd generates, a :, and then the source file that serves as the input to the generator command.

Updates to the source file are what the compiler uses to determine whether the generator needs to run. The generated files can freely be ignored by source control.

License and Credits

All code is licensed as MIT. See LICENSE.

This project was transferred to me by Javier Chávarri after it was abandoned following the switch of ahrefs to Melange.