From 54a3f79acc8cce10aeb4239bcb68661b11739ade Mon Sep 17 00:00:00 2001 From: Lenny Date: Sat, 5 Oct 2024 13:38:42 +0200 Subject: [PATCH 1/3] feat: add service worker guide for fixing invalid file hashes in ngsw.json --- .../common/troubleshooting/service-worker.mdx | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 docs/platforms/javascript/common/troubleshooting/service-worker.mdx diff --git a/docs/platforms/javascript/common/troubleshooting/service-worker.mdx b/docs/platforms/javascript/common/troubleshooting/service-worker.mdx new file mode 100644 index 00000000000000..174e8a6be556b0 --- /dev/null +++ b/docs/platforms/javascript/common/troubleshooting/service-worker.mdx @@ -0,0 +1,13 @@ +--- +title: Service Worker +--- + +## Fixing invalid file hashes in `ngsw.json` after injecting debugIds + +if `debugIds` are injected into the chunks of the build, the file hashes in `ngsw.json` become invalid and can no longer be cached by the serviceworker. To resolve this issue, regenerate `ngsw.json` after the `debugIds` have been injected using the following command: +```bash +node_modules/.bin/ngsw-config +``` + +* `dist` Path to the built chunk files. The `ngsw.json` with the old hashes should be located there. +* `config` Location of `ngsw-config.json` (should be in project root) From 47573c014d56c03f57865f25717bdad1a66bd75c Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Tue, 8 Oct 2024 10:45:13 +0200 Subject: [PATCH 2/3] move content, add troubleshooting entry --- .../common/sourcemaps/uploading/cli.mdx | 18 ++++++++++++++++++ .../common/troubleshooting/index.mdx | 13 +++++++++++++ .../common/troubleshooting/service-worker.mdx | 13 ------------- .../upload/primer/javascript.angular.mdx | 6 +++--- 4 files changed, 34 insertions(+), 16 deletions(-) delete mode 100644 docs/platforms/javascript/common/troubleshooting/service-worker.mdx diff --git a/docs/platforms/javascript/common/sourcemaps/uploading/cli.mdx b/docs/platforms/javascript/common/sourcemaps/uploading/cli.mdx index 03ee5b762081b3..4da10dfb49a660 100644 --- a/docs/platforms/javascript/common/sourcemaps/uploading/cli.mdx +++ b/docs/platforms/javascript/common/sourcemaps/uploading/cli.mdx @@ -30,3 +30,21 @@ If you want to configure source map uploading using the CLI, follow the steps be You can generate source maps using the tooling of your choice. See examples from other guides linked under Uploading Source Maps. + + + +## Fixing Angular Service Worker caching issues + +If you use the [Angular service worker](https://angular.dev/ecosystem/service-workers), you might encounter caching issues when uploading source maps with Sentry CLI. +This happens because Sentry CLI injects debugIds into the generated JavaScript chunks after the build process. +This means that the file hashes in `ngsw.json` for these chunks become invalid. +To resolve the invalid hashes, regenerate `ngsw.json` after the `debugIds` have been injected using the following command: + +```bash +node_modules/.bin/ngsw-config +``` + +- `dist` Path to the built chunk files. The `ngsw.json` with the old hashes should be located there. +- `config` Location of `ngsw-config.json` (should be in project root) + + diff --git a/docs/platforms/javascript/common/troubleshooting/index.mdx b/docs/platforms/javascript/common/troubleshooting/index.mdx index db7e89b3771307..ba785b6e612aee 100644 --- a/docs/platforms/javascript/common/troubleshooting/index.mdx +++ b/docs/platforms/javascript/common/troubleshooting/index.mdx @@ -386,4 +386,17 @@ export default defineConfig({ + + + +If you upload source maps for your Angular application with Sentry CLI, you might encounter caching issues if you use the [Angular service worker](https://angular.dev/ecosystem/service-workers). +Learn more about fixing these caching issues in the Uploading Source Maps with Sentry CLI guide. + + + + + If you need additional help, you can [ask on GitHub](https://github.com/getsentry/sentry-javascript/issues/new/choose). Customers on a paid plan may also contact support. diff --git a/docs/platforms/javascript/common/troubleshooting/service-worker.mdx b/docs/platforms/javascript/common/troubleshooting/service-worker.mdx deleted file mode 100644 index 174e8a6be556b0..00000000000000 --- a/docs/platforms/javascript/common/troubleshooting/service-worker.mdx +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: Service Worker ---- - -## Fixing invalid file hashes in `ngsw.json` after injecting debugIds - -if `debugIds` are injected into the chunks of the build, the file hashes in `ngsw.json` become invalid and can no longer be cached by the serviceworker. To resolve this issue, regenerate `ngsw.json` after the `debugIds` have been injected using the following command: -```bash -node_modules/.bin/ngsw-config -``` - -* `dist` Path to the built chunk files. The `ngsw.json` with the old hashes should be located there. -* `config` Location of `ngsw-config.json` (should be in project root) diff --git a/platform-includes/sourcemaps/upload/primer/javascript.angular.mdx b/platform-includes/sourcemaps/upload/primer/javascript.angular.mdx index 9f54aba13cec83..34b43c5545e8d8 100644 --- a/platform-includes/sourcemaps/upload/primer/javascript.angular.mdx +++ b/platform-includes/sourcemaps/upload/primer/javascript.angular.mdx @@ -1,10 +1,10 @@ To upload your Angular project's source maps to Sentry, we recommend one of these options: -- [**Angular CLI and Sentry webpack plugin**](./angular-webpack/)
+- [Angular CLI and Sentry webpack plugin](./angular-webpack/)
Use the Angular CLI, a custom Angular builder and the Sentry webpack plugin to set releases and upload source maps automatically when running `ng build`. -- [**Nx Angular CLI and Sentry webpack plugin**](./angular-nx/)
+- [Nx Angular CLI and Sentry webpack plugin](./angular-nx/)
If you're using Nx, use `@nx/angular` CLI and the Sentry webpack plugin to set releases and upload source maps automatically when running `nx build`. -- [**Sentry CLI**](./cli/)
+- [Sentry CLI](./cli/)
Upload source maps manually using Sentry CLI. These options work well with Angular projects out of the box. For other bundlers or more advanced projects and configurations, take a look at the following guides and options for uploading sourcemaps: From 57926a356a6f42b1ef85ec002e735fdf3828d543 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Tue, 8 Oct 2024 10:46:37 +0200 Subject: [PATCH 3/3] small wording adjustment --- docs/platforms/javascript/common/sourcemaps/uploading/cli.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/javascript/common/sourcemaps/uploading/cli.mdx b/docs/platforms/javascript/common/sourcemaps/uploading/cli.mdx index 4da10dfb49a660..3dd9c0fd4fdd0a 100644 --- a/docs/platforms/javascript/common/sourcemaps/uploading/cli.mdx +++ b/docs/platforms/javascript/common/sourcemaps/uploading/cli.mdx @@ -38,7 +38,7 @@ You can generate source maps using the tooling of your choice. See examples from If you use the [Angular service worker](https://angular.dev/ecosystem/service-workers), you might encounter caching issues when uploading source maps with Sentry CLI. This happens because Sentry CLI injects debugIds into the generated JavaScript chunks after the build process. This means that the file hashes in `ngsw.json` for these chunks become invalid. -To resolve the invalid hashes, regenerate `ngsw.json` after the `debugIds` have been injected using the following command: +To resolve the invalid hashes, regenerate `ngsw.json` after the debugIds have been injected using the following command: ```bash node_modules/.bin/ngsw-config