Skip to content

Having both named and default exports from package #612

Closed Answered by Sylvenas
boyeln asked this question in Help
Discussion options

You must be logged in to vote

In some package of turborepo, set package.json as follows:

{
   // ...
  "files": [
    "dist/"
  ],
 "main": "./src/index.ts",
  "exports": {
    ".": {
      "require": "./dist/index.js",
      "import": "./dist/index.mjs",
      "default": "./dist/index.js",
      "types": "./dist/index.d.ts"
    },
    "./*": {
      "require": "./dist/*/index.js",
      "import": "./dist/*/index.mjs",
      "types": "./dist/*/index.d.ts"
    }
  },
  "typesVersions": {
    "*": {
      "*": [
        "./dist/*/index.d.ts",
        "./dist/index.d.ts"
      ]
    }
  },
}

Import in some app of turborepo:

import {sleep} from 'helper'
// or
import { sleep } from "helper/timer";

It worded very well.

Replies: 6 comments 9 replies

Comment options

You must be logged in to vote
1 reply
@boyeln
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@tomerlichtash
Comment options

@EarlGeorge
Comment options

@Sylvenas
Comment options

Comment options

You must be logged in to vote
1 reply
@EarlGeorge
Comment options

Comment options

You must be logged in to vote
4 replies
@gaboesquivel
Comment options

@alexrabin
Comment options

@dev-tarun-nw
Comment options

@thefill
Comment options

Answer selected by boyeln
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet