Import nested file from node_modules package

Viewed 95

I am using yarn workspaces and I have following tsconfig for my package

{
  "compilerOptions": {
    "allowUmdGlobalAccess": true,
    "rootDir": "src",
    "outDir": "dist",
    "declaration": true,
    "sourceMap": true,
    "types": [
      "node",
      "jest"
    ]
  },
  "include": ["src"],
  "exclude": ["src/**/*.unitTest.ts"]
}

Now in another project which depends on this package I want to import a file i.e. packages/<package>/dist/somefile.js

Importing as import someFunction from '<package>/dist/somefile.js'; works But import someFunction from '<package>/somefile.js'; gives error. And this is what I want.

in my package.json I have

  "exports": {
    "./": "./dist/",
    "./package.json": "./package.json"
  },
0 Answers
Related