immobiliare/fastify-sentry

Cannot use in bundled application - missing package.json

bagr001 opened this issue ยท 4 comments

Hi, thank you for your work, I love your integration.

I used this plugin in my app that is bundled into single file during build, but i stumbled on an obstacle.
During runtime, there si require call for package.json via relative path, which cannot be bundled at current state.

Is there a possibility to change this behavior to support code bundling?

I've tested one sollution. Changing

const PACKAGE_NAME = require(path.resolve(__dirname, 'package.json')).name;

to

const PACKAGE_NAME = require('./package.json').name;

would help :-)

Thanks!

const PACKAGE_NAME = require(path.resolve(__dirname, 'package.json')).name;

dnlup commented

Hi @bagr001 , thank you for opening this. Yes it's possible, PRs are welcome if you have the time to work on it ๐Ÿ˜‰ . Otherwise I'll look into it

dnlup commented

We could also just hardcode the plugin name in the exports ๐Ÿ˜‰

We could also just hardcode the plugin name in the exports ๐Ÿ˜‰

Yep, I second this, it's just a string that won't change, we'll one less thing to worry about if/when moving to ESM ๐Ÿ‘

dnlup commented

This should be fixed now, thanks @bagr001