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

Only first entry works when more than one is provided #55

Closed
prdxs opened this issue Sep 21, 2021 · 6 comments · Fixed by #134
Closed

Only first entry works when more than one is provided #55

prdxs opened this issue Sep 21, 2021 · 6 comments · Fixed by #134

Comments

@prdxs
Copy link

prdxs commented Sep 21, 2021

Current Behavior

When running
dts build -i src/components/core/Badge/index.ts -i src/components/core/CssBaseline/index.ts
the second entry is ignored.

The dist/ folder only contains the bundle containing the Badge component in this case.

Expected behavior

I would expect having bundle files for CssBaseline too.

Suggested solution(s)

I don't have a clue 😂

Additional context

I just want to have one file for each component of a library of React components

Your environment

  System:
    OS: Linux 5.11 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Core(TM) i7-7560U CPU @ 2.40GHz
    Memory: 3.67 GB / 15.37 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 14.17.5 - ~/.nvm/versions/node/v14.17.5/bin/node
    Yarn: 1.22.11 - ~/.nvm/versions/node/v14.17.5/bin/yarn
    npm: 7.21.0 - ~/.nvm/versions/node/v14.17.5/bin/npm
  Browsers:
    Brave Browser: 93.1.29.81
    Chrome: 93.0.4577.82
    Firefox: 92.0
  npmPackages:
    dts-cli: ^0.17.1 => 0.17.1 
    typescript: ^4.4.3 => 4.4.3 
@aladdin-add
Copy link

this is working as expected.

you can add another entry to import all components:

export { default as Badge} from 'src/components/core/Badge/index.ts';
export { default as CssBaseline} from 'src/components/core/CssBaseline/index.ts';
...
$ dts build -i src/index.ts

@prdxs
Copy link
Author

prdxs commented Sep 22, 2021

Yes, I understand that if you have a barrel index with all your exports you are going to get a bundle with all your files there.
What I want is different bundles for different entries, if that makes sense. And I thought providing many entries was the way to accomplish that.

@aladdin-add
Copy link

tsdx was designed to be an opinionated tool, seems not supported this way. But I'm open to add it in the fork.

@prdxs
Copy link
Author

prdxs commented Sep 22, 2021

It's up to you. I think it might be useful for people writing a component library and don't want it all bundled in one file. I am not sure (correct me if I am wrong) but I think that if all the library comes in one file you cannot leverage tree-shaking.

I could give it a go too.

BTW, I love your fork TSDX idea is really good but they don't seem to be maintaining it anymore and this fork let me use the last version of ESLint, etc.

@aladdin-add
Copy link

aladdin-add commented Sep 22, 2021

as I can tell, most modern bundlers support esm tree-shaking, webpack/rollup/parcel/... so, it seems not a big deal to make a barrel index. But I agreed not all packages has just one entry, e.g. eslint has two entries: 1) public api; 2) non-officially supported api. https://github.com/eslint/eslint/blob/e3cd1414489ceda460d593ac7e7b14f8ad45d4fc/package.json#L12-L13
it could be useful for these packages. PRs are welcome! 😄

@jy95
Copy link

jy95 commented Sep 23, 2021

If I correctly recall, there was one PR (never merged) in tsdx : jaredpalmer#367
If @prdxs is willing to do a similar PR on this fork, why not ?

Edit: If it helps someone to start, here is a git patch file with the major changes, that could be applied to dts-cli (still issues to deal with tests :( )

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

Successfully merging a pull request may close this issue.

3 participants