Comments (2)
Hey @mistic. Thanks for the issue! Can you provide an example of how you're using require.resolve
?
Based on my assumptions on how you're using it, we'd need to add support for it in the commonjs detective. I could definitely see your future example being a test case here: https://github.com/dependents/node-detective-cjs/blob/master/test/test.js#L33.
Here is where we sniff for require()
: https://github.com/dependents/node-detective-cjs/blob/master/index.js#L13-L26. You could add support for require.resolve there by looking for a resolve
function call that's an attribute of a require
object.
If you're unfamiliar with ASTs, you're basically iterating through the keys in a big object and looking for a particular part of it (if it exists). Here's a good tool for seeing the AST representation of some code to look for the part of the object that represents require.resolve('')
: https://astexplorer.net/#/gist/ed8f609760da184363377d975063552b/45f0e4dae0e876853a9997fde5faeeb7137e4746.
I'm super open to a PR in node-detective-cjs with the fix.
from node-precinct.
Hey @mistic. Similar support was recently added by a contributor for supporting require.main.require
. That (#47) could be a good starting point if you or another contributor would like to address this issue.
from node-precinct.
Related Issues (20)
- Remove rewire
- Type Definitions missing HOT 3
- Does not get correct dependencies when mixing es6 and cjs import syntax HOT 9
- Please add support for precss HOT 1
- Webpack's `require.context` not being employed HOT 3
- svelte-style html files HOT 3
- require.main.require not being parsed HOT 8
- detective-typescript uses an unsupported version of typescript HOT 1
- Allow fs to be passed in options (for paperwork)
- Dynamic imports javascript not being detected HOT 1
- Dynamic Imports in ES6 module without export are not detected HOT 4
- Keep a changelog (at least for breaking changes) HOT 1
- Update detective-typescript's parser HOT 1
- TypeScript file with a cast fails to find any dependencies HOT 2
- Missing `mixedImports` for TypeScript files HOT 1
- Support customizing options for walker HOT 2
- Export regular text instead of array in cli HOT 1
- bug
- Add recursive support HOT 1
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 node-precinct.