getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.87k stars 1.55k forks source link

Remove usage of `resolve` library #12860

Open AbhiPrasad opened 2 months ago

AbhiPrasad commented 2 months ago

Problem Statement

https://github.com/getsentry/sentry-javascript/blob/354977792e78789fc2823a169b95cd11e55b4c35/packages/nextjs/package.json#L83

The SDK requires Node 14.18+ as per https://github.com/getsentry/sentry-javascript/blob/354977792e78789fc2823a169b95cd11e55b4c35/packages/nextjs/package.json#L10

This means we can replace resolve library with native Node.js usage.

Solution Brainstorm

~Instead of using resolve, we can use import { createRequire } from 'module';. This is fine because we only need CJS resolution here.~

~See https://github.com/rollup/plugins/pull/1742 as an example PR doing this.~

AbhiPrasad commented 2 months ago

This eliminates 5 deps / 225 KB from the dep tree of the SDK: https://npmgraph.js.org/?q=resolve

AbhiPrasad commented 2 months ago

Looks like this does need esm resolution support!

We might need https://github.com/unjs/mlly instead

Zen-cronic commented 1 month ago

just a heads up @AbhiPrasad, mlly has a relatively similar dep graph and size to resolve.

5 deps: https://npmgraph.js.org/?q=mlly 232 kB: https://www.npmjs.com/package/mlly/v/1.7.1?activeTab=readme