Skip to content

Bug: Importing Common Index in Logger Folder raises Module Error #664

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

Closed
Muthuveerappanv opened this issue Mar 14, 2022 · 3 comments · Fixed by #882
Closed

Bug: Importing Common Index in Logger Folder raises Module Error #664

Muthuveerappanv opened this issue Mar 14, 2022 · 3 comments · Fixed by #882
Assignees
Labels
bug Something isn't working completed This item is complete and has been merged/shipped logger This item relates to the Logger Utility

Comments

@Muthuveerappanv
Copy link
Contributor

Bug description

  1. npm production package of `powetools-logger' is breaking in 0.0.7, due to importing commons package in Logger.ts
  2. Error due to the tests export that are part of the commons/index

Expected Behavior

0.0.7 version to work fine without module error when tests folder are removed at the time of pruning for production-ready build
(Or if the package tests being exported out of commons is needed, please rename the folder as pruning utilities like node-prune are trimming off tests)

Current Behavior

No Module Found Error when using Powertools Logger package

stack": [
        "Runtime.ImportModuleError: Error: Cannot find module './tests/resources/contexts'",
        "Require stack:",
        "- /var/task/node_modules/@aws-lambda-powertools/commons/lib/index.js",
        "- /var/task/node_modules/@aws-lambda-powertools/logger/lib/Logger.js",
        "- /var/task/node_modules/@aws-lambda-powertools/logger/lib/index.js",

Possible Solution

  1. Do not export tests
  2. Or if the package tests needs to be exported, please rename the folder as pruning utilities like node-prune are trimming off tests)

Steps to Reproduce

  1. npm install project with "@aws-lambda-powertools/logger": "^0.7.0"
  2. node-prune using https://github.com/tj/node-prune

Environment

  • Powertools version used: 0.0.7
  • Packaging format (Layers, npm): npm
  • AWS Lambda function runtime: : nodejs 14.x
  • Debugging logs:
    Screen Shot 2022-03-14 at 11 50 46 AM
@Muthuveerappanv Muthuveerappanv added bug Something isn't working triage This item has not been triaged by a maintainer, please wait labels Mar 14, 2022
@flochaz flochaz self-assigned this Mar 16, 2022
@dreamorosi
Copy link
Contributor

Hi @Muthuveerappanv

first of all, thanks a lot for reporting the issue and also apologies for the delay in acknowledging it from our side. We have been busy at polishing the utilities to prepare for the launch.

I have looked at the issue reported and I was able to reproduce it.

I'll leave here a link to a repo where I was able to reproduce and document the steps for the person who will resolve the issue: https://github.com/dreamorosi/test-664

Muthuveerappanv pushed a commit to Muthuveerappanv/aws-lambda-powertools-typescript that referenced this issue May 16, 2022
@Muthuveerappanv
Copy link
Contributor Author

Muthuveerappanv commented May 16, 2022

Hi @Muthuveerappanv

first of all, thanks a lot for reporting the issue and also apologies for the delay in acknowledging it from our side. We have been busy at polishing the utilities to prepare for the launch.

I have looked at the issue reported and I was able to reproduce it.

I'll leave here a link to a repo where I was able to reproduce and document the steps for the person who will resolve the issue: https://github.com/dreamorosi/test-664

@dreamorosi I created a PR to import Utility components from /lib instead of top level pacakge. Let me know if this will do.

@github-actions
Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@dreamorosi dreamorosi removed the triage This item has not been triaged by a maintainer, please wait label Oct 19, 2022
@dreamorosi dreamorosi changed the title Bug (logger): Importing Common Index in Logger Folder raises Module Error Bug: Importing Common Index in Logger Folder raises Module Error Nov 14, 2022
@dreamorosi dreamorosi added logger This item relates to the Logger Utility completed This item is complete and has been merged/shipped labels Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working completed This item is complete and has been merged/shipped logger This item relates to the Logger Utility
Projects
None yet
4 participants