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

interpret

v3.1.1

Published

A dictionary of file extensions and associated module loaders.

Downloads

84,717,103

Readme

interpret

NPM version Downloads Build Status Coveralls Status

A dictionary of file extensions and associated module loaders.

What is it

This is used by Liftoff to automatically require dependencies for configuration files, and by rechoir for registering module loaders.

How to use it

Consumers should use the exported extensions or jsVariants object to determine which module should be loaded for a given extension. If a matching extension is found, consumers should do the following:

  1. If the value is null, do nothing.
  2. If the value is a string, try to require it.
  3. If the value is an object, try to require the module property. If successful, the register property (a function) should be called with the module passed as the first argument. Advanced: An optional second argument can be provided to replace the default configuration for a hook.
  4. If the value is an array, iterate over it, attempting step #2 or #3 until one of the attempts does not throw.

API

This module provides two top-level properties: extensions and jsVariants.

Note: This module does not depend on any of the loaders it recommends; instead, end-users are expected to install the hooks they want to use for the file types they want to use. See supported extensions and their hooks in the sections below.

extensions

A mapping of file extensions to modules which provide a require.extensions loader.

File extension keys are all in the format of '.foo' or '.foo.bar' and module loader values are either null if the loader should fallthrough to node's loader, or a string representing the module to be required, an object of { module: 'foobar', register: function }, or an array containing those strings and/or objects.

A sample of an entry containing multiple hooks would look like:

{
  '.ts': [
    'ts-node/register',
    'sucrase/register/ts',
    {
      module: '@babel/register',
      register: function(hook) {
        hook({
          extensions: '.ts',
          rootMode: 'upward-optional',
          ignore: [ignoreNonBabelAndNodeModules],
        });
      },
    },
  ],
}

Supported extensions and their hooks

.babel.js:
  - '@babel/register'
.babel.jsx:
  - '@babel/register'
.babel.ts:
  - '@babel/register'
.babel.tsx:
  - '@babel/register'
.cjs:
  - interpret/cjs-stub
.coffee:
  - coffeescript/register
.coffee.md:
  - coffeescript/register
.cts:
  - ts-node/register
.esbuild.js:
  - esbuild-register/dist/node
.esbuild.jsx:
  - esbuild-register/dist/node
.esbuild.ts:
  - esbuild-register/dist/node
.esbuild.tsx:
  - esbuild-register/dist/node
.esm.js:
  - esm
.js:
  - built-in node.js loader
.json:
  - built-in node.js loader
.json5:
  - json5/lib/register
.jsx:
  - '@babel/register'
  - sucrase/register/jsx
.litcoffee:
  - coffeescript/register
.mdx:
  - '@mdx-js/register'
.mjs:
  - interpret/mjs-stub
.node:
  - built-in node.js loader
.sucrase.js:
  - sucrase/dist/register
.sucrase.jsx:
  - sucrase/dist/register
.sucrase.ts:
  - sucrase/dist/register
.sucrase.tsx:
  - sucrase/dist/register
.swc.js:
  - '@swc/register'
.swc.jsx:
  - '@swc/register'
.swc.ts:
  - '@swc/register'
.swc.tsx:
  - '@swc/register'
.toml:
  - toml-require
.ts:
  - ts-node/register
  - sucrase/register/ts
  - '@babel/register'
  - esbuild-register/dist/node
  - '@swc/register'
.tsx:
  - ts-node/register
  - sucrase/register/tsx
  - '@babel/register'
  - esbuild-register/dist/node
  - '@swc/register'
.yaml:
  - yaml-hook/register
.yml:
  - yaml-hook/register

jsVariants

The jsVariants is the same mapping as above, but only include the extensions which are variants of JavaScript.

Supported extensions and their hooks

.babel.js:
  - '@babel/register'
.babel.jsx:
  - '@babel/register'
.babel.ts:
  - '@babel/register'
.babel.tsx:
  - '@babel/register'
.cjs:
  - interpret/cjs-stub
.coffee:
  - coffeescript/register
.coffee.md:
  - coffeescript/register
.esbuild.js:
  - esbuild-register/dist/node
.esbuild.jsx:
  - esbuild-register/dist/node
.esbuild.ts:
  - esbuild-register/dist/node
.esbuild.tsx:
  - esbuild-register/dist/node
.esm.js:
  - esm
.js:
  - built-in node.js loader
.jsx:
  - '@babel/register'
  - sucrase/register/jsx
.litcoffee:
  - coffeescript/register
.mdx:
  - '@mdx-js/register'
.mjs:
  - interpret/mjs-stub
.sucrase.js:
  - sucrase/dist/register
.sucrase.jsx:
  - sucrase/dist/register
.sucrase.ts:
  - sucrase/dist/register
.sucrase.tsx:
  - sucrase/dist/register
.swc.js:
  - '@swc/register'
.swc.jsx:
  - '@swc/register'
.swc.ts:
  - '@swc/register'
.swc.tsx:
  - '@swc/register'
.ts:
  - ts-node/register
  - sucrase/register/ts
  - '@babel/register'
  - esbuild-register/dist/node
  - '@swc/register'
.tsx:
  - ts-node/register
  - sucrase/register/tsx
  - '@babel/register'
  - esbuild-register/dist/node
  - '@swc/register'

License

MIT