Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

170
Views
jscodeshift - get count of all imports from a module in project

I'm playing around with jscodeshift.

My goal is to get count of all imports from a particular module in a project

import { Circle, Triangle, Rectangle } from 'geometry';

results in

{ Circle: 1, Triangle: 1, Rectangle: 1 }

I have kind of achieved what I wanted here But the only issue is that I want these stats for a whole project instead of single file.

Any idea how can I achieve this?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Not sure if I understand this correctly, are you trying to import everything from within a module without having to explicitly type their names (Circle, Triangle, etc)? Or this might help:

export const Foo = 1;
export const Bar = 2;

// geometry2.js|ts
export const Biz = 3;

// index.js|ts 
import * as counts from './geometry';
import * as counts2 from './geometry2';

const data = { ...counts, ...counts2 };
console.log(data); // logs {Foo: 1, Bar: 2, Biz: 3}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!