-
Notifications
You must be signed in to change notification settings - Fork 150
Can't be bundled with Webpack when DefinePlugin is used #91
Comments
same issue here. we are using node 4.3 in Lambda. Code is compiled using webpack and babel with preset es2015. When we run there's 2 errors traced: Error 2: any pointers would be wonderful. Thanks |
@chiplay This doesn't look like an error with @pdkn Same here, I think, because the stack trace doesn't have references to |
Closing this issue for now. Make sure to try out the latest release (https://github.com/segmentio/analytics-node/releases/tag/v3.0.0)! If the advice above doesn't help, feel free to open a new issue. |
Hi @vadimdemedes I've just upgraded to 3.0 from 2.4 and tried to bundle analytics-node into the webpack build. Alas it throws this warning: and then when running the code in Lambda (Node 6.10): If we don't bundle the lib into the webpack bundle but keep as external lib then it works Class & Webpack config Attached: |
The webpack error isn't for
This is more likely an error with your code, because it's not a valid JS. If you search in your editor for |
yup, but 'formidable' is a dependency of 'superagent' which is a dependency of analytics-node. |
This is a good find, @pdkn! But, even though, the bundle will still compile just fine. |
that's right, the bundle compiles fine, but when we run the code in Lambda it errors. |
I can't find any references to "true" = namespaces yet but will keep hunting |
Here's the problem: debug-js/debug#467. The combination of webpack's |
I'm fine with removing EDIT: I don't think removing |
isomorphic-fetch seems to be all the rage these days. |
|
I'd remove |
+1 to @stephenmathieson's comment. |
Was going to mention superagent is a bit of a beast. 'Got' sounds better. I tend to roll my own with vanilla node http & promises. Good article here on dependency tree https://www.tomas-dvorak.cz/posts/nodejs-request-without-dependencies/ |
does |
It should work with browserified Node.js modules (like |
also, see my edit in #91 (comment); just removing |
Bear in mind this lib is called analytics-node. Shouldn't people be using analytics.js for browser? |
I'd agree, but we (Segment) don't have a great solution for people who want to use commonjs/modules for everything, and those who can't dirty the global namespace (what if your company has a "widget" other people use on their sites). using analytics-node works fine in these scenarios. also, since it works now, it'd be (another) breaking change to drop support for browserify/webpack/etc, which I don't think would be a good move just yet |
Oops, I forgot about #91 (comment). There's a way to workaround |
For the record I def don't recommend breaking changes for others ;) I hadn't looked at analytics.js and didn't realize it wasn't commonjs/modules. Bare in mind we have a solution at the moment by setting the lib as an external and then copying it into the bundle. (see webpack config zip up the thread). We just want to avoid this step for code hygiene (and so others don't have same issues). |
|
I'm in favor of any of these XHR libraries, but just to throw another name in the ring: I had luck using axios for doing back front and backend requests with the same library. |
@stephenmathieson not that I've heard of recently - thanks for checking in. |
Closing this since the underlying issue is resolved now. |
No, we're still using |
We are using
analytics-node
in our AWS Lambda function and last night started receiving errors:Looks like some change between 2.1.1 and 2.3.0 is breaking the import/require for us. Unfortunately lambda error stacks are pretty obscure - any ideas?
The text was updated successfully, but these errors were encountered: