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 entries mode will compose duplicate files into each entries that imported that file #610

Open
turnerguo opened this issue Dec 25, 2024 · 1 comment

Comments

@turnerguo
Copy link

Version

System:
    OS: macOS 14.6.1
  Browsers:
    Chrome Canary: 133.0.6917.0
    Edge: 131.0.2903.112
  npmPackages:
    @rslib/core: 0.2.0 => 0.2.0

Details

Assuming we have a library package like this:

// ./src
//   - common
//     - utils.ts
//   - components-a
//     - buttons-a.ts -> utils.ts
//   - components-b
//     - buttons-b.ts -> utils.ts

// rslib.config.ts
...
source: {
       entry: {
         index: ['./src/**', '!./**/__test__/**'],
       },
    },
...

after build the utils.ts file will compiled into both components-a and components-b, in vite it will automatically split utils.ts as a reusable file, this is actually truly expected.

Reproduce link

https://codepen.io/Justineo/pen/yLbxxOR

Reproduce Steps

execute rslib build

@Timeless0911
Copy link
Contributor

Timeless0911 commented Dec 26, 2024

Your entry configuration above is usually used for bundleless mode, the correct entry config should be:

source: {
  entry: {
    'components-a': './src/components-a/buttons-a.ts',
    'components-b': './src/components-b/buttons-b.ts',
  },
},

This should be the issue you want to describe.

The bundled output components-a.js and components-b.js will both contain code in utils.ts. Splitting is not supported now, we will improve that in webpack/Rspack in the future. See #45.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants