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

Allow glob or regex strings for forceExclude option #1348

Open
rizowski opened this issue Jan 13, 2023 · 2 comments
Open

Allow glob or regex strings for forceExclude option #1348

rizowski opened this issue Jan 13, 2023 · 2 comments

Comments

@rizowski
Copy link

Feature Proposal

Description

Allow setting a glob pattern for forceExclude so we can exclude an entire namespaced package.

For feature proposals:

  • What is the use case that should be solved. The more detail you describe this in the easier it is to understand for us.

Moving onto Node 18 and fully trying to use @aws-sdk/*@V3 in the AWS lambda environment I need to exclude the entire @aws-sdk/* namespace to utilize the package installed in the environment. We've been blocked from fully migrating to the V3 package because serverless-webpack isn't excluding the entire lib like it does with aws-sdk v2. Even though @aws-sdk v3 is "modular" they still bring in a lot of their own @aws-sdk/@V3 as subdependencies.

Beyond that example, using lambda layers could also create a similar issue when bundling specific dependencies and publishing those independently of the main application. If those are namespaced, we can have the same problem.

  • If there is additional config how would it look

Glob:

custom:
  webpack:
    includeModules:
      forceExclude:
        - "@aws-sdk/*"

Regex:

custom:
  webpack:
    includeModules:
      forceExclude:
        - "^@aws-sdk"

Similar or dependent issue(s):
AFIK no one has requested it explicitly

Additional Data

  • Serverless-Webpack Version you're using: 5.11.0
  • Webpack version you're using: 5.75.0
  • Serverless Framework Version you're using: 3.25.1
  • Operating System: Mac OS 13.1
  • Stack Trace (if available):
@ifeltsweet
Copy link

As a temporary workaround, we moved @aws-sdk/* from devDependencies to production dependencies and added

custom:
  webpack:
    excludeRegex: 'node_modules/@aws-sdk'

We also added the packages we are using from the @AWS-SDK to webpack externals:

externals: ['@aws-sdk/client-s3', '@aws-sdk/client-sqs'],

This is not ideal because only the packages we explicitly list in the externals won't be bundled.

We've tried using a regex for externals such as /^@aws-sdk\/*/ but during packaging, we are getting the follow error:

error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.

I guess we could use noFrozenLockfile: true but I am not sure about the undesirable consequences of this.

@j0k3r
Copy link
Member

j0k3r commented Feb 17, 2023

The excludeRegex option alone is working pretty great for me as well (I'm using externals: [nodeExternals()], as well).

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

3 participants