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

fix(commons) prune issue - fix #664 #881

Conversation

Muthuveerappanv
Copy link
Contributor

@Muthuveerappanv Muthuveerappanv commented May 16, 2022

Importing Common Index in Logger Folder raises Module Error #664

  • Import Commons Utility from the commons using import { Utility } from '@aws-lambda-powertools/commons/lib/Utility'; instead of directly from the package's index
  • The index exports contain tests/resources references. Pruning tools removes tests folder within the code during build
  • Hence importing the Utility directly from its inner package

How to verify this change

Related issues, RFCs

#664

PR status

Is this ready for review?: NO
Is it a breaking change?: NO

Checklist

  • My changes meet the tenets criteria
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in areas that should be flagged with a TODO, or hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding changes to the examples
  • My changes generate no new warnings
  • The code coverage hasn't decreased
  • I have added tests that prove my change is effective and works
  • New and existing unit tests pass locally and in Github Actions
  • Any dependent changes have been merged and published in downstream module
  • The PR title follows the conventional commit semantics

Breaking change checklist

  • I have documented the migration process
  • I have added, implemented necessary warnings (if it can live side by side)

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@flochaz
Copy link
Contributor

flochaz commented May 23, 2022

Hi @Muthuveerappanv thanks for this. For now I proposed to rename the folder #882 which indeed make more sense that way. That will fix your issue as well if I am not mistaken, right ?
we will review your proposal in more details asap.

@ijemmy
Copy link
Contributor

ijemmy commented May 23, 2022

I'm wondering if we should even publish the common package to npm. We just use direct reference everywhere.

Advantages:

  1. No worry about wrong version.
  2. One less package/dependency to manage.
  3. Leaner overall packages (e.g. we don't need any of the Events and Context outside of test)

Not sure if I miss any disadvantage here? @saragerion , @flochaz , @dreamorosi

Search result on where it's used.
image

@dreamorosi
Copy link
Contributor

Currently, as a customer when I install @aws-lambda-powertools/tracer & @aws-lambda-powertools/logger (or any combinations of the two), npm is able to deduplicate commons and as long as the versions match there will be only one in the node_folders.

If we use references (i.e. not a package), I think they are going to have the source code for say Utility twice: one for Tracer and one for Logger.

@Muthuveerappanv
Copy link
Contributor Author

Hi @Muthuveerappanv thanks for this. For now I proposed to rename the folder #882 which indeed make more sense that way. That will fix your issue as well if I am not mistaken, right ? we will review your proposal in more details asap.

yes, renaming will solve issue currently with pruning.

@saragerion
Copy link
Contributor

Hi @Muthuveerappanv, thanks for taking the time for opening this PR. We have already another PR that will solve this issue. I will close this one as it's a duplicate.

@saragerion saragerion closed this May 24, 2022
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

Successfully merging this pull request may close these issues.

5 participants