Comments (10)
By all means extend ufuzz to support ES6+. I'd be happy to critique it.
Adding things like const, let, classes, class expressions and arrow functions would be fairly straightforward. Destructuring - in all its various forms (declaration, default values, in function parameters and destructuring assignment) could be interesting. Correctly exercising generators would be brutal, for example. The trick is to always generate valid code that produces a result - not as easy as one might think. The other think to watch out for is the frequency of generation of a specific ES6 feature so that a good representative mix of functionality is produced.
The best way to start would be to run uglifyjs -h ast
and knock off each node type one at a time.
I'd suggest to avoid generating async/await code until the node VM sandbox can handle it. We currently have no way to run asynchronous tests due to the timeout problem. All tests are synchronous for this reason.
OT - Would it be possible to put such non-trivial work in pull requests? It's easier to review that way.
from terser.
Expanding on the "representative mix of functionality" remark, we don't want to have destructuring in more than 5% of generated functions, for example. If a certain node type is too frequently generated it will cause various optimizations to be disabled such that it will not exercise the Compressor very well. I suppose a code coverage tool could gauge the effectiveness of ufuzz testing.
from terser.
BTW, reducing failing ufuzz test cases is somewhat of a black art. It takes me 30 minutes on average per test case to whittle it down to 5 - 10 lines to see whether it's a legitimate minify code generation failure or a false positive. That's why care has to be taken in ufuzz design to always try to generate valid code producing a valid result to reduce the false positive frequency.
from terser.
I'm having fun and found a parser error already :) looks like you can't have a class or function as the body of a for loop without a block.
from terser.
Would there be any merit to having an --ecma
flag similar to acorn
has to optionally restrict fuzzing to a certain ecma
level?
from terser.
I think that flag might make the script a lot more complex, when it comes to choosing what to output next you'd have to have two lists of what's possible.
In other news, it looks like since classes make the code inside of them strict mode automatically, ufuzz is outputting a lot of errors now I've added them. This might be a while.
from terser.
There's a strict flag - maybe that can help.
case '--use-strict':
use_strict = true;
from terser.
Thanks!
from terser.
I made a fuzzer that's able to catch parsing errors in ES6 code, #198. The idea comes from https://github.com/Rich-Harris/butternut/blob/master/test/fuzz-test.js.
from terser.
I like it
from terser.
Related Issues (20)
- Use without NPM HOT 1
- Private fields, `in` and precedence (?) HOT 1
- Never use unsafe_methods
- renames arrow function declaration despite `keep_fnames: true` HOT 2
- [Feature request] ability to declare a static block as pure HOT 3
- When the compression is enabled, used variables are dropped. HOT 3
- [Feature request] nameCache and __MANGLE_PROP__ overlap HOT 5
- preserve_annotations changes position of `/* #__PURE__ */` comments in function calls HOT 1
- Support new import attributes "with" syntax. HOT 6
- Babel transpiled ES6 class is not working after mangling with terser HOT 3
- reserved is not a supported option HOT 1
- Replace new BigInt("0") with 0n for ecma: 2020+ HOT 1
- try/catch block that can't possibly throw should be unwrapped
- IIFE Parameter is being removed and causes code to break HOT 3
- AWS Pipe line deploy got this error
- [Feature] Support @pure in JSdoc just like `@__PURE__`
- Drop console.assert() statements with always true assertion HOT 1
- Not sure what to call this. Javascript destructuring? HOT 2
- Issue in Minification in v5.31.4 HOT 2
- 5.31.4 is dropping base classes when there are sub classes that extend the base class. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terser.