Open DIYgod opened 6 years ago
When Esprima doesn’t like your code, it must an invalid JavaScript ;)
The compressed source code is like
if(true){}/\d/.test('');
Then gulp-strip-comments parses my code with toString
function to a string like 'if(true){}/\\d/.test(\'\')'
Should I make an issue to gulp-strip-comments?
I’m not sure, I will test it later though ;)
Here's the test I've done, and it all looks fine:
const decomment = require('decomment');
const str = 'if(true){}/\d/.test(\'\');';
const s = decomment(str);
console.log(s);
//=> if(true){}/d/.test('');
Have you tried gulp-decomment?
Sorry for my late reply.
The error happends in /\\d/
, not /\d/
You should log/chase it against the Esprima engine as the one that fails to process that piece of JavaScript.
There is nothing that can be done about it within this library.
There, I've opened an issue: Fails on a compressed piece of code.
Thanks!
The author of Esprima claims he fixed it, but I've just released an update, and I can still reproduce the issue :(
Esprima hasn't been published for 3 years, and now looks a bit abandoned.
I presently do not have time for rewriting this library to use a different parser.
A minimal demo:
Error log: