babel-plugin-conditional-annotation
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

Conditional Annotation

💡 Description

Remove the code during the compilation phase through conditional annotations, is babel plugin.

🚀 Features

  • 支持 #if、#elseif、#else、#endif 四种条件注释
  • 支持多层嵌套,相关联的条件注释必须在同一层级
  • 仅对数组、对象、代码块中的条件注释进行处理

📦 Install

npm i -D babel-plugin-conditional-annotation

⚡ Usage

// #if TOP_LEVEL
// top level
console.log('top level');
// #endif
// #if FUNC
function func() {
  // debug outer
  // #if DEBUG
  // debug inner prev
  console.log('debug');
  // debug inner next
  // #endif
  return {
    // #if MODE === 'development'
    development: true,
    // #elseif MODE === 'production'
    production: true,
    // #else
    mode: 'unknown',
    // #endif
  };
}
// #endif

📄 License

MIT License © 2024 shewulong

Package Sidebar

Install

npm i babel-plugin-conditional-annotation

Weekly Downloads

1

Version

1.0.4

License

MIT

Unpacked Size

9.87 kB

Total Files

7

Last publish

Collaborators

  • shewulong