GoogleCloudPlatform / stackdriver-errors-js

Client-side JavaScript exception reporting library for Cloud Error Reporting
https://cloud.google.com/error-reporting/
Apache License 2.0
362 stars 54 forks source link

Provide JS module #2

Closed steren closed 5 years ago

steren commented 8 years ago

Installing via a script is not the preferred way to install dependencies in a modern web application.

Developers should be able to use the library by importing a module in their application.

We should be compatible with the common module conventions (AMD, CommonJS, JS modules?)

oshalygin commented 7 years ago

I'd love to get started on something like this, and with the help wanted label, are you still open to a PR?

steren commented 7 years ago

Yes of course, any help is appreciated. Feel free to submit a PR

evanjmg commented 7 years ago

Is there any usage instructions for npm? I can't use it as a module unless I know how to use it as such. A simple import did not work. Please add to readme

mikelambert commented 7 years ago

It's not a real npm package, but:

npm install github:GoogleCloudPlatform/stackdriver-errors-js --save

And then:

import { StackdriverErrorReporter } from 'stackdriver-errors-js';

works for me.

steren commented 7 years ago

Thanks. I suppose this is ES6 syntax right? Feel free to send a PR to add this info to https://github.com/GoogleCloudPlatform/stackdriver-errors-js/blob/master/README.md#setup-for-javascript

mikelambert commented 7 years ago

Ideally you would 'npm publish' this repo up to the npm servers, and then repush it as needed with semver. Someone else could do that, but then that someone would become the 'de facto' owner of your NPM package (and potentially do bad things), so I'd recommend you learning and doing the npm publish yourself.

The syntax I've listed is an npm client workaround that pulls from git HEAD (unversioned) instead of from the npm servers.

steren commented 7 years ago

the library is on npm: https://www.npmjs.com/package/@google-cloud/error-reporting

What this issue is about is to provide a JS module in a more JS idiomatic way.

mikelambert commented 7 years ago

Ahhh sorry, I totally misunderstood, apologies for the basic reply above. I'm using it in an idiomatic way at the moment with my webpack build, so I think I assumed that this wasn't about that. But I pull from my own GitHub repo (with that pull request I just sent in)...thats why I was assuming this didn't exist on npm.

iozeen commented 6 years ago

@mikelambert doesn't work for me, throws error: Uncaught Error: make sure you loaded “dist/stackdriver-errors-concat.js” or “dist/stackdriver-errors-concat.min.js”, or that you imported the “stacktrace-js” module All I want is to import it via ES6 and use it as util module in my react application

Jastrzebowski commented 6 years ago

@iozeen Check @ties answer in #15, not nice but working. We should work on the module, I would suggest UMD (like stacktrace-js)

patelnav commented 5 years ago

@Jastrzebowski : Not sure when a PR that fixes this will hit the main branch, but the shenanigans fix to this:

import * as StackTrace from 'stacktrace-js';
window.StackTrace = StackTrace