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

Remove moment as a dependency #11

Merged
merged 5 commits into from
Oct 12, 2024

Conversation

Souler
Copy link
Contributor

@Souler Souler commented Oct 4, 2024

For as simple as this koa-accesslog is; bringing moment into the dependency tree just to format a date felt a bit overkill.

This PR replaces moment with a local minimal implementation only with en support.

Why not using Intl?

Intl availability on runtime depends on how the node binary was built and how the process running was started (you can read more here). Since I did not want to couple the library to a specific icu setup; I decided to implement the minimal required code for the date formatting needs of the library.

## Would this be a breaking change?
To be honest: I'm not 100% sure. I have tried to keep the implementation as close as possible to what we had; but this PR would change how the short month is rendered for non-en configured systems. Not a big deal; but worht considering when decieding.

It is also worth noting this PR is indepentent from #10 but they would create a conflict with eachother because of the changes in the package-lock.json in the other PR.

Copy link
Member

@3imed-jaberi 3imed-jaberi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Souler Great job! I had a plan to remove 'moment' or keep it as peer deps. a while ago.

Here you can find a few refinement suggestions, could you please apply them and update all tests. once you do that, ping me to move forward!

format.js Outdated Show resolved Hide resolved
format.js Outdated Show resolved Hide resolved
format.js Show resolved Hide resolved
format.js Outdated Show resolved Hide resolved
format.js Outdated Show resolved Hide resolved
format.js Outdated Show resolved Hide resolved
format.js Outdated Show resolved Hide resolved
@Souler
Copy link
Contributor Author

Souler commented Oct 12, 2024

@3imed-jaberi I went ahead and addressed the naming suggestion and the unnecesary variable on toTwoDigit.

However I find myself arguing against the other two proposed changes (the object-map for months, and the array for joining the time). Happy to discuss them further so we can find an agreement.

format.js Outdated Show resolved Hide resolved
@3imed-jaberi 3imed-jaberi merged commit d172efe into koajs:master Oct 12, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants