Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
alefduarte opened this issue Dec 18, 2024 · 2 comments
Closed

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

alefduarte opened this issue Dec 18, 2024 · 2 comments
Labels
🐞 bug Something isn't working

Comments

@alefduarte
Copy link

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.
@alefduarte alefduarte added the 🐞 bug Something isn't working label Dec 18, 2024
@Timeless0911
Copy link
Collaborator

Try to set bundle: true, see https://lib.rsbuild.dev/config/lib/bundle#bundle-true

@alefduarte
Copy link
Author

I changed it and made some updates to the bundle and it worked! I failed to understand what it meant in the documentation. Thank you for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants