-
Notifications
You must be signed in to change notification settings - Fork 60
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
speed up by using acorn tokenizer when possible #73
base: master
Are you sure you want to change the base?
Conversation
40baf44
to
76c9161
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, and the conflict is very simple to fix, just bumping the ECMA version. I'm not to confident on what the side effects of this change could be though.
Fixed the merge conflict |
yeah not sure about side effects either, might try using it in some more projects first |
05af6e5
to
038c74c
Compare
If a function expression declares a `require` parameter, its body is not analyzed for `require()` calls. This is mostly helpful for bundles that were already browserified, `detective` will ignore the calls to browser-pack's require runtime.
Well that got a lot more complex to support the scope stuff introduced by #79 😆 it looks like it works tho, will do a major bump for this to be safe (+ the scope stuff may technically be breaking as well) |
Add a
findFast
function that's exactly likedetective.find
, but doesn't parse the source. detective.find automatically uses findFast if possible.we cannot do this if a custom
isRequire
function is provided, because that can check an arbitrarily complexcallee
. If a customisRequire
function is not provided we only have to check for a single token with nameopts.word,
so then we can look at only the token stream.acorn's tokenizer ignores comments so things like
require /* xyz */ ('abc')
already work.when
opts.nodes
is set, detected require calls are parsed usingacorn.parseExpressionAt
.opts.fullParse
can be set in order to always do a full parse. this can be useful if folks want to make sure that all syntax is correct.I've so far found only one case where this doesn't work:
may add a special case for that if there's nothing else.
e;
Before:
After: