architect / functions

AWS Lambda Node runtime helpers for Architect apps
https://arc.codes
163 stars 38 forks source link

chore: add `"sideEffects": false` to package.json #521

Closed mcansh closed 2 years ago

mcansh commented 2 years ago

Add "sideEffects": false to package.json to allow frameworks that mix client and server code in the same files to tree-shake "@architect/functions" from client bundles.

https://remix.run/docs/en/v1/pages/gotchas#server-code-in-client-bundles

https://esbuild.github.io/api/#conditionally-injecting-a-file https://webpack.js.org/guides/tree-shaking https://github.com/rollup/plugins/tree/master/packages/node-resolve#ignoresideeffectsforroot

Thank you for helping out! ✨

We really appreciate your commitment to improving Architect

To maintain a high standard of quality in our releases, before merging every pull request we ask that you've completed the following:

Please also be sure to completed the CLA (if you haven't already).

Learn more about contributing to Architect here.

Thanks again!

CLAassistant commented 2 years ago

CLA assistant check
All committers have signed the CLA.

ryanblock commented 2 years ago

Hey there! I am not certain all our exports are side effect free per webpack’s definitions. I don’t want to make claims to bundlers that we are uncertain of, just to have to support the issues that could cause later. Wdyt?

ryanblock commented 2 years ago

Related, I’m not sure I follow what you mean by tree shaking fs-extra, that is not a dependency of this lib.

mcansh commented 2 years ago

Hey there! I am not certain all our exports are side effect free per webpack’s definitions. I don’t want to make claims to bundlers that we are uncertain of, just to have to support the issues that could cause later. Wdyt?

Makes sense and is totally a valid concern, I opened this without really looking at any related code, having a re-export for export {default} from "@architect/functions"; is sufficient enough - was just trying to make the integration into Remix projects a bit easier

Related, I’m not sure I follow what you mean by tree shaking fs-extra, that is not a dependency of this lib.

sorry! copy paste gone bad, should be "@architect/functions"

ryanblock commented 2 years ago

I'd say things are pretty pure, the only thing that gives me pause is https://github.com/architect/functions/blob/main/src/index.js#L43-L45

Since I'm not familiar with the ramifications of this change and will wind up being responsible for things breaking should we make it, how do you think we should go about resolving this PR?

mcansh commented 2 years ago

hm, yeah that does make me hesitant, plus based on the "tip" from the webpack docs it sounds like we shouldn't do this - I'll ask around on our side