Title: [build] Bundle monorepo dependencies in npm packages · Issue #5886 · getsentry/sentry-javascript · GitHub
Open Graph Title: [build] Bundle monorepo dependencies in npm packages · Issue #5886 · getsentry/sentry-javascript
X Title: [build] Bundle monorepo dependencies in npm packages · Issue #5886 · getsentry/sentry-javascript
Description: Problem Statement In spite of the fact that - theoretically - updating one of our top-level packages (@sentry/browser, @sentry/node, and all framework-specific packages) should also update all monorepo dependencies (@sentry/utils, @sentr...
Open Graph Description: Problem Statement In spite of the fact that - theoretically - updating one of our top-level packages (@sentry/browser, @sentry/node, and all framework-specific packages) should also update all mono...
X Description: Problem Statement In spite of the fact that - theoretically - updating one of our top-level packages (@sentry/browser, @sentry/node, and all framework-specific packages) should also update all mono...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/5886
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[build] Bundle monorepo dependencies in npm packages","articleBody":"### Problem Statement\r\n\r\nIn spite of the fact that - theoretically - updating one of our top-level packages (`@sentry/browser`, `@sentry/node`, and all framework-specific packages) should also update all monorepo dependencies (`@sentry/utils`, `@sentry/core`, etc), it's come up as a problem multiple times that this doesn't always happen. As a result, people end up with crashes when, for example, a newer version of `@sentry/browser` calls upon a recently-added hub method, an older version of `@sentry/hub` is still installed, and the user ends up with a `undefined is not callable` error.\r\n\r\nThis never comes up as a problem for people using our CDN bundle, because in that case all monorepo dependencies are included in the bundle.\r\n\r\n### Solution Brainstorm\r\n\r\nTo solve this, let's include our monorepo dependencies in our npm packages the same way we do in our bundles. We can still publish the dependencies as separate packages, for anyone who specifically needs them (people building community SDKs for frameworks we don't support, for example), but we'd stop listing them as runtime dependencies.\r\n\r\n\r\n---------\r\n\r\nUPDATE: This is going to be trickier than I thought.\r\n\r\nLeaving a note here for myself, of things I've tried which have not yet worked, for when I come back to this:\r\n(tried with building nextjs SDK and bundling either utils or react packages)\r\n- move package to dev deps, don’t mark dev deps as external (adjust output for templates, loaders, adjust script to copy file to correct location)-> build/esm and build/cjs contain nextjs dir, dir for each non-external package, but doesn't work because other packages only contain esm, not cjs\r\n- symlink src folder from other package as nextjs/src/packages/\u003cpackagename> and change imports to point to that -> files from other package don't get included in build\r\n- symlink src/index.ts from other package into nextjs/src/packages/\u003cpackagename> and change imports to point to `./packages/\u003cpackagename> -> complains it can't find the module (not reading through symlink)\r\n- copy contents of other package src folder into nextjs/src/packages/\u003cpackagename> -> need to add all of other package's deps to nextjs package deps, turn on flags from other package builds (like jsx for react package)\r\n- copy correct files into build/esm and build/cjs folders, use `output.paths` rollup option to rewrite import to point to that folder -> replacement is hardcoded, so doesn't account for differences in relative path\r\n\r\nAlternative option: Crate post-install script to verify versions of all deps, warn or error if out of sync (Not perfect - some people turn off scripts - but a lot better than nothing)","author":{"url":"https://github.com/lobsterkatie","@type":"Person","name":"lobsterkatie"},"datePublished":"2022-10-05T14:12:02Z","url":"https://github.com/getsentry/sentry-javascript/issues/5886"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e4b05b6c-bb14-af12-4108-e80183f49e14 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DAAE:20A7C6:486049:5FFFDD:6B04DA02 |
| html-safe-nonce | 7d31e9b792ec30befdf3d141ae45818eb1c94aa7ecf133c8494a3c22420aceda |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQUFFOjIwQTdDNjo0ODYwNDk6NUZGRkREOjZCMDREQTAyIiwidmlzaXRvcl9pZCI6IjY5MTEzNDE4MTg3ODg0ODAwMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2f004dc8ca51347a27d12b2af53189845ad635583087ccf7da3ff70579aecb47 |
| hovercard-subject-tag | issue:1397862210 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/5886/issue_layout |
| twitter:image | https://opengraph.githubassets.com/040ff68e1685cd44e815b672b631c92b482190a3940c029bd96534ff96cc093d/getsentry/sentry-javascript/issues/5886 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/040ff68e1685cd44e815b672b631c92b482190a3940c029bd96534ff96cc093d/getsentry/sentry-javascript/issues/5886 |
| og:image:alt | Problem Statement In spite of the fact that - theoretically - updating one of our top-level packages (@sentry/browser, @sentry/node, and all framework-specific packages) should also update all mono... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lobsterkatie |
| hostname | github.com |
| expected-hostname | github.com |
| None | 194dacb8acfd3e4d3ffb2704e0b1f10327f0dad690a7142acc7b0e0a2d073965 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6c35540a0a2991ee20bd053ba2601cce33f72cb1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width