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

module-inlinify

v1.0.1

Published

A simple browserify transform to inline the output of particular scripts.

Downloads

4

Readme

module-inlinify

A simple browserify transform to inline the results of some of the modules.

npm install module-inlinify

It's time to stop choosing between developer productivity and performance for the front-end Using this browserify transform, you can take certain modules and inline the results.

Here are a few examples:

Stilr

Stilr is a utility for managing CSS in React projects by creating dynamically generated classNames. With it you would write you styles something like this:

var StyleSheet = require('stilr')

module.exports = StyleSheet.create({
  container: {
    background: 'blue'
  },
  item: {
    color: 'white'
  }
})

The StyleSheet.create function converts the object into a simple object that maps from the original keys to classNames. So a file that imports this file can get the className with styles.container and styles.item.

This is great for developer productivity, but you shouldn't have to pay for that with all your CSS in your JS in production.

If you apply the module-inlinify transform, and set the config to include this file, it would be transformed to:

module.export = {"container": "_jsie0", "item":"_hie38"}

Just the parts you need, and nothing else!

Module-Inlinify will import this file compute the output, and replace the contents of the file if the output is a simple value. This means that you can write any valid node code in these modules. Variables, function calls, requiring modules are all fair-game.

implicit BRFS

If you have a simple module the reads a file, transforms it and then finally exports a string, you can replace it with the output string. You essentially get brfs for free, as long is it isolated in a separate file, and uses the synchronous form.

Usage

The usage is fairly straight-forward.

In your package.json file add a section config for module-inlinify, and mention a glob for files to include.

"module-inlinify": {
  "include": "*.inline.js"
}

This would inline the results of all modules whose paths end in .inline.js

Now, you can just add the transform to your browserify command, and you're done.

Roadmad

[ ] Support for async using promises?