Skip to content

Commit d949d6a

Browse files
committed
adding a warning, trying to fix linter
1 parent 5d7b45e commit d949d6a

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

integration-tests/esbuild.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ try {
2727
console.error(err)
2828
process.exit(1)
2929
} finally {
30-
process.chdir(CWD)
30+
process.chdir(CWD)
3131
}

integration-tests/esbuild/package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,9 @@
1616
"apm"
1717
],
1818
"author": "Thomas Hunter II <tlhunter@datadog.com>",
19-
"license": "ISC"
19+
"license": "ISC",
20+
"dependencies": {
21+
"esbuild": "0.16.12",
22+
"express": "^4.16.2"
23+
}
2024
}

packages/datadog-esbuild/index.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
'use strict'
2+
3+
// eslint-disable no-console
4+
15
const NAMESPACE = 'datadog'
26

37
const instrumented = Object.keys(require('../datadog-instrumentations/src/helpers/hooks.js'))
48
const rawBuiltins = require('module').builtinModules
59

10+
warnIfUnsupported()
11+
612
const builtins = new Set()
713

814
for (const builtin of rawBuiltins) {
@@ -37,7 +43,6 @@ module.exports.setup = function (build) {
3743
const pkg = require(pathToPackageJson)
3844

3945
if (DEBUG) {
40-
// eslint-disable-next-line no-console
4146
console.log(`resolve ${packageName}@${pkg.version}`)
4247
}
4348

@@ -64,7 +69,6 @@ module.exports.setup = function (build) {
6469

6570
build.onLoad({ filter: /.*/, namespace: NAMESPACE }, args => {
6671
if (DEBUG) {
67-
// eslint-disable-next-line no-console
6872
console.log(`load ${args.path}@${args.pluginData.version}`)
6973
}
7074

@@ -88,3 +92,13 @@ module.exports.setup = function (build) {
8892
}
8993
})
9094
}
95+
96+
function warnIfUnsupported () {
97+
const [major, minor] = process.versions.node.split('.').map(Number)
98+
if (major < 14 || (major === 14 && minor < 17)) {
99+
console.error('WARNING: Esbuild support isn\'t available for older versions of Node.js.')
100+
console.error(`Expected: Node.js >= v14.17. Actual: Node.js = ${process.version}.`)
101+
console.error('This application may build properly with this version of Node.js, but unless a')
102+
console.error('more recent version is used at runtime, third party packages won\'t be instrumented.')
103+
}
104+
}

0 commit comments

Comments
 (0)