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 codepencency as a dependency, use builtin node features instead (fixing #35) #36

Merged
merged 5 commits into from
Mar 10, 2022

Conversation

davalentine-r7
Copy link
Contributor

Description

This change addresses #35 (comment) which highlights that the codependency module does not work when the library is imported using ES6 import syntax.

Testing

  1. Created a test package and npm linked this branch.
  2. Added "type": "module" to package.json
  3. Attempted to run module using ES6 import syntax -> Successful
  4. Removed "type": "module" from package.json
  5. Attempted to run module using CommonJS require syntax -> Successful

src/index.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated
"json-stringify-safe": "^5.0.1",
"lodash": "^4.17.15",
"reconnect-core": "^1.3.0"
},
"peerDependencies": {
"winston": "^3.2.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious here but what does the version pin do, in this case? Since it's a peer dependency and as such is not installed by this package, right?
Will it throw up an error now if a customer is using 3.1.x?

Copy link
Contributor

Choose a reason for hiding this comment

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

The NPM docs actually seem to indicate that this is the case;

Assuming the host complies with semver, only changes in the host package's major version will break your plugin. Thus, if you've worked with every 1.x version of the host package, use "^1.0" or "1.x" to express this. If you depend on features introduced in 1.5.2, use "^1.5.2".
https://docs.npmjs.com/cli/v7/configuring-npm/package-json#peerdependencies

I think we may need to figure out if we need a specific version or if just 3.x will do 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe they will get a warning about an unmet peer dependency rather than an error

Copy link
Contributor

Choose a reason for hiding this comment

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

If we can validate it works on all version in 3.x then that is fine to use. The reason this is the base as thats what it was tested with in the devDeps

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've just checked with version 3.0.0 at least and it works

@rjacobs-r7 rjacobs-r7 changed the title Remove codepencency as a dependency, use builtin node features instead Remove codepencency as a dependency, use builtin node features instead (fixing #35) Mar 9, 2022
Copy link
Contributor

@sbialkowski-r7 sbialkowski-r7 left a comment

Choose a reason for hiding this comment

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

if you could npm version patch too

package.json Outdated
"json-stringify-safe": "^5.0.1",
"lodash": "^4.17.15",
"reconnect-core": "^1.3.0"
},
"peerDependencies": {
"winston": "^3.x",
"winston-transport": "^4.3.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

considering we used to require 3.2.1+.... why are we now requiring an even higher version if we can probably work with both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this referring to #36 (comment) or?

Copy link
Contributor

Choose a reason for hiding this comment

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

nope. this sets a minimum version of 4.3.0 for winston-transport, right, whereas we worked with 3.2.1+ before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before it worked with * I believe, but again same as the other version limiting, this is what we have verified works as it's what our devDependencies use

package.json Outdated
@@ -1,6 +1,6 @@
{
"name": "r7insight_node",
"version": "3.2.0",
"version": "3.2.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

Had me confused here :D Version number of r7insight_node and winston lined up

Copy link
Contributor

Choose a reason for hiding this comment

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

btw you probably don't want to increase the version number here and in this way, as the git tags will get out of sync.
Also, we're quite possibly breaking compatibility here, so should this be a major?

Copy link
Contributor Author

@davalentine-r7 davalentine-r7 Mar 10, 2022

Choose a reason for hiding this comment

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

This change doesn't break compatibility(if you want to double check yourself, you can install this branch locally using yarn add git+https://github.com/rapid7/r7insight_node.git#fix-module-imports and see how it works with and without winston). I'll revert the package version change

@rjacobs-r7 rjacobs-r7 merged commit d9c941c into master Mar 10, 2022
@rjacobs-r7 rjacobs-r7 deleted the fix-module-imports branch March 10, 2022 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants