Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minified build #100

Open
StErMi opened this issue May 30, 2020 · 11 comments
Open

minified build #100

StErMi opened this issue May 30, 2020 · 11 comments
Labels
question Further information is requested

Comments

@StErMi
Copy link

StErMi commented May 30, 2020

Hi, I was comparing the result of the serverless-bundle (I'm using the beta branch because I'm using typescript to develop) with serverless-plugin-ncc and I see that the final bundle of serverless-bundle is quite havier compared to serverless-plugin-ncc

index.js from serverless-bundle is 2,319KB
index.js from serverless-plugin-ncc is 1,105KB

I don't know internally if there are differences but as far as I can see it's not possible to minify the serverless-bundle output.

So I've two questions:

  1. would it be possible to add that option to serverless-bundle?
  2. have you ever thought to create an ncc plugin? (because I know guys that you are damn amazing in support serverless and I would like to see something from your own!). serverless-plugin-ncc seems to not support serverless-offline and many cool things that come from your bundle plugin.
@jayair
Copy link
Member

jayair commented May 30, 2020

When I had first worked on serverless-bundle, I had worked on minimizing. But it seemed to slow down the build times by a lot. If you are interested in taking this on, I would start by using https://www.npmjs.com/package/webpack-bundle-analyzer to compare the two outputs.

For question 2, I'm not totally sure what you mean. What do you think serverless-bundle is doing different from serverless-plugin-ncc?

@jayair jayair added the question Further information is requested label May 30, 2020
@thomaschaaf
Copy link
Contributor

thomaschaaf commented Feb 4, 2021

Maybe we can use a version without mangling and compression:

        { minimize: true,  minimizer: [
          new TerserPlugin({
            cache: true,
            parallel: true,
            sourceMap: ENABLE_SOURCE_MAPS,
            terserOptions: {
              mangle: false,
              compress: false,
            }
          })
        ] },

this results in the comments being removed which already helps alot!

@remcoabalain
Copy link

Hi, any updates on this? We would like to use minified build files.

Also wondering, maybe not on topic here, but it seems like all optimizations are turned off. Our files are really big after compiling and includes all imported code. Does tree shaking not work in the current webpack setup?

@thomaschaaf
Copy link
Contributor

V5 Beta has minification enabled 🙂

@remcoabalain
Copy link

@thomaschaaf Thanks! Seems to work 😄

@chris-hinds
Copy link

So glad I just found this issue, Just got to a point where I realised my serverless functions were including code that I had not imported from a shared lib which obviously meant tree shaking wasn't working.

This seems to be solved in the latest v5 beta. Nice work.

@marianocodes
Copy link

In case you don't want to move to V5 Beta yet, use serverless-plugin-optimize which in my case actually outputs a smaller bundle

@rogueturnip
Copy link

Is there a way to disable minimization? I'm using serverless-mysql in my code and get the following error:

Received packet in the wrong sequence

It seems like this is an issue with webpack minimization because rolling back to 4.4.0 fixes the issue

@spidgorny
Copy link

Related issue: mysqljs/mysql#1655

@sromic
Copy link

sromic commented Dec 29, 2022

Is there a way to disable minimization? I'm using serverless-mysql in my code and get the following error:

Received packet in the wrong sequence

It seems like this is an issue with webpack minimization because rolling back to 4.4.0 fixes the issue

this could be mitigated using the esbuild instead of babel, e.g. with the following config (keepNames set to true is the key point here):

  bundle:
    caching: true
    esbuild: true
    minifyOptions:
      keepNames: true

@beniusij
Copy link

Can confirm this fixed the problem with packets in the wrong sequence. Cheers @sromic!

bundle:
  minifyOptions:
    keepNames: true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

10 participants