-
Notifications
You must be signed in to change notification settings - Fork 29
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
fix: Use url-join instead of urljoin #342
Conversation
libhoney is pulling in a helper library called urljoin to fuse URL components together. urljoin expects to be run in a Node environment, and uses the Node standard library (notably the path module). Because of this dependency, libhoney fails for us when run under Webpack 5, which no longer bundles Node libraries in. This PR swaps urljoin out for an alternative library with equivalent functionality, called url-join. url-join has no dependencies, and is newer than urljoin and still maintained. Because it's new, it uses ES Modules; I needed to configure Jest to use Babel to transform it.
Just saw that this is failing a check because it needs a proper prefix in its title. I'm going to update this to be a "fix:", although I'm not sure if it should be a "maint:" or "chore:" instead. Happy to make any changes requested 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR! The dependency change looks good. Can we leave the babel config format as is for the moment?
babel.config.js
Outdated
@@ -1,4 +1,4 @@ | |||
{ | |||
module.exports = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, not sure if we want the config as JS or JSON. is this change necessary as part of this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So AFAICT Jest does not pick up the babel configuration in .babelrc
, only in babel.config.js
. Without this change, Jest won't have Babel process url-join
, which causes tests to syntax error on the ES Modules syntax. There's some discussion about this here.
I promise I get zero joy out of making changes to other project's build configurations, I didn't make this change for the fun of it! 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, boo. That makes sense. In that case, I'm just going to suggest a small tweak to syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I'll just push that as a commit.
Which problem is this PR solving?
libhoney is pulling in a helper library called urljoin to fuse URL components together. urljoin expects to be run in a Node environment, and uses the Node standard library (notably the path module). Because of this dependency, libhoney fails for us when run under Webpack 5, which no longer bundles Node libraries in.
Short description of the changes
This PR swaps urljoin out for an alternative library with equivalent functionality, called url-join. url-join has no dependencies, and is newer than urljoin and still maintained.
Because it's new, it uses ES Modules; I needed to configure Jest to use Babel to transform it.