rollup-plugin-conditional-compilation 1.0.4 → 1.0.6
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 +11 -4
- package/dist/index.cjs +6486 -1
- package/dist/index.d.ts +20 -6
- package/dist/index.mjs +6484 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,6 +20,11 @@ console.log('user', userData); // when DEBUG is false, this line will be removed
|
|
|
20
20
|
- [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.
|
|
21
21
|
For more awesome packages, check out [my homepage💛](https://baendlorel.github.io/?repoType=npm)
|
|
22
22
|
|
|
23
|
+
## Fixed Issues in v1.0.6
|
|
24
|
+
|
|
25
|
+
1. Added configurable `ecmaVersion` and `sourceType` options to pass to Acorn. Previously, `sourceType` is fixed in this plugin and prevented parsing ES module files; this is now configurable.
|
|
26
|
+
2. Fixed an issue where `variables` was required; `variables` is now optional.
|
|
27
|
+
|
|
23
28
|
## Installation
|
|
24
29
|
|
|
25
30
|
```bash
|
|
@@ -34,11 +39,13 @@ import conditional from 'rollup-plugin-conditional-compilation';
|
|
|
34
39
|
export default {
|
|
35
40
|
...other configs,
|
|
36
41
|
plugins: [
|
|
42
|
+
// Recommended: run `conditional` before the TypeScript transformer so the
|
|
43
|
+
// plugin operates on the original source comments.
|
|
44
|
+
conditional({ variables: { DEBUG: false, FEATURE_X: true } }),
|
|
37
45
|
typescript({
|
|
38
46
|
...,
|
|
39
47
|
removeComments: false, // !!IMPORTANT!! Don't strip comments so quickly!
|
|
40
48
|
}),
|
|
41
|
-
conditional({ variables: { DEBUG: false, FEATURE_X: true } })
|
|
42
49
|
],
|
|
43
50
|
};
|
|
44
51
|
```
|
|
@@ -77,12 +84,12 @@ console.log('always');
|
|
|
77
84
|
|
|
78
85
|
## Behaviors
|
|
79
86
|
|
|
80
|
-
- **AST Parsing**: Using Acorn with `{ ecmaVersion:"latest" }` to parse the code, so it supports
|
|
87
|
+
- **AST Parsing**: Using Acorn with `{ ecmaVersion: "latest", sourceType: "module" }` by default to parse the code, so it supports the latest JavaScript syntax and ES modules.
|
|
81
88
|
|
|
82
89
|
- **Directive Style**: Only `//` comments are scanned for directives; block comments (`/* ... */`) are ignored.
|
|
83
90
|
- Reason 1: block comments can span multiple lines with `*` ahead and may contain nested comments, making parsing more complex and error-prone.
|
|
84
|
-
- Reason 2:
|
|
85
|
-
- **Precise Evaluation**: Expressions are
|
|
91
|
+
- Reason 2: For consistency and simplicity.
|
|
92
|
+
- **Precise Evaluation**: Expressions are executed using the Function constructor — do not pass untrusted input or rely on side effects.
|
|
86
93
|
|
|
87
94
|
## License
|
|
88
95
|
|