Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

module-inlinify

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

module-inlinify

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

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

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?

Keywords

FAQs

Package last updated on 29 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc