nippur72 / ifdef-loader

Webpack loader for JavaScript/TypeScript conditional compilation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Provide a way to write optional code hide in comment

loynoir opened this issue · comments

Background

Sometime, mix all conditional code together may not allowed by linters.
Need a way to write optional code, able to avoid linting errors.

Actual

/// #if ! __DEBUG__
const foo = "bar" // Cannot redeclare block-scoped variable 'foo'
/// #else
var foo = "bar" // Cannot redeclare block-scoped variable 'foo'
const __hotUpdate = ()=>{
  foo="bar2" // Cannot assign to 'foo' because it is a constant
}
/// #endif

Expected

/// #if ! __DEBUG__
const foo = "bar"
/// #else
/// var foo = "bar"
/// const __hotUpdate = ()=>{
///   foo="bar2"
/// }
/// #endif

Maybe?

  1. // code
  2. /// code
  3. /* code */

what about

/// #if ! __DEBUG__
const foo = "bar"
/// #else
//_ var foo = "bar"
//_ const __hotUpdate = ()=>{
//_   foo="bar2"
//_ }
/// #endif

Thanks for your reply.
I think it's better.
Because it's easier to find out there is a different hidden block within a glance.

this is now addressed in v2.3.0 with the option ifdef-uncomment-prefix (see the README).