Huge News!Announcing our $40M Series B led by Abstract Ventures.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 - npm Package Compare versions

Comparing version 2.3.0 to 2.3.1

2

package.json
{
"name": "ifdef-loader",
"version": "2.3.0",
"version": "2.3.1",
"description": "",

@@ -5,0 +5,0 @@ "main": "ifdef-loader.js",

@@ -62,3 +62,3 @@ "use strict";

return source;
var lines = source.split('\n');
var lines = source.split(/\r\n|\n|\r/);
var ifBlocks = find_if_blocks(lines);

@@ -65,0 +65,0 @@ for (var _i = 0, ifBlocks_1 = ifBlocks; _i < ifBlocks_1.length; _i++) {

@@ -59,3 +59,3 @@ import { OptionObject } from 'loader-utils';

const lines = source.split('\n');
const lines = source.split(/\r\n|\n|\r/);

@@ -62,0 +62,0 @@ const ifBlocks = find_if_blocks(lines);

@@ -100,2 +100,41 @@ # ifdef-loader

## Code in comments
Often times writing `#if` ... `#else` ... `#endif` results in code that is not syntactically valid
or does not pass the LINT check. A possible workaround is to hide such code in comments
and let `ifdef-loader` uncomment it if it's part of the block that has to be included in the output.
Example:
The following code is invalid because the linter sees a double declaration of the `a` variable.
```
// #if DEBUG
let a=1;
// #else
let a=2;
// #endif
```
Using code in comments:
```
// #if DEBUG
let a=1;
// #else
// #code let a=2;
// #endif
```
The code is now under comment so it's ignored by the linter; but it's uncommented
by `ifdef-loader` if the else branch has to be included in the output (that is when `DEBUG==false`).
The `// #code ` string prefix can be changed and has to be explictly specified
in the options object:
```
const opts = {
// ...
"ifdef-uncomment-prefix": "// #code ",
// ...
};
```
## License

@@ -102,0 +141,0 @@

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