@granite-js/plugin-sentry 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @granite-js/plugin-sentry
2
2
 
3
+ ## 0.1.5
4
+
5
+ ### Patch Changes
6
+
7
+ - @granite-js/plugin-core@0.1.5
8
+ - @granite-js/utils@0.1.5
9
+
10
+ ## 0.1.4
11
+
12
+ ### Patch Changes
13
+
14
+ - @granite-js/plugin-core@0.1.4
15
+ - @granite-js/utils@0.1.4
16
+
3
17
  ## 0.1.3
4
18
 
5
19
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -21,11 +21,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  }) : target, mod));
22
22
 
23
23
  //#endregion
24
- const fs_promises = __toESM(require("fs/promises"));
24
+ const es_toolkit = __toESM(require("es-toolkit"));
25
25
  const crypto = __toESM(require("crypto"));
26
+ const fs_promises = __toESM(require("fs/promises"));
26
27
  const fs = __toESM(require("fs"));
27
28
  const __sentry_cli = __toESM(require("@sentry/cli"));
28
- const es_toolkit = __toESM(require("es-toolkit"));
29
29
 
30
30
  //#region src/snippets.ts
31
31
  const SENTRY_DEBUG_ID_HOLDER = "SENTRY_DEBUG_ID";
@@ -129,14 +129,14 @@ const sentryPlugin = ({ enabled = true,...options } = {}) => {
129
129
  build: {
130
130
  order: "post",
131
131
  handler: async function(config) {
132
+ const sentryResults = [];
132
133
  const files = config.buildResults.map(({ outfile, sourcemapOutfile }) => ({
133
134
  bundle: outfile,
134
135
  sourcemap: sourcemapOutfile
135
136
  }));
136
137
  for (const file of files) {
137
138
  const { bundle, sourcemap } = file;
138
- const bundleContent = await fs_promises.readFile(bundle, "utf-8");
139
- const debugId = await extractSentryDebugId(bundleContent);
139
+ const debugId = await extractSentryDebugId(bundle);
140
140
  if (debugId == null) {
141
141
  console.error("Cannot find Sentry Debug ID");
142
142
  continue;
@@ -144,12 +144,18 @@ const sentryPlugin = ({ enabled = true,...options } = {}) => {
144
144
  const hermesBundle = tryResolveHermesBundle(bundle);
145
145
  const targetBundle = hermesBundle?.hbc ?? bundle;
146
146
  const targetSourcemap = hermesBundle?.sourcemap ?? sourcemap;
147
- await writeDebugIdInjectedSourcemap(targetSourcemap, debugId);
147
+ await Promise.all([writeDebugIdInjectedSourcemap(sourcemap, debugId), hermesBundle?.sourcemap ? writeDebugIdInjectedSourcemap(hermesBundle?.sourcemap, debugId) : es_toolkit.noop]);
148
148
  await sentryActions.uploadSourcemap({ root: config.cwd }, {
149
149
  bundlePath: targetBundle,
150
150
  sourcemapPath: targetSourcemap
151
151
  });
152
+ sentryResults.push({
153
+ bundle,
154
+ sourcemap,
155
+ debugId
156
+ });
152
157
  }
158
+ this.meta.sentry = sentryResults;
153
159
  }
154
160
  },
155
161
  config: { esbuild: {
package/dist/index.js CHANGED
@@ -1,9 +1,8 @@
1
- import * as fs$2 from "fs/promises";
2
- import * as fs from "fs/promises";
1
+ import { asyncNoop, noop } from "es-toolkit";
3
2
  import { randomUUID } from "crypto";
4
- import * as fs$1 from "fs";
3
+ import * as fs$1 from "fs/promises";
4
+ import * as fs from "fs";
5
5
  import SentryCLI from "@sentry/cli";
6
- import { asyncNoop } from "es-toolkit";
7
6
 
8
7
  //#region src/snippets.ts
9
8
  const SENTRY_DEBUG_ID_HOLDER = "SENTRY_DEBUG_ID";
@@ -48,10 +47,10 @@ function extractSentryDebugId(bundleContent) {
48
47
  //#region src/injectSentryDebugId.ts
49
48
  async function writeDebugIdInjectedSourcemap(sourcemapPath, debugId) {
50
49
  const sourcemapObject = await injectSentryDebugId(sourcemapPath, debugId);
51
- await fs$2.writeFile(sourcemapPath, JSON.stringify(sourcemapObject, null, 2), "utf-8");
50
+ await fs$1.writeFile(sourcemapPath, JSON.stringify(sourcemapObject, null, 2), "utf-8");
52
51
  }
53
52
  async function injectSentryDebugId(sourcemapPath, debugId) {
54
- const sourcemapContent = await fs$2.readFile(sourcemapPath, "utf-8");
53
+ const sourcemapContent = await fs$1.readFile(sourcemapPath, "utf-8");
55
54
  const sourcemapObject = JSON.parse(sourcemapContent);
56
55
  sourcemapObject.debugId = debugId;
57
56
  return sourcemapObject;
@@ -61,7 +60,7 @@ async function injectSentryDebugId(sourcemapPath, debugId) {
61
60
  //#region src/resolveHermesBundle.ts
62
61
  function tryResolveHermesBundle(jsBundlePath) {
63
62
  const lookupPath = `${jsBundlePath}.hbc`;
64
- return fs$1.existsSync(lookupPath) ? {
63
+ return fs.existsSync(lookupPath) ? {
65
64
  hbc: lookupPath,
66
65
  sourcemap: `${lookupPath}.map`
67
66
  } : null;
@@ -107,14 +106,14 @@ const sentryPlugin = ({ enabled = true,...options } = {}) => {
107
106
  build: {
108
107
  order: "post",
109
108
  handler: async function(config) {
109
+ const sentryResults = [];
110
110
  const files = config.buildResults.map(({ outfile, sourcemapOutfile }) => ({
111
111
  bundle: outfile,
112
112
  sourcemap: sourcemapOutfile
113
113
  }));
114
114
  for (const file of files) {
115
115
  const { bundle, sourcemap } = file;
116
- const bundleContent = await fs.readFile(bundle, "utf-8");
117
- const debugId = await extractSentryDebugId(bundleContent);
116
+ const debugId = await extractSentryDebugId(bundle);
118
117
  if (debugId == null) {
119
118
  console.error("Cannot find Sentry Debug ID");
120
119
  continue;
@@ -122,12 +121,18 @@ const sentryPlugin = ({ enabled = true,...options } = {}) => {
122
121
  const hermesBundle = tryResolveHermesBundle(bundle);
123
122
  const targetBundle = hermesBundle?.hbc ?? bundle;
124
123
  const targetSourcemap = hermesBundle?.sourcemap ?? sourcemap;
125
- await writeDebugIdInjectedSourcemap(targetSourcemap, debugId);
124
+ await Promise.all([writeDebugIdInjectedSourcemap(sourcemap, debugId), hermesBundle?.sourcemap ? writeDebugIdInjectedSourcemap(hermesBundle?.sourcemap, debugId) : noop]);
126
125
  await sentryActions.uploadSourcemap({ root: config.cwd }, {
127
126
  bundlePath: targetBundle,
128
127
  sourcemapPath: targetSourcemap
129
128
  });
129
+ sentryResults.push({
130
+ bundle,
131
+ sourcemap,
132
+ debugId
133
+ });
130
134
  }
135
+ this.meta.sentry = sentryResults;
131
136
  }
132
137
  },
133
138
  config: { esbuild: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@granite-js/plugin-sentry",
3
3
  "type": "module",
4
- "version": "0.1.3",
4
+ "version": "0.1.5",
5
5
  "description": "Plugin for integrating Sentry with Granite applications",
6
6
  "scripts": {
7
7
  "prepack": "yarn build",
@@ -33,8 +33,8 @@
33
33
  "vitest": "^3.1.4"
34
34
  },
35
35
  "dependencies": {
36
- "@granite-js/plugin-core": "0.1.3",
37
- "@granite-js/utils": "0.1.3",
36
+ "@granite-js/plugin-core": "0.1.5",
37
+ "@granite-js/utils": "0.1.5",
38
38
  "@sentry/cli": "^2.45.0",
39
39
  "es-toolkit": "^1.38.0",
40
40
  "execa": "^5"