-
Notifications
You must be signed in to change notification settings - Fork 306
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
Feature Request: Webpack Support #827
Comments
Alright, by now I figured out I had to externalize the node_modules using webpack-node-externals. Is this a required step in the setup? If it is, it should probably be mentioned in the setup instructions, no? |
We could indeed recommend this module when using Webpack. It's possible that it won't be possible to use it in some setups, but I think it would work for most cases. In all honesty, I didn't know about this module which is the why it's not currently documented, so thanks for the tip! |
I'm not sure whether we're getting bitten by something similar - kinda a newb here - but we use babel to transpile our ES6 before shipping it. Would this be affecting us too - I realize, naturally, that we're not talking about WebPack, but I figure it can't hurt to ask. |
Hi @armenr If you're just using babel to transpile ES6 to JS and are not bundling, you probably get bitten by something else... |
@mruoss - I've used PKG, NCC, and NEXE - and have been bitten in ALL three cases by EXACTLY what you've been bitten by. I moved our entire setup (dev & prod) to Docker, JUST to get a "vanilla" set up, as an attempt to benefit from auto-instrumentation...but it doesn't look like it's instrumented fully.
:) - How can I go about finding out? |
If you have no node_modules folder inside your docker image, this is your issue. |
Alright, see the referenced issue above. Bundling node modules is not supported by the |
@armenr Simply using Babel should not cause any problems, although you have to make sure to avoid hoisting, similar to what we recommend for TypeScript in the setup docs, otherwise auto-instrumentation will not work properly. |
Thanks for the quick and helpful response, @rochdev! :) We utilize an entrypoint file to fire up our NodeJS APIs in the following pattern/manner:
Is this sufficient/correct? |
@armenr Assuming that the tracer is initialized synchronously in |
@rochdev -- synchronously, yes. --> see below
|
Hey @mruoss how could you fix that to use dd-trace in your webpack application? I've been falling in the same problem here a few days... |
my webpack config currently looks like this: import nodeExternals from 'webpack-node-externals'
const config = {
entry: '...',
externals: [nodeExternals()],
... other_configuration
} |
I've also encountered this problem with node10 and dd-trace while trying to bundle with webpack: ERROR in ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/transforms.js
Module not found: Error: Can't resolve 'graphql/language/printer' in '/home/maschmann/git<package>/node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools'
@ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/transforms.js 10:18-53
@ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/signature.js
@ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/index.js
@ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/index.js
@ ./node_modules/dd-trace/packages/dd-trace/src/plugins/index.js
@ ./node_modules/dd-trace/packages/dd-trace/src/platform/node/index.js
@ ./node_modules/dd-trace/packages/dd-trace/index.js
@ ./node_modules/dd-trace/index.js
@ ./app.js
@ multi ./app.jsERROR in ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/transforms.js
Module not found: Error: Can't resolve 'graphql/language/visitor' in '/home/maschmann/git/<package>/node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools'
@ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/transforms.js 9:18-53
@ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/signature.js
@ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/index.js
@ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/index.js
@ ./node_modules/dd-trace/packages/dd-trace/src/plugins/index.js
@ ./node_modules/dd-trace/packages/dd-trace/src/platform/node/index.js
@ ./node_modules/dd-trace/packages/dd-trace/index.js
@ ./node_modules/dd-trace/index.js
@ ./app.js
@ multi ./app.jsERROR in ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/transforms.js
Module not found: Error: Can't resolve 'graphql/utilities' in '/home/maschmann/git/<package>/node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools'
@ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/transforms.js 11:20-48
@ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/signature.js
@ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/tools/index.js
@ ./node_modules/dd-trace/packages/datadog-plugin-graphql/src/index.js
@ ./node_modules/dd-trace/packages/dd-trace/src/plugins/index.js
@ ./node_modules/dd-trace/packages/dd-trace/src/platform/node/index.js
@ ./node_modules/dd-trace/packages/dd-trace/index.js
@ ./node_modules/dd-trace/index.js
@ ./app.js |
We also ran into this issue adding Let us know if you need more information @rochdev.
|
Until a fix is made, our team found a temporary workaround for Angular 9 CLI & webpack when using Angular Universal (server-side rendering). Created an externals reference:
And added a
|
We're running into the same issue as @kalebdf and @maschmann - webpack is failing for our server-side project. We're following the guidance here https://docs.datadoghq.com/tracing/setup/nodejs/ |
For For |
Thanks for responding and for this package! I'll be blunt and ask, any update @rochdev ? |
@amitizle Are you referring to the issue with |
@rochdev yes it is. |
@amitizle Ok, for some reason I assumed it was fixed. I'll look into it this week. |
@amitizle I tried to take a quick look at the dependency tree but nothing stood out. I'm not super well versed Webpack wise, could you create a small replication snippet I could use as the basis of the investigation? |
@rochdev me neither 😄 |
I think I found the issue with the spdx-* dependencies :
Hope it solves the problem for everyone! |
I am using nestjs monorepo webpack build. const mergedOptions = merge(options, {
resolve: {
extensions: ['.js', '.ts', '.json'],
},
plugins: [
new webpack.IgnorePlugin({
checkResource(resource) {
const lazyImports = [
//...
'graphql/language/printer',
'graphql/language/visitor',
'graphql/utilities',
'spdx-exceptions',
'spdx-license-ids',
'spdx-license-ids/deprecated',
];
if (!lazyImports.includes(resource)) {
return false;
}
try {
require.resolve(resource, {
paths: [process.cwd()],
});
} catch (err) {
return true;
}
return false;
},
}),
],
}); |
We've removed the dependency on |
We had the same issue with dd-trace like @maschmann had. The solution was that we had to set externals for those graphql packages within the webpack config file.
This resolved the issue for us. |
Hi team, we are having a simlilar issue with dd-trace for a large number of Lambda's which are running on NodeJS. They are created using Yarn 2 and webpack to a single index.js file. Because of the treeshaking and nature of the Yarn PnP we don't have any node_modules, so using webpack-node-externals isn't an option either - as we don't have any node_modules to copy in the zip we place on AWS Lambda. In case a fix in the library or its dependencies isn't possible, is there any alternative workaround in existence? |
@vanseverk There was a mention in another issue of webpack-pnp-externals, I would give that a try for now. We do plan to support Webpack and PnP officially eventually but not in the short term. |
Note that if bundling is important for your application that we do now have official esbuild support. |
Hi there. I set up dd-trace according to the setup instructions and find that modules like http or express are not instrumented. I tried to find out the reason, digging in some of the dd-trace code and finding that e.g. express is not in the
require.cache
because it only contains numeric values. Although I did not find anything in the instructions about it, I set the webpack optimizationmoduleIds
tonamed
. Now I see node module paths inrequire.cache
but still express is not there.Is this a known problem? Am I doing somehting wrong here?
Thanks,
Michael
Environment
The text was updated successfully, but these errors were encountered: