rollup-plugin-conditional-compilation 1.0.0 → 1.0.1
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 +20 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/rollup-plugin-conditional-compilation) [](https://npmcharts.com/compare/rollup-plugin-conditional-compilation,token-types?start=1200&interval=30)
|
|
4
4
|
[](https://opensource.org/licenses/MIT) [](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.
|
|
6
|
+
A simple plugin that allows you to include or exclude code blocks based on compile-time conditions. Same as `#if`, `#else`, `#elif` , `#endif` in C/C++, it looks like this:
|
|
7
|
+
|
|
8
|
+
```typescript
|
|
9
|
+
// #if DEBUG
|
|
10
|
+
console.log('user', userData); // when DEBUG is false, this line will be removed
|
|
11
|
+
// #endif
|
|
12
|
+
```
|
|
7
13
|
|
|
8
14
|
> **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
15
|
|
|
@@ -47,13 +53,20 @@ export default {
|
|
|
47
53
|
|
|
48
54
|
### Example
|
|
49
55
|
|
|
50
|
-
|
|
56
|
+
Remove testing methods in your class when compiling for production:
|
|
51
57
|
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
```typescript
|
|
59
|
+
class User {
|
|
60
|
+
private name: string;
|
|
61
|
+
private identifier: string;
|
|
62
|
+
|
|
63
|
+
// #if DEBUG
|
|
64
|
+
// This method will be removed in production build
|
|
65
|
+
_getTestData() {
|
|
66
|
+
return SomeImportantDataForTesting;
|
|
67
|
+
}
|
|
68
|
+
// #endif
|
|
69
|
+
}
|
|
57
70
|
```
|
|
58
71
|
|
|
59
72
|
If `variables.DEBUG === false`, compiled output becomes:
|