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

Share between browser and node #45

Open
fredfortier opened this issue Jun 24, 2020 · 0 comments
Open

Share between browser and node #45

fredfortier opened this issue Jun 24, 2020 · 0 comments

Comments

@fredfortier
Copy link

fredfortier commented Jun 24, 2020

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?

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

1 participant