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

requirex

v0.3.3

Published

A different kind of module loader

Downloads

148

Readme

npm version Travis status AppVeyor status dependency status

requirex is a small install size, free license, tightly coded and opinionated toolchain replacing npm and webpack. It runs entirely on your own machine in the browser, or in Node.js. It saves lots of both time and disk space.

It removes unnecessary complexity from modern JavaScript development, making it easy to start new projects and test ideas. There's no need to install or configure anything to start coding. You can even use npm packages without having Node.js.

For the quickest start, see the optional instant online project creatorTODO (you can continue development locally and offline).

Basic idea

If you write:

import React from 'react';

requirex guesses it's ES6 or TypeScript and wants the latest react from npm. So it fetches React (unless already installed locally using npm) from UNPKG or jsDelivr and transpiles your code using the TypeScript compiler (also works for ES6, much like Babel).

If the compiler is not installed locally, it fetches that too. Any npm package can be imported in the same way and generally obvious, manual tooling steps in JavaScript development have been automated away to save your time and effort.

There's lots of automatic :sparkles: magic :sparkles: inside to make it run smooth and fast: caching, bundling, module resolution, transpiling, AMD / CommonJS support, source maps, isomorphic fetch... So read on:

Table of contents

Skip Webpack

requirex is a radical change to JavaScript development philosophy. Compare:

Automating the common development steps gets you started faster. If the project grows more complex, you can switch to Webpack later without wasting any effort spent because requirex can automatically generate compatible configuration files for npm or TODOWebpack.

requirex allows you to learn, test and validate ideas faster.

Getting started

Online quickstart

Open the project creatorTODO, follow instructions and publish an app or download a self-hosted project (even without Node.js) as a .zip or tarball.

Locally in the browser

If you already have a web server, a single index.html file inside it (download example) is enough to run some code.

Otherwise, you can download serve.bat (a simple web server for Linux, Windows and OS X), run it and put an index.html file in the same directory, then open http://localhost:8080/ to see the result.

In index.html (download full example), first include requirex on the page:

<script src="https://cdn.jsdelivr.net/npm/requirex"></script>

Then use it to load your own code with a script element using a special type attribute:

<script type="x-req-application/javascript" src="app.js"></script>

Or more explicitly using vanilla JavaScript:

<script>

System.import('./app.js');

</script>

You can also write ES6 or TypeScript directly inside the script element:

<script type="x-req-application/javascript">

import React from 'react';
import ReactDOM from 'react-dom';

const element = <h1>Hello, World!</h1>;

ReactDOM.render(element, document.body);

</script>

You can use the project creatorTODO and download a self-hosted project with a web server included and ready to go (even without Node.js).

Locally in Node.js

You can install requirex like so:

npm install --save requirex

Then use it from the command line:

npx requirex app.js

or without npx:

node -e "require('requirex').System.import('./app.js')"

or from JavaScript code:

var System = require('requirex').System;

System.import('./app.js');

on in package.json scripts:

"scripts": {
  "start": "requirex app.js"
}

Now app.js can contain ES6 or TypeScript code and successfully import packages even if they haven't been installed, like this:

import pad from 'left-pad';

console.log(pad('foo', 42));

Here's a one-liner to test it immediately:

npx requirex -e "console.log(require('left-pad')('foo', 42));"

or without npx:

node -e "require('requirex').System.import('left-pad').then(function(pad) { console.log(pad('foo', 42)); })"

Practical issues

Changing package versions can cause problems later, so requirex can read, generate and update package.json and package-lock.json files. That keeps the project always compatible with other development tools. If you want to keep using npm then requirex will use any installed packages, but you can also try out new packages without having to install them. Generating new npm configuration ensures used packages will have correct version numbers and unused packages are dropped.

Loading dependencies and transpiling code every time is slow, so requirex will store results in window.caches, window.localStorage or the local filesystem, whichever it can access.

Other users still need to download everything the first time, so requirex can bundle and minify all dependencies into a single file making it load faster.

License

The MIT License

Copyright (c) 2018- RequireX authors, see doc/AUTHORS