Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Can we slim down "release" builds? #241

Open
kylef opened this issue Jul 1, 2019 · 7 comments
Open

Can we slim down "release" builds? #241

kylef opened this issue Jul 1, 2019 · 7 comments

Comments

@kylef
Copy link
Member

kylef commented Jul 1, 2019

When you npm install protagonist into a project, it takes up around 100MB, over 90MB of that is built artefacts which are not needed by Protagonist at runtime, all that is really needed from build at runtime is build/release/protagonist.node.

Screenshot 2019-07-01 at 13 38 17

@kylef
Copy link
Member Author

kylef commented Jul 1, 2019

Posting as a question, not sure how feasible it is. Perhaps we can hook into GYP to delete some of the build state for release builds.

@kylef
Copy link
Member Author

kylef commented Jul 1, 2019

In theory, something like the following should contain everything for the runtime: Screenshot 2019-07-01 at 13 51 28

We do need to consider that some of the LICENSE files for vendored dependencies are not there and how to ensure they are always present.

@kylef
Copy link
Member Author

kylef commented Jul 17, 2019

Looking at the GYP documentation, doesn't appear to be any hooks or way we can execute code, and even if we could it would be tricky to make it platforn independent. I think an NPM hook for postinstall may be the best option, we can produce a Node file which contains instructions to delete the artefacts for Release builds (we can omit these for debug).

@pksunkara
Copy link
Contributor

I thought we need *.a files because protagonist.node is dynamically linked. Did you get it working after deleting those things after installing protagonist as a module?

@kylef
Copy link
Member Author

kylef commented Jul 17, 2019

Yes, it works. .a is a static library, it is used to build protagonist.node. protagonist.node does not dynamically link to anything other than libc++ and system libraries once built:

$ otool -L build/Release/protagonist.node
build/Release/protagonist.node:
	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 400.9.4)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.250.1)

@gap777
Copy link

gap777 commented Nov 7, 2019

Any progress on this? We'd love to take advantage of this slimmed down release.

@kylef
Copy link
Member Author

kylef commented Nov 25, 2019

@gap777 There hasn't been, I am not entirely sure if it is possible from Protagonist alone. I haven't had chance to fully look into it, it might be up for discussion upstream in Node JS (node-gyp specifically: https://github.com/nodejs/node-gyp) since this can apply to all the C++ add-ons for Node.

If you want a slimmed down build, you can take a look at drafter.js, it's a pure JavaScript version of Protagonist (https://github.com/apiaryio/drafter.js/).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants