Closed godu closed 9 months ago
Perhaps we could disable the "sideEffects"
property in the package.json
(cf https://webpack.js.org/guides/tree-shaking/).
I test it, and the bundle passes from 570.9kb
to 458.2kb
.
oh, wow, didn't know about this property, I tried me end project and indeed reduced size in like twice. however when I tried to add it in the @effect-aws packages, I didn't see any improvements is it supposed to be used in libs?
I was surprise that a simple program produces a ~500kb bundle
I cannot reproduce it I'm using command
esbuild --bundle src/lambda.ts --target=\"node18\" --platform=\"node\" --outfile=\"dist/index.js\" --tsconfig=\"tsconfig.json\" --tree-shaking=true --main-fields=module,main --minify --metafile=dist/meta.json
probably you can try this --main-fields=module,main
in your esbuild command, it should improve tree shaking
Ok, I have a hint. In my sample, I don't use the DefaultDynamoDBServiceLayer
and esbuild should be able to prune the ../../node_modules/@effect-aws/client-dynamodb/lib/esm/DynamoDBService.js
file.
Without the sideEffects
property, the DynamoDBService
module is present in my bundle, even if I use any your recommended flags.
I think it will be more safe to add "sideEffects": []
like effect does (cf: https://discord.com/channels/795981131316985866/1174418279276757002/1174680724377440356).
agreed. If you feel like you can raise a PR, or I will pick it up in the evening.
I was surprise that a simple program produces a ~500kb bundle
bundled with
Maybe we should improve the tree-shacking readiness.