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

193
Views
How to shield the internals of a Lerna package, so other packages cannot import them?

I am working with a Lerna monorepo. I often see one package make imports from deep inside another package, for example:

import { SomeType } from "@schema/folder/folder/file.ts"

This is undesirable, because sometimes we need to transform auto-generated types before exporting them via index.d.ts. This sometimes results in the wrong, non-transformed type being imported from deep inside the package.

I would like to somehow constrain the files/folders that one package exposes to the others, so such imports would not be possible:

import { SomeType } from "@schema" // valid
import { SomeType2 } from "@schema/folder/folder/file.ts" // invalid

What are my options?

I am not sure what other info I can provide since I have little to no experience with this stuff.

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

0

When you use eslint, you can add a no-restricted-imports rule to the eslint settings of the package:

    "no-restricted-imports": [
      "error",
      {
        "patterns": ["@schema/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!