Skip to content

Share between browser and node #45

Open
@fredfortier

Description

@fredfortier

I have to applications which import shared packages:

  • A frontend bundled for the browser with react-scripts
  • A nodejs backend

I'd like to move from console.log to log4js across both projects including the shared libraries. Ideally, I would create a log package that determines the runtime context, and initialize either log4js or log4js-node accordingly. Then, the logger would simply be imported pre-configured in all of my modules:

import log from log;

// This should just work because the logger is configured in the log package
log.info('foo');

Is this a valid design and are there examples of such implementation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions