Skip to content

ref(build): Add build/types to tarballs and adjust types entry points #4824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Mar 31, 2022

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Mar 30, 2022

With PR #4724, we introduced separate building of type declaration files which would be written to <sdk>/build/types. Furthermore, we adjusted the types entry point in the package.jsons to this new directory. To avoid a breaking change, we kept type declarations in dist and esm. However, a bug in this PR caused a small regression in most of our SDKs: The new types directory was not included in most of our SDK tarballs. Subsequently, we released a hot fix via #4745 which simply reset the entry points back to their previous path (dist/index.d.ts) in all SDKs.

This PR now properly fixes this bug:

  • All tarballs now include the build/types directory. All .npmignores were adjusted to include this directory.
  • The types entry point in all package.jsons are now adjusted to the new types directory

In addition, this PR makes slight adjustments w.r.t. creating tarballs to the following SDK projects to improve consistency:

  • Browser: Adjusted postbuild.sh to copy .npmignore to ./build
    • Converting postbuild.sh to Node will happen in a separate PR coming soon (TM)
  • Gatsby: Use .npmignore instead of files property in package.json
  • Utils: Changed .npmignore to be more similar to our other packages
  • WASM: Changed .npmignore to be more similar to our other packages
    • A note here: our WASM tarballs did not include bundles before, so I didn't include them now either
  • Next.js: Added .npmignore file

A note for reviewing: with the exception of Angular and Browser (both in 1st commit), all adjustments are one commit per SDK. If necessary, feel free to go through the PR commit by commit. The changes per SDK are pretty isolated though.
Also, since a similar change caused a regression last time, I double checked all entry points and tarballs. Regardless, a second pair of eyes would probably be good on that end.

ref: https://getsentry.atlassian.net/browse/WEB-730
ref: https://getsentry.atlassian.net/browse/WEB-745

Lms24 added 15 commits March 30, 2022 10:38
- change `types` entry point in `package.json`
- adjust `.npmignore` to include `build/types` in tarball

- applies to `@sentry/angular` & `@sentry/browser` in this commit
change from `files` pkg.json property to .npmignore
adjust .npmignore for consistency w/ other packages
change .npmignore structure to allow specific dirs instead of all js files (consistency)
@Lms24 Lms24 requested review from lobsterkatie and lforst March 30, 2022 13:42
Copy link
Member

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm 👍

Copy link
Member

@lobsterkatie lobsterkatie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Does npm require each package to have its own .npmignore file, or will it use one from the repo if the package itself doesn't have one? (I ask because almost all of these look identical and I'm wondering if it's possible to use a single copy at the project root instead.)

Never mind - I figured this out on my own!

Copy link
Member

@lobsterkatie lobsterkatie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two small suggestions, but otherwise LGTM! Can we also add the standard .npmignore to the nextjs package, so we can stop shipping our tsconfigs, etc?

@Lms24
Copy link
Member Author

Lms24 commented Mar 31, 2022

J ust two small suggestions, but otherwise LGTM! Can we also add the standard .npmignore to the nextjs package, so we can stop shipping our tsconfigs, etc?

Thanks for the review. And yes, we can absolutely do that. I'll add the default .npmignore config here as well. Is there anything we should allow in addition to the three directories? Like anything that Next.js needs (e.g. the vercel directory?) additionally?

@lobsterkatie
Copy link
Member

Is there anything we should allow in addition to the three directories? Like anything that Next.js needs (e.g. the vercel directory?) additionally?

Nope. The vercel folder is just a bunch of scripts I wrote to make it possible to test an SDK branch against a test app deployed to vercel, and everything else is just the standard config files all packages have.

@Lms24
Copy link
Member Author

Lms24 commented Mar 31, 2022

Alright, then I'll merge this in. Thanks :)

@github-actions
Copy link
Contributor

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 20.07 KB (+0.01% 🔺)
@sentry/browser - ES5 CDN Bundle (minified) 64.54 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.78 KB (+0.03% 🔺)
@sentry/browser - ES6 CDN Bundle (minified) 57.95 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 23.21 KB (0%)
@sentry/browser - Webpack (minified) 82.45 KB (0%)
@sentry/react - Webpack (gzipped + minified) 23.25 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 48.19 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 25.98 KB (+0.01% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 24.41 KB (+0.01% 🔺)

@Lms24 Lms24 changed the title ref(build): Add build/types to tarballs and adjust types entry point ref(build): Add build/types to tarballs and adjust types entry points Mar 31, 2022
@Lms24 Lms24 merged commit faaacb8 into master Mar 31, 2022
@Lms24 Lms24 deleted the lms-proper-bugfix-6.19.0 branch March 31, 2022 08:20
@AbhiPrasad AbhiPrasad added this to the Pre 7.0.0 Work milestone Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants