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

Replace cosmiconfig with lilconfig to Work with Webpack #31

Closed
wants to merge 1 commit into from
Closed

Replace cosmiconfig with lilconfig to Work with Webpack #31

wants to merge 1 commit into from

Conversation

CHC383
Copy link

@CHC383 CHC383 commented Jun 10, 2024

Partially fix #29

Description

Webpack will try to bundle modules during compile time and replace the original require, so using require directly in the Webpack context to load configs could result in MODULE_NOT_FOUND error. next-logger uses the sync API of cosmiconfig to load its config, which internally uses import-fresh to handle the config loading, and import-fresh underneath uses the plain require. This has been causing the issues mentioned in #13 (comment) and #29

While trying to fix the issue (PR: sindresorhus/import-fresh#27), it seems that import-fresh is not actively maintained. lilconfig is a zero-dependency alternative to cosmiconfig with the same API and more lightweight, and just released a new version 3.1.2 with the same fix.

I am proposing to use lilconfig instead in this PR to fix the config loading issue and hopefully avoid some issues caused by legacy components in the future.

Testing

npm run test

Webpack will replace `require` and `import` by default, `lilconfig` is a zero-dependency laternative to `cosmiconfig` with the same API, and the most recent version handles the webpack case.
@CHC383
Copy link
Author

CHC383 commented Jun 14, 2024

Hi @atkinchris, could you please review this PR and the others? Thanks

@CHC383 CHC383 closed this Jun 17, 2024
@CHC383 CHC383 deleted the feat/process-stdout branch June 17, 2024 17:34
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.

it fails to import the winston logger.
2 participants