Skip to content

[Bug]: Multiple export (entry points) #575

@alefduarte

Description

@alefduarte

Version

System:
    OS: Windows 10 10.0.19045
    CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11850H @ 2.50GHz
    Memory: 9.34 GB / 31.67 GB
  Browsers:
    Edge: Chromium (127.0.2651.86)
    Internet Explorer: 11.0.19041.4355

demo:
  System:
    OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (2) x64 AMD EPYC
    Memory: 1.41 GB / 4.01 GB
    Container: Yes
    Shell: 5.9 - /bin/zsh

Details

I'm creating a simple library with multiple entries.
I have seen this: web-infra-dev/rsbuild#3702
But it still does not answer my question.
I want to import my components like this:

import { Button } from '@acme/ui/Inputs';

However, this doesn't work. I've managed to get it working using Vite and Rollup, but I want to migrate to rslib instead.
I'm likely making a mistake, but I can't find any documentation on how to resolve it.

My entries are set up as follows:

  source: {
    entry: {
      './Inputs': 'src/Inputs/index.ts',
      './Surfaces': 'src/Surfaces/index.ts',
    },
  },

I'm also receiving this warning:

duplicate entry: index, this may lead to the incorrect output, please rename the file
My exports configuration is:

  "exports": {
    "./Inputs": {
      "types": "./dist/Inputs/index.d.ts",
      "import": "./dist/index.js"
    },
    "./Surfaces": {
      "types": "./dist/Surfaces/index.d.ts",
      "import": "./dist/index.js"
    }
  },

I know the import is the same path because there is only one js file, I don't know why.
I've created a working example, which you can find here:
https://codesandbox.io/p/devbox/sx9t7q

Ultimately, I want to be able to import components in this way:

import { Button } from '@acme/ui/Inputs';
import { Card } from '@acme/ui/Surfaces';

Reproduce link

https://codesandbox.io/p/devbox/sx9t7q

Reproduce Steps

  1. run pnpm i to install all dependencies
  2. run pnpm build to build all packages
    alternatively, run pnpm build --filter=@acme/ui to build only the ui package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐞 bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions