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

604
Views
package.json exports and multiple type declaration file

I am trying build a TypeScript library and want to export using exports field in package.json.

From nodejs and webpack's documentation, I saw that exports is the recommended way to export modules.

https://nodejs.org/api/packages.html#package-entry-points

https://webpack.js.org/guides/package-exports/

The old way is to use "main", "types" and "module".

How can I export type declaration using this method? Should I keep using the "types" field? But what if I have multiple exports?

Here is a sample of exports I have

"exports": {
    ".": {
      "import": "./dist/A.mjs",
      "require": "./dist/A.js"
    },
    "./A": {
      "import": "./dist/A.mjs",
      "require": "./dist/A.js"
    },
    "./B": {
      "import": "./dist/B.mjs",
      "require": "./dist/B.js"
    }
  }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I have written a post that has an strategy to provide multiple types: https://www.raulmelo.dev/blog/build-javascript-library-with-multiple-entry-points-using-vite-3

about 4 years ago · Raul 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!