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

static-module

Package Overview
Dependencies
Maintainers
2
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

static-module

convert module usage to inline expressions

  • 1.5.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
707K
decreased by-4.16%
Maintainers
2
Weekly downloads
 
Created

What is static-module?

The static-module npm package is used to statically analyze and transform JavaScript modules at build time. It allows you to replace dynamic code with static code, which can be useful for optimizations and reducing runtime dependencies.

What are static-module's main functionalities?

Static Code Replacement

This feature allows you to replace dynamic code with static code. In this example, the `myFunction` from `my-module` is replaced with a static JSON string. This can be useful for optimizing code by removing dynamic parts that are known at build time.

const staticModule = require('static-module');
const through = require('through2');

const sm = staticModule({
  'my-module': {
    'myFunction': function() {
      return JSON.stringify({ key: 'value' });
    }
  }
}, { vars: { process: { env: { NODE_ENV: 'production' } } } });

process.stdin.pipe(sm).pipe(process.stdout);

Variable Inlining

This feature allows you to inline variables, such as environment variables, into your code. In this example, `process.env.NODE_ENV` is replaced with the string 'production'. This can help in optimizing and simplifying the code by removing runtime checks.

const staticModule = require('static-module');
const through = require('through2');

const sm = staticModule({
  'process.env.NODE_ENV': JSON.stringify('production')
});

process.stdin.pipe(sm).pipe(process.stdout);

Other packages similar to static-module

Keywords

FAQs

Package last updated on 29 Jul 2017

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