rollup-plugin-conditional-compilation 0.0.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,17 +3,17 @@
3
3
  [![npm version](https://img.shields.io/npm/v/rollup-plugin-conditional-compilation.svg)](https://www.npmjs.com/package/rollup-plugin-conditional-compilation) [![npm downloads](http://img.shields.io/npm/dm/rollup-plugin-conditional-compilation.svg)](https://npmcharts.com/compare/rollup-plugin-conditional-compilation,token-types?start=1200&interval=30)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/59dd6795e61949fb97066ca52e6097ef)](https://www.codacy.com/app/Borewit/rollup-plugin-conditional-compilation?utm_source=github.com&utm_medium=referral&utm_content=Borewit/rollup-plugin-conditional-compilation&utm_campaign=Badge_Grade)
5
5
 
6
- A simple plugin that allows you to include or exclude code blocks based on compile-time conditions. Works like `#if`, `#endif` in C/C++.
6
+ A simple plugin that allows you to include or exclude code blocks based on compile-time conditions. Works like `#if`, `#else`, `#elif` , `#endif` in C/C++.
7
7
 
8
- > **Note**: This plugin is a simplified version that only supports `#if` and `#endif` for now. Supports for `#else`, `#elif` will be added in future releases.
8
+ > **Note**: You should modify the plugin options to ensure **NOT to strip comments so quickly**, since we work with them. For example, with `@rollup/plugin-typescript`, set `removeComments: false`.
9
9
 
10
- For more awesome packages, check out [my homepage💛](https://baendlorel.github.io/?repoType=npm)
11
-
12
- **More rollup plugins** you might be interested in:
10
+ **More Rollup plugins** you might be interested in:
13
11
 
14
- - [rollup-plugin-conditional-compilation](https://www.npmjs.com/package/rollup-plugin-conditional-compilation): inline your `const enum XXX { ... }` definitions at compile time.
12
+ - [rollup-plugin-const-enum](https://www.npmjs.com/package/rollup-plugin-const-enum): inline your `const enum XXX { ... }` definitions at compile time.
15
13
  - [rollup-plugin-func-macro](https://www.npmjs.com/package/rollup-plugin-func-macro): replace `__func__` by function name of current block, and `__file__` by file name at compile time.
16
14
 
15
+ For more awesome packages, check out [my homepage💛](https://baendlorel.github.io/?repoType=npm)
16
+
17
17
  ## Installation
18
18
 
19
19
  ```bash
@@ -25,21 +25,25 @@ pnpm add -D rollup-plugin-conditional-compilation
25
25
 
26
26
  ```js
27
27
  import conditional from 'rollup-plugin-conditional-compilation';
28
-
29
28
  export default {
30
- input: 'src/index.js',
31
- output: { file: 'dist/bundle.js', format: 'esm' },
32
29
  ...other configs,
33
- plugins: [conditional({ variables: { DEBUG: false, FEATURE_X: true } })],
30
+ plugins: [
31
+ typescript({
32
+ ...,
33
+ removeComments: false, // !!IMPORTANT!! Don't strip comments so quickly!
34
+ }),
35
+ conditional({ variables: { DEBUG: false, FEATURE_X: true } })
36
+ ],
34
37
  };
35
38
  ```
36
39
 
37
40
  ### Syntax
38
41
 
39
- - Single-line directives only: `// #if <expression>` and `// #endif`.
42
+ - Single-line directives only: `// #if <expression>`, `// #else`, `// #elif <expression>` and `// #endif`.
40
43
  - The `<expression>` is evaluated at build time with the keys from `variables` available as identifiers.
41
- - You can write literally **ANY** js expression in it, because it is evaluated as an IIFE(Immediately Invoked Function Expression).
42
- - Only `#if` and `#endif` are supported(for now). `#else` / `#elif` will be supported in future releases.
44
+ - You can write **literally ANY JavaScript expressions** in it, because it is evaluated as an IIFE (Immediately Invoked Function Expression).
45
+ - Supported directives: `#if`, `#else`, `#elif`, `#endif` (similar to C/C++ style conditional compilation).
46
+ - Since it is `if/else` , it follows the syntax of `if/else` statements
43
47
 
44
48
  ### Example
45
49