node-dtrace-provider
node-dtrace-provider copied to clipboard
ESBuild failed
When I use ESBuild with my project, it failed with the following error:
hospital/api % node build.js
✘ [ERROR] Could not resolve require("./src/build/**/*/DTraceProviderBindings")
node_modules/dtrace-provider/dtrace-provider.js:18:26:
18 │ var binding = require('./src/build/' + builds[i] + '/DTraceProviderBindings');
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error
/workspaces/hospital/api/node_modules/esbuild/lib/main.js:1476
let error = new Error(text);
^
Error: Build failed with 1 error:
node_modules/dtrace-provider/dtrace-provider.js:18:26: ERROR: Could not resolve require("./src/build/**/*/DTraceProviderBindings")
at failureErrorWithLog (/workspaces/hospital/api/node_modules/esbuild/lib/main.js:1476:15)
at /workspaces/hospital/api/node_modules/esbuild/lib/main.js:945:25
at /workspaces/hospital/api/node_modules/esbuild/lib/main.js:897:52
at buildResponseToResult (/workspaces/hospital/api/node_modules/esbuild/lib/main.js:943:7)
at /workspaces/hospital/api/node_modules/esbuild/lib/main.js:970:16
at responseCallbacks.<computed> (/workspaces/hospital/api/node_modules/esbuild/lib/main.js:622:9)
at handleIncomingPacket (/workspaces/hospital/api/node_modules/esbuild/lib/main.js:677:12)
at Socket.readFromStdout (/workspaces/hospital/api/node_modules/esbuild/lib/main.js:600:7)
at Socket.emit (node:events:520:28)
at addChunk (node:internal/streams/readable:559:12) {
errors: [Getter/Setter],
warnings: [Getter/Setter]
}
Node.js v22.8.0
Hey. Also, I have this problem. Please merge changes for fix
Hi,
actually as far as I understand the workaround authored by @CasperPas just makes the DTraceProviderBindings not being bundled.
As esbuild docs say (https://esbuild.github.io/api/#glob)
// This will be bundled
const json1 = require('./data/' + kind + '.json')
// This will not be bundled
const path = './data/' + kind + '.json'
const json2 = require(path)
Therefore, if one wants to opt-out from bundling dtrace-provider completely we can exclude it from the bundle using esbuild external option: https://esbuild.github.io/api/#external.
At least that worked for me.