Does the "exports" attributes in package.json work in workspaces?

Viewed 136

I have a npm package set up as follows

project
|
|-- package.json
|
|-- workspace_a
|   |-- package.json
|   |-- index.js
|
|-- workspace_b
|   |-- package.json
|   |
|   |-- src
|   |   |-- index.js
|   |   |
|   |   |-- folder_1
|   |   |   |-- index.js
|   |   |
|   |   |-- folder_2
|   |       |-- index.js
|   |
|   |-- dist
|       |-- index.js
|       |
|       |-- folder_1
|       |   |-- index.js
|       |
|       |-- folder_2
|           |-- index.js

The main project file is propery configured for workspaces, as are the workspace project.json files.

project/workspace_b/package.json contains the following:

{
  "main": "dist/index.js",
   "exports: {
     ".": "./dist/index.js",
     "./*": "./dist/*/*.js"
    }
}

project/workspace_a/index.js:

import example from "@project/workspace_b/folder_1"

I am expecting this line to load the default export contained in project/workspace_b/dist/folder_1/index.js however I am recieving the error Cannot find module: '@project/workspace_b/folder_1'

Should the exports attributes in project/workspace_b/package.json handle this for me?

0 Answers
Related