Skip to content

Commit

Permalink
Remove the mysql2 package peer dependency (#695)
Browse files Browse the repository at this point in the history
This peer dependency was previously added to fix the build for the
OpenTelemetry mysql2 package instrumentation. In the TypeScript build of
this package it would import the mysql2 types in the
`@opentelemetry/instrumentation-mysql2` package, which we import.

The `@opentelemetry/instrumentation-mysql2` package itself has no
runtime dependency on the mysql2 package, and neither does
`@opentelemetry/auto-instrumentations-node`. Which got me interested to
find out how that package works if we're experiencing the problem
described in PR #688

> Control packages peer dependencies
> We need mysql2 as a peer dependency of the package because the
> OpenTelemetry instrumentation library requires it. This could be fixed
> with introspection using require-in-the-middle.

Instead I've moved it to the devDependencies list to fix the build and
remove the dependency for users that do not use the mysql2 package in
their app.

I've then tested it in a TypeScript example app
appsignal/opentelemetry#29 that doesn't use
mysql2. The AppSignal package works without mysql2 as a peer dependency
in this scenario.
  • Loading branch information
tombruijn committed Jun 22, 2022
1 parent c05d2f5 commit a1d947c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 32 deletions.
6 changes: 6 additions & 0 deletions .changesets/remove-mysql2-peer-dependency.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
bump: "patch"
type: "change"
---

Remove the mysql2 package peer dependency. It's not only present as a development dependency for the package.
58 changes: 29 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
"tslib": "^2.0.3",
"winston": "^3.6.0"
},
"peerDependencies": {
"mysql2": "*"
},
"devDependencies": {
"mysql2": "*",
"@types/jest": "^26.0.19",
"@typescript-eslint/eslint-plugin": "^5.13.0",
"@typescript-eslint/parser": "^5.13.0",
Expand Down

0 comments on commit a1d947c

Please sign in to comment.