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

152
Views
Problems with circular imports using index.js?

Given the following file structure:

myFiles
├── index.js
├── getTrue.js
└── dependentGetFalse.js

And the following code

// index.js
export { getTrue } from './getTrue'
export { dependentGetFalse } from './dependentGetFalse'
// getTrue.js
export const getTrue = () => true
// dependentGetFalse.js
import { getTrue } from '.'
export const dependentGetFalse = () => !getTrue()

Where there's (what I assume to be) a circular import between dependentGetFalse.js and index.js.

What problems will arise from this? Or is it ok to have?

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

0

If your codes run flawless and you are comfortable with them, It is ok to have this circular situation

about 4 years ago · Juan Pablo Isaza Report

0

It's best to avoid using '.' imports.

Try this:

// dependentGetFalse.js
import { getTrue } from './getTrue'
export const dependentGetFalse = () => !getTrue()

index.js is useful when you try to import something from outside of this folder.

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!