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

Package size #342

Open
remicastaing opened this issue Mar 14, 2018 · 5 comments
Open

Package size #342

remicastaing opened this issue Mar 14, 2018 · 5 comments

Comments

@remicastaing
Copy link

remicastaing commented Mar 14, 2018

Hello every one! Thanks for the awesome work.

I'm looking at the package size after running sls package:

serverless-graphql-dynamo.zip          10,5 MB

If you look into the .zip files you will find all the node_modules, with readme, test, src, etc. Is not there any way to get rid of all this dead weight?

If you remove:

const nodeExternals = require('webpack-node-externals');
...
externals: [nodeExternals()],

from webpack.config.js, you can go down to:

serverless-graphql-dynamo.zip          1,1 MB

And if you add uglifyjs-webpack-plugin, you can shrink the package to:

serverless-graphql-dynamo.zip          674 KB

Disclaimer: I have not tested if the service is working after deployment.

@sid88in
Copy link
Contributor

sid88in commented Mar 14, 2018

@remicastaing very interesting. Would be great if you could test it out. I have not spent time to optimize the package sizing yet but I am sure there is scope for optimization.

@remicastaing
Copy link
Author

I just deployed the minified service and it seems to work: playground and graphiql are responding and I'm getting a { "message": "Missing Authentication Token" } message without an error from the endpoint.

During packaging, I'm getting two warnings:

WARNING in ./node_modules/colors/lib/colors.js
131:29-43 Critical dependency: the request of a dependency is an expression
 @ ./node_modules/colors/lib/colors.js
 @ ./node_modules/colors/safe.js
 @ ./node_modules/winston/lib/winston/config.js
 @ ./node_modules/winston/lib/winston.js
 @ ./node_modules/aws-xray-sdk-core/lib/logger.js
 @ ./node_modules/aws-xray-sdk-core/lib/aws-xray.js
 @ ./node_modules/aws-xray-sdk-core/lib/index.js
 @ ./node_modules/aws-xray-sdk/lib/index.js
 @ ./resolvers.js
 @ ./handler.js

WARNING in ./node_modules/aws-xray-sdk-core/lib/patchers/call_capturer.js
45:32-47 Critical dependency: the request of a dependency is an expression
 @ ./node_modules/aws-xray-sdk-core/lib/patchers/call_capturer.js
 @ ./node_modules/aws-xray-sdk-core/lib/segments/attributes/aws.js
 @ ./node_modules/aws-xray-sdk-core/lib/aws-xray.js
 @ ./node_modules/aws-xray-sdk-core/lib/index.js
 @ ./node_modules/aws-xray-sdk/lib/index.js
 @ ./resolvers.js
 @ ./handler.js

@remicastaing
Copy link
Author

If I'm trying to use uglifyjs-webpack-plugin, I could not bring schema stitching (mergeSchemas from graphql-tools) to work.

@sid88in
Copy link
Contributor

sid88in commented Mar 29, 2018

Right now we are not using merge schemas but would use it in future. Maybe we can keep this issue open till we have an answer.

@remicastaing
Copy link
Author

If, like me, you encounter some issue by packaging some npm module, just use webpack-node-externals to get rid of it. They won't be packaged and uglifyed but are still there in the node_modules folder

(I dropped mergeSchemas from graphql-tools and I'm using mergeTypes from merge-graphql-schemas because the former won't go along with the error handling module graphql-apollo-errors.)

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

No branches or pull requests

2 participants