Skip to content

Commit 38e4269

Browse files
authored
docs: make limitations more clear (#23)
1 parent 5325de4 commit 38e4269

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,25 @@ pluginCheckSyntax({
195195
196196
## Limitations
197197
198-
1. Check Syntax plugin only checks incompatible syntax in the outputs and cannot detect missing polyfills.
199-
2. Check Syntax plugin's detection may be inaccurate in certain cases due to the limitations of AST parser. Check Syntax is implemented based on [Acorn](https://github.com/acornjs/acorn), which targets a specific ECMA version, such as ES2018. On the other hand, SWC can target specific syntax during compilation, such as ES2018's Object Spread. This difference means that using the same browserslist configuration, SWC's compiled output is correct, but Check Syntax may still fail detection.
198+
### Syntax detection range
199+
200+
This plugin only checks incompatible syntax in the outputs and cannot detect missing polyfills.
201+
202+
### Syntax detection accuracy
203+
204+
The syntax detection in this plugin may have some limitations due to the granularity difference between the AST parser and the actual compiler:
205+
206+
1. **Parser Granularity**: This plugin uses [Acorn](https://github.com/acornjs/acorn) as its parser, which can only check syntax compatibility at the ECMAScript version level (like ES5, ES2015, etc).
207+
208+
2. **Compiler Granularity**: The JavaScript compiler (such as SWC) is more fine-grained and can handle individual syntax features independently. For example, it knows that Firefox 45 supports arrow functions even though it doesn't support all ES2015 features.
209+
210+
This difference can lead to false positives. For example:
211+
212+
- When your browserslist includes `firefox >= 45`:
213+
- SWC correctly determines that arrow functions can be used since Firefox 45 supports them
214+
- This plugin will report an error because Firefox 45 doesn't support all ES2015 features
215+
216+
Therefore, you might encounter situations where the compiled output is actually compatible with your target browsers, but this plugin still reports errors due to this granularity mismatch.
200217
201218
## License
202219

0 commit comments

Comments
 (0)