-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The import
parser has false positives and false negatives
#79
Comments
Ah, I see.. Yeah, they're here: Lines 14 to 17 in d3acee7
|
Ok, I'm on it... Why are you using the |
Well, if I follow the JS Spec with a hack for identifiers, I end up with this for just detecting imports: ... which is probably a bit much... Also, I'd need to triple check and make sure it doesn't backtrack pathologically (it probably does). There's probably a smarter way to do it... |
import
parserimport
parser has false positives and false negatives
So, I'm about to implement something similar for the online version of bunchmark, and while working on an improved version of the above, I found a case where Flems modifies code it shouldn't and adds Here is a reduced example. My WIP parser had variables with The new parser should be ReDOS resistant, but I still have to test it. I end up with these ginormous RegExps:
... and then this Edit: adding support for dynamic imports as well. |
The package is live as https://github.com/pygy/unpkgify (it has tests and seems quite robust). |
My approach still has regexp-related corner cases (you need a full JS parser to tell them apart from successive divisions). If a RegExp contains a pattern that looks like a bit of template string, or even simply a brace, it can throw my parser off. I think I'm going to use Babel for this. |
As mentioned earlier, here are a few bugs I found:
Gives
Live here
If you point me to the parser (I suppose it is RegExp-based) I can upgrade it.
The text was updated successfully, but these errors were encountered: