-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Improve dependency extractor #7385
Improve dependency extractor #7385
Conversation
29ac745
to
db2953d
Compare
db2953d
to
a5dbfbf
Compare
9516b01
to
c16ea91
Compare
Tests seems to be failing on Node 6? |
There's a case that was failing before: foo.require.requireActual('foo'); I used a negative lookbehind to fix it, but they're only supported in Node 9+. I disabled the test cases that don't work with Node 6 to make CI pass. Once we drop support for Node <10 we can re-enable them. |
Heh, so in like 3 years :P (EDIT: node 8 is EOL Dec 2019, so 3 was a bit of an exaggeration) Would it be possible to detect support and activate if it's available? Or would that give us different behaviors on different nodes which might be confusing to the user? |
@SimenB what I disabled was the test, not the support for the feature. I still use feature detection and enable it if it's available. |
Ah, cool! Could we conditionally disable the test/assertions as well, then? To make sure we don't break it 🙂 |
Codecov Report
@@ Coverage Diff @@
## master #7385 +/- ##
==========================================
+ Coverage 66.72% 66.78% +0.05%
==========================================
Files 241 242 +1
Lines 9356 9372 +16
Branches 6 6
==========================================
+ Hits 6243 6259 +16
Misses 3110 3110
Partials 3 3
Continue to review full report at Codecov.
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
This refactors the default dependency extractor to make regular expressions less error-prone (building them with a custom DSL) and fixes some bugs:
require("foo",)
(notice the trailing comma), which is completely valid, wasn't detected.import typeof {foo} from 'foo'
was detected as a dependency, when it should've been ignored likeimport type {foo} from 'foo';
.It also uses negative lookbehind when it's supported.
Performance-wise, it's faster than the previous version as it removes unnecessary capture groups (tested internally at Facebook).
Test plan
Updated unit tests.