DriLLFreAK100/codefee-kit

Redundant multiple Inputs

jayeshchoudhary opened this issue · 1 comments

I have build this repo with default input


input: [
    './src/index.ts',
    ...getFiles('./src/common', extensions),
    ...getFiles('./src/components', extensions),
    ...getFiles('./src/hooks', extensions),
     ...getFiles('./src/utils', extensions),
  ],

also with only src/index.ts input
input: [ './src/index.ts', ]

The output in dist folder is exactly same in both cases. I even verified with the final bundle analyzer It's exactly the same.

I believe since we have exported everything in our src/index.ts file. hence it is only our main entry point. and rollup is smart enough to take all index.ts into consideration.

can you please verify this once. I i am right then we can safely remove all the bundle util code.

Hi @jayeshchoudhary, good day! Thanks for filing this.

Yes, you are mostly correct. The reason for the getFiles util code was due to my previous setup without output.preserveModules flag. Hence, specifying individual files did helped to carry out the necessary code splitting back then.

That being said, there is still a subtle difference in terms of files output in the dist folder. Some of the index.ts files didn't exactly get built into individual index.js files, which would then contradict with the *.d.ts TypeScript Definition files generated. The following snapshot illustrates part of the file differences.

image

Though not exactly a big impact, however it can still cause issues (missing barrel) at a client app if the person is trying to access the package with a line like so:

import { Button } from 'codefee-kit/dist/components';
TypeScript will not complain upfront because the .d.ts file is there. However, it'll definitely be erroneous upon build time at the client app.