New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ifdef-loader

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ifdef-loader

#ifdef conditional Webpack loader

  • 0.0.10
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.9K
decreased by-35.09%
Maintainers
1
Weekly downloads
 
Created
Source

ifdef-loader

Webpack package loader that allows JavaScript/TypeScript conditional compilation (#if ... #endif).

Installation

In webpack build directory:

npm install ifdef-loader --save-dev

Configuration

Example of use with TypeScript files, enabling the DEBUG and version variables:

In webpack.config.json:

//...
{ test: /\.tsx?$/, exclude: /node_modules/, loaders: [ "ts-loader", 'ifdef-loader?DEBUG=true&version=3' ] }
//...

in example.ts:

// #if DEBUG
/* code to be included if DEBUG is defined */
//   #if version <2
/* code to be included if DEBUG is defined and version < 2*/
//   #endif
// #endif

Add ifdef-verbose to query string if you want the loader to print informations when directives are processed:

//...
{ test: /\.tsx?$/, exclude: /node_modules/, loaders: [ "ts-loader", 'ifdef-loader?ifdef-verbose=true' ] }
//...

Directives

Directives must be placed after a // doubleslash comment.

// #if SOMECOND
//   #if SOMEOTHER
/* code */
//   #endif
// #endif

At the moment the only directive supported is #if/#endif (more to come).

// #if SOMECOND
/* code to be included if SOMECOND is true */
// #endif

License

MIT

FAQs

Package last updated on 07 Aug 2016

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