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

Option to skip packaging externals #152

Closed
samrith-s opened this issue Jun 25, 2021 · 5 comments
Closed

Option to skip packaging externals #152

samrith-s opened this issue Jun 25, 2021 · 5 comments

Comments

@samrith-s
Copy link

Hey,

I have these options in my SLS config:

package:
    exclude:
        - 'cache-manager'
        - 'class-transformer'
        - 'class-validator'
        - '@nestjs/microservices'
        - '@nestjs/websockets'
    individually: true
custom:
    esbuild:
        bundle: true
        minify: true
        keepNames: true
        sourcemap: true
        external:
            - 'cache-manager'
            - 'class-transformer'
            - 'class-validator'
            - '@nestjs/microservices'
            - '@nestjs/websockets'
        plugins: 'esbuild.plugins.js'

However, once it bundles, it runs this:

Packing external modules: cache-manager, class-transformer, class-validator, @nestjs/microservices, @nestjs/websockets

I want to completely skip it as these packages are opt-in in NestJS. Is there any way to achieve it? I see from the code that this plugin packages externals. Is there any way to completely skip them?

@vamche
Copy link
Contributor

vamche commented Jun 28, 2021

Hello @samrith-s

You can list modules in the external section to not include them in the final artifact.

The package specified in the exclude option is passed to esbuild as external, but it is not included in the function bundle either. The default value for this option is ['aws-sdk'].

Please let me know if that works for you.

@samrith-s
Copy link
Author

Hey @vamche ,

Thanks for your response. Afaik, I am already doing that. All the packages are listed in custom.esbuild.external and package.exclude, yet it packages them.

@vamche
Copy link
Contributor

vamche commented Jun 28, 2021

@samrith-s I was talking about the serverless-esbuild config. Could you please list them in custom.esbuild.external and try?

   custom:
    esbuild:
        bundle: true
        minify: true
        keepNames: true
        sourcemap: true
        external:
            - 'cache-manager'
            - 'class-transformer'
            - 'class-validator'
            - '@nestjs/microservices'
            - '@nestjs/websockets'
        exclude:
            - 'cache-manager'
            - 'class-transformer'
            - 'class-validator'
            - '@nestjs/microservices'
            - '@nestjs/websockets' 
        plugins: 'esbuild.plugins.js'

@vamche
Copy link
Contributor

vamche commented Jul 12, 2021

@samrith-s Did you get a chance to try with custom.esbuild.external?

@vamche
Copy link
Contributor

vamche commented Aug 9, 2021

Closing the issue since there is no activity anymore.

@vamche vamche closed this as completed Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants