You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The situation is such that when publishing npm modules, I compile the code into two formats: CommonJS (cjs) and ECMAScript modules (esm). I utilize Rollup to generate bundled files as well as to create the index.d.ts file. In certain instances, modules (like @peculiar/x509) may include additional settings for compiling the final files for browser use. I am aware that the standard TypeScript compiler can be used to produce various module formats, but it generates JavaScript files with the same structure as the TypeScript files, resulting in a multitude of files with redundant imports. Conversely, when using Rollup, the compiled code appears much more succinct.
Regarding the asn1js module, I'm not confident that it can be made significantly more compact through tree shaking since all the structure classes are utilized in the fromBER method, which is used by applications. The only code that might not be used in the asn1js module is the compareSchema function. However, if an application is written without using this function, it would be excluded from the bundle file during the build process. Here is an example of a simple application. From the screenshot, it is apparent that the application file includes the asn1js module, but the compareSchema function is not present.
This module is authored in ESM but then transpiles that to CJS, then finally uses rollup to create a big code blob.
Image from https://esbuild.github.io/analyze/ :
The tsc config could be updated to just publish ESM and rollup could be removed.
This would make it easier to do tree shaking to remove unused code from bundles.
The same change could be made to pvutils and pvtsutils.
@microshine I can open some PRs if you'd fine this useful?
The text was updated successfully, but these errors were encountered: