Skip to content

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

Closed
@Muthuveerappanv

Description

@Muthuveerappanv

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcompletedThis item is complete and has been merged/shippedloggerThis item relates to the Logger Utility

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions