@sentry/bundler-plugins 11.11.0 → 11.13.0

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.
Files changed (188) hide show
  1. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
  2. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
  3. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
  4. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
  5. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
  6. package/build/cjs/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
  7. package/build/cjs/_virtual/_rolldown/runtime.js +22 -0
  8. package/build/cjs/babel-plugin/component-annotation.js +14 -32
  9. package/build/cjs/babel-plugin/component-annotation.js.map +1 -1
  10. package/build/cjs/babel-plugin/constants.js +140 -122
  11. package/build/cjs/babel-plugin/constants.js.map +1 -1
  12. package/build/cjs/babel-plugin/experimental.js +204 -307
  13. package/build/cjs/babel-plugin/experimental.js.map +1 -1
  14. package/build/cjs/babel-plugin/index.js +315 -437
  15. package/build/cjs/babel-plugin/index.js.map +1 -1
  16. package/build/cjs/bun/index.js +81 -117
  17. package/build/cjs/bun/index.js.map +1 -1
  18. package/build/cjs/core/build-plugin-manager.js +626 -683
  19. package/build/cjs/core/build-plugin-manager.js.map +1 -1
  20. package/build/cjs/core/cli.js +134 -129
  21. package/build/cjs/core/cli.js.map +1 -1
  22. package/build/cjs/core/component-annotate-hooks.js +16 -27
  23. package/build/cjs/core/component-annotate-hooks.js.map +1 -1
  24. package/build/cjs/core/component-annotation-oxc-ast.js +10 -21
  25. package/build/cjs/core/component-annotation-oxc-ast.js.map +1 -1
  26. package/build/cjs/core/component-annotation-oxc-fragments.js +45 -74
  27. package/build/cjs/core/component-annotation-oxc-fragments.js.map +1 -1
  28. package/build/cjs/core/component-annotation-oxc-jsx.js +116 -156
  29. package/build/cjs/core/component-annotation-oxc-jsx.js.map +1 -1
  30. package/build/cjs/core/component-annotation-oxc-walk.js +62 -123
  31. package/build/cjs/core/component-annotation-oxc-walk.js.map +1 -1
  32. package/build/cjs/core/component-annotation-oxc.js +68 -103
  33. package/build/cjs/core/component-annotation-oxc.js.map +1 -1
  34. package/build/cjs/core/debug-id-upload.js +223 -234
  35. package/build/cjs/core/debug-id-upload.js.map +1 -1
  36. package/build/cjs/core/get-code-injection-position.js +59 -74
  37. package/build/cjs/core/get-code-injection-position.js.map +1 -1
  38. package/build/cjs/core/glob.js +9 -7
  39. package/build/cjs/core/glob.js.map +1 -1
  40. package/build/cjs/core/index.js +77 -61
  41. package/build/cjs/core/index.js.map +1 -1
  42. package/build/cjs/core/logger.js +17 -26
  43. package/build/cjs/core/logger.js.map +1 -1
  44. package/build/cjs/core/options-mapping.js +95 -117
  45. package/build/cjs/core/options-mapping.js.map +1 -1
  46. package/build/cjs/core/sentry/telemetry.js +90 -105
  47. package/build/cjs/core/sentry/telemetry.js.map +1 -1
  48. package/build/cjs/core/sentry/transports.js +92 -99
  49. package/build/cjs/core/sentry/transports.js.map +1 -1
  50. package/build/cjs/core/sourcemap-settings.js +98 -61
  51. package/build/cjs/core/sourcemap-settings.js.map +1 -1
  52. package/build/cjs/core/upload-filter.js +52 -0
  53. package/build/cjs/core/upload-filter.js.map +1 -0
  54. package/build/cjs/core/utils.js +228 -219
  55. package/build/cjs/core/utils.js.map +1 -1
  56. package/build/cjs/core/version.js +4 -5
  57. package/build/cjs/core/version.js.map +1 -1
  58. package/build/cjs/esbuild/index.js +180 -210
  59. package/build/cjs/esbuild/index.js.map +1 -1
  60. package/build/cjs/loader-utils/index.js +5 -10
  61. package/build/cjs/rollup/debug-id-injection.js +22 -38
  62. package/build/cjs/rollup/debug-id-injection.js.map +1 -1
  63. package/build/cjs/rollup/debug-id-stamping.js +14 -24
  64. package/build/cjs/rollup/debug-id-stamping.js.map +1 -1
  65. package/build/cjs/rollup/index.js +195 -209
  66. package/build/cjs/rollup/index.js.map +1 -1
  67. package/build/cjs/rollup/source-map-handling.js +178 -0
  68. package/build/cjs/rollup/source-map-handling.js.map +1 -0
  69. package/build/cjs/vite/index.js +19 -35
  70. package/build/cjs/vite/index.js.map +1 -1
  71. package/build/cjs/vite/source-map-hooks.js +116 -0
  72. package/build/cjs/vite/source-map-hooks.js.map +1 -0
  73. package/build/cjs/webpack/component-annotation-transform.js +20 -26
  74. package/build/cjs/webpack/component-annotation-transform.js.map +1 -1
  75. package/build/cjs/webpack/index.js +277 -234
  76. package/build/cjs/webpack/index.js.map +1 -1
  77. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/assertClassBrand.js +6 -0
  78. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/checkPrivateRedeclaration.js +5 -0
  79. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldGet2.js +6 -0
  80. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldInitSpec.js +6 -0
  81. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateFieldSet2.js +6 -0
  82. package/build/esm/_virtual/_@oxc-project_runtime@0.158.0/helpers/esm/classPrivateMethodInitSpec.js +6 -0
  83. package/build/esm/_virtual/_rolldown/runtime.js +2 -0
  84. package/build/esm/babel-plugin/component-annotation.js +13 -29
  85. package/build/esm/babel-plugin/component-annotation.js.map +1 -1
  86. package/build/esm/babel-plugin/constants.js +140 -120
  87. package/build/esm/babel-plugin/constants.js.map +1 -1
  88. package/build/esm/babel-plugin/experimental.js +204 -305
  89. package/build/esm/babel-plugin/experimental.js.map +1 -1
  90. package/build/esm/babel-plugin/index.js +311 -434
  91. package/build/esm/babel-plugin/index.js.map +1 -1
  92. package/build/esm/bun/index.js +76 -101
  93. package/build/esm/bun/index.js.map +1 -1
  94. package/build/esm/core/build-plugin-manager.js +621 -664
  95. package/build/esm/core/build-plugin-manager.js.map +1 -1
  96. package/build/esm/core/cli.js +134 -127
  97. package/build/esm/core/cli.js.map +1 -1
  98. package/build/esm/core/component-annotate-hooks.js +16 -25
  99. package/build/esm/core/component-annotate-hooks.js.map +1 -1
  100. package/build/esm/core/component-annotation-oxc-ast.js +9 -19
  101. package/build/esm/core/component-annotation-oxc-ast.js.map +1 -1
  102. package/build/esm/core/component-annotation-oxc-fragments.js +44 -72
  103. package/build/esm/core/component-annotation-oxc-fragments.js.map +1 -1
  104. package/build/esm/core/component-annotation-oxc-jsx.js +115 -154
  105. package/build/esm/core/component-annotation-oxc-jsx.js.map +1 -1
  106. package/build/esm/core/component-annotation-oxc-walk.js +61 -121
  107. package/build/esm/core/component-annotation-oxc-walk.js.map +1 -1
  108. package/build/esm/core/component-annotation-oxc.js +65 -96
  109. package/build/esm/core/component-annotation-oxc.js.map +1 -1
  110. package/build/esm/core/debug-id-upload.js +218 -213
  111. package/build/esm/core/debug-id-upload.js.map +1 -1
  112. package/build/esm/core/get-code-injection-position.js +59 -72
  113. package/build/esm/core/get-code-injection-position.js.map +1 -1
  114. package/build/esm/core/glob.js +9 -5
  115. package/build/esm/core/glob.js.map +1 -1
  116. package/build/esm/core/index.js +62 -47
  117. package/build/esm/core/index.js.map +1 -1
  118. package/build/esm/core/logger.js +17 -24
  119. package/build/esm/core/logger.js.map +1 -1
  120. package/build/esm/core/options-mapping.js +95 -115
  121. package/build/esm/core/options-mapping.js.map +1 -1
  122. package/build/esm/core/sentry/telemetry.js +89 -102
  123. package/build/esm/core/sentry/telemetry.js.map +1 -1
  124. package/build/esm/core/sentry/transports.js +90 -83
  125. package/build/esm/core/sentry/transports.js.map +1 -1
  126. package/build/esm/core/sourcemap-settings.js +96 -59
  127. package/build/esm/core/sourcemap-settings.js.map +1 -1
  128. package/build/esm/core/upload-filter.js +50 -0
  129. package/build/esm/core/upload-filter.js.map +1 -0
  130. package/build/esm/core/utils.js +221 -209
  131. package/build/esm/core/utils.js.map +1 -1
  132. package/build/esm/core/version.js +4 -3
  133. package/build/esm/core/version.js.map +1 -1
  134. package/build/esm/esbuild/index.js +176 -194
  135. package/build/esm/esbuild/index.js.map +1 -1
  136. package/build/esm/loader-utils/index.js +4 -3
  137. package/build/esm/package.json +1 -1
  138. package/build/esm/rollup/debug-id-injection.js +22 -36
  139. package/build/esm/rollup/debug-id-injection.js.map +1 -1
  140. package/build/esm/rollup/debug-id-stamping.js +14 -22
  141. package/build/esm/rollup/debug-id-stamping.js.map +1 -1
  142. package/build/esm/rollup/index.js +191 -189
  143. package/build/esm/rollup/index.js.map +1 -1
  144. package/build/esm/rollup/source-map-handling.js +173 -0
  145. package/build/esm/rollup/source-map-handling.js.map +1 -0
  146. package/build/esm/vite/index.js +19 -32
  147. package/build/esm/vite/index.js.map +1 -1
  148. package/build/esm/vite/source-map-hooks.js +114 -0
  149. package/build/esm/vite/source-map-hooks.js.map +1 -0
  150. package/build/esm/webpack/component-annotation-transform.js +17 -24
  151. package/build/esm/webpack/component-annotation-transform.js.map +1 -1
  152. package/build/esm/webpack/index.js +274 -216
  153. package/build/esm/webpack/index.js.map +1 -1
  154. package/build/types/core/build-plugin-manager.d.ts +33 -10
  155. package/build/types/core/build-plugin-manager.d.ts.map +1 -1
  156. package/build/types/core/cli.d.ts +6 -1
  157. package/build/types/core/cli.d.ts.map +1 -1
  158. package/build/types/core/debug-id-upload.d.ts +7 -4
  159. package/build/types/core/debug-id-upload.d.ts.map +1 -1
  160. package/build/types/core/index.d.ts +4 -3
  161. package/build/types/core/index.d.ts.map +1 -1
  162. package/build/types/core/options-mapping.d.ts +4 -3
  163. package/build/types/core/options-mapping.d.ts.map +1 -1
  164. package/build/types/core/sentry/telemetry.d.ts.map +1 -1
  165. package/build/types/core/sourcemap-settings.d.ts +10 -1
  166. package/build/types/core/sourcemap-settings.d.ts.map +1 -1
  167. package/build/types/core/types.d.ts +32 -1
  168. package/build/types/core/types.d.ts.map +1 -1
  169. package/build/types/core/upload-filter.d.ts +9 -0
  170. package/build/types/core/upload-filter.d.ts.map +1 -0
  171. package/build/types/core/utils.d.ts +4 -0
  172. package/build/types/core/utils.d.ts.map +1 -1
  173. package/build/types/core/version.d.ts +1 -1
  174. package/build/types/esbuild/index.d.ts +2 -2
  175. package/build/types/esbuild/index.d.ts.map +1 -1
  176. package/build/types/rollup/index.d.ts +107 -7
  177. package/build/types/rollup/index.d.ts.map +1 -1
  178. package/build/types/rollup/source-map-handling.d.ts +59 -0
  179. package/build/types/rollup/source-map-handling.d.ts.map +1 -0
  180. package/build/types/vite/index.d.ts +4 -8
  181. package/build/types/vite/index.d.ts.map +1 -1
  182. package/build/types/vite/source-map-hooks.d.ts +45 -0
  183. package/build/types/vite/source-map-hooks.d.ts.map +1 -0
  184. package/build/types/webpack/index.d.ts +7 -3
  185. package/build/types/webpack/index.d.ts.map +1 -1
  186. package/package.json +33 -38
  187. package/build/cjs/loader-utils/index.js.map +0 -1
  188. package/build/esm/loader-utils/index.js.map +0 -1
@@ -1,27 +1,17 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- const index = require('../core/index.js');
4
- const debugIdUpload = require('../core/debug-id-upload.js');
5
-
1
+ const require_debug_id_upload = require("../core/debug-id-upload.js");
2
+ const require_index = require("../core/index.js");
3
+ // src/rollup/debug-id-stamping.ts
6
4
  function stampDebugIds(bundle, updateChunkCode) {
7
- for (const output of Object.values(bundle)) {
8
- if (output.type !== "chunk" || !index.isJsFile(output.fileName)) {
9
- continue;
10
- }
11
- const sourceMapAsset = bundle[output.sourcemapFileName ?? `${output.fileName}.map`];
12
- const sourceMapSource = sourceMapAsset?.type === "asset" && typeof sourceMapAsset.source === "string" ? sourceMapAsset.source : void 0;
13
- const stamped = debugIdUpload.stampDebugId(output.code, sourceMapSource);
14
- if (!stamped) {
15
- continue;
16
- }
17
- if (updateChunkCode) {
18
- output.code = stamped.bundleSource;
19
- }
20
- if (stamped.sourceMapSource !== void 0 && sourceMapAsset?.type === "asset") {
21
- sourceMapAsset.source = stamped.sourceMapSource;
22
- }
23
- }
5
+ for (const output of Object.values(bundle)) {
6
+ if (output.type !== "chunk" || !require_index.isJsFile(output.fileName)) continue;
7
+ const sourceMapAsset = bundle[output.sourcemapFileName ?? `${output.fileName}.map`];
8
+ const sourceMapSource = sourceMapAsset?.type === "asset" && typeof sourceMapAsset.source === "string" ? sourceMapAsset.source : void 0;
9
+ const stamped = require_debug_id_upload.stampDebugId(output.code, sourceMapSource);
10
+ if (!stamped) continue;
11
+ if (updateChunkCode) output.code = stamped.bundleSource;
12
+ if (stamped.sourceMapSource !== void 0 && sourceMapAsset?.type === "asset") sourceMapAsset.source = stamped.sourceMapSource;
13
+ }
24
14
  }
25
-
26
15
  exports.stampDebugIds = stampDebugIds;
27
- //# sourceMappingURL=debug-id-stamping.js.map
16
+
17
+ //# sourceMappingURL=debug-id-stamping.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"debug-id-stamping.js","sources":["../../../src/rollup/debug-id-stamping.ts"],"sourcesContent":["import { isJsFile, stampDebugId } from '../core';\n\n// The subset of Rollup's `OutputBundle` the stamping hooks read.\nexport type OutputBundle = Record<\n string,\n | { type: 'chunk'; fileName: string; code: string; sourcemapFileName?: string | null }\n | { type: 'asset'; fileName: string; source: string | Uint8Array }\n>;\n\nexport function stampDebugIds(bundle: OutputBundle, updateChunkCode: boolean): void {\n for (const output of Object.values(bundle)) {\n if (output.type !== 'chunk' || !isJsFile(output.fileName)) {\n continue;\n }\n\n const sourceMapAsset = bundle[output.sourcemapFileName ?? `${output.fileName}.map`];\n const sourceMapSource =\n sourceMapAsset?.type === 'asset' && typeof sourceMapAsset.source === 'string' ? sourceMapAsset.source : undefined;\n\n const stamped = stampDebugId(output.code, sourceMapSource);\n if (!stamped) {\n continue;\n }\n\n if (updateChunkCode) {\n output.code = stamped.bundleSource;\n }\n if (stamped.sourceMapSource !== undefined && sourceMapAsset?.type === 'asset') {\n sourceMapAsset.source = stamped.sourceMapSource;\n }\n }\n}\n"],"names":["isJsFile","stampDebugId"],"mappings":";;;;;AASO,SAAS,aAAA,CAAc,QAAsB,eAAA,EAAgC;AAClF,EAAA,KAAA,MAAW,MAAA,IAAU,MAAA,CAAO,MAAA,CAAO,MAAM,CAAA,EAAG;AAC1C,IAAA,IAAI,OAAO,IAAA,KAAS,OAAA,IAAW,CAACA,cAAA,CAAS,MAAA,CAAO,QAAQ,CAAA,EAAG;AACzD,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,iBAAiB,MAAA,CAAO,MAAA,CAAO,qBAAqB,CAAA,EAAG,MAAA,CAAO,QAAQ,CAAA,IAAA,CAAM,CAAA;AAClF,IAAA,MAAM,eAAA,GACJ,gBAAgB,IAAA,KAAS,OAAA,IAAW,OAAO,cAAA,CAAe,MAAA,KAAW,QAAA,GAAW,cAAA,CAAe,MAAA,GAAS,MAAA;AAE1G,IAAA,MAAM,OAAA,GAAUC,0BAAA,CAAa,MAAA,CAAO,IAAA,EAAM,eAAe,CAAA;AACzD,IAAA,IAAI,CAAC,OAAA,EAAS;AACZ,MAAA;AAAA,IACF;AAEA,IAAA,IAAI,eAAA,EAAiB;AACnB,MAAA,MAAA,CAAO,OAAO,OAAA,CAAQ,YAAA;AAAA,IACxB;AACA,IAAA,IAAI,OAAA,CAAQ,eAAA,KAAoB,MAAA,IAAa,cAAA,EAAgB,SAAS,OAAA,EAAS;AAC7E,MAAA,cAAA,CAAe,SAAS,OAAA,CAAQ,eAAA;AAAA,IAClC;AAAA,EACF;AACF;;;;"}
1
+ {"version":3,"file":"debug-id-stamping.js","names":["isJsFile","stampDebugId"],"sources":["../../../src/rollup/debug-id-stamping.ts"],"sourcesContent":["import { isJsFile, stampDebugId } from '../core';\n\n// The subset of Rollup's `OutputBundle` the stamping hooks read.\nexport type OutputBundle = Record<\n string,\n | { type: 'chunk'; fileName: string; code: string; sourcemapFileName?: string | null }\n | { type: 'asset'; fileName: string; source: string | Uint8Array }\n>;\n\nexport function stampDebugIds(bundle: OutputBundle, updateChunkCode: boolean): void {\n for (const output of Object.values(bundle)) {\n if (output.type !== 'chunk' || !isJsFile(output.fileName)) {\n continue;\n }\n\n const sourceMapAsset = bundle[output.sourcemapFileName ?? `${output.fileName}.map`];\n const sourceMapSource =\n sourceMapAsset?.type === 'asset' && typeof sourceMapAsset.source === 'string' ? sourceMapAsset.source : undefined;\n\n const stamped = stampDebugId(output.code, sourceMapSource);\n if (!stamped) {\n continue;\n }\n\n if (updateChunkCode) {\n output.code = stamped.bundleSource;\n }\n if (stamped.sourceMapSource !== undefined && sourceMapAsset?.type === 'asset') {\n sourceMapAsset.source = stamped.sourceMapSource;\n }\n }\n}\n"],"mappings":";;;AASA,SAAgB,cAAc,QAAsB,iBAAgC;CAClF,KAAK,MAAM,UAAU,OAAO,OAAO,MAAM,GAAG;EAC1C,IAAI,OAAO,SAAS,WAAW,CAACA,cAAAA,SAAS,OAAO,QAAQ,GACtD;EAGF,MAAM,iBAAiB,OAAO,OAAO,qBAAqB,GAAG,OAAO,SAAS;EAC7E,MAAM,kBACJ,gBAAgB,SAAS,WAAW,OAAO,eAAe,WAAW,WAAW,eAAe,SAAS,KAAA;EAE1G,MAAM,UAAUC,wBAAAA,aAAa,OAAO,MAAM,eAAe;EACzD,IAAI,CAAC,SACH;EAGF,IAAI,iBACF,OAAO,OAAO,QAAQ;EAExB,IAAI,QAAQ,oBAAoB,KAAA,KAAa,gBAAgB,SAAS,SACpE,eAAe,SAAS,QAAQ;CAEpC;AACF"}
@@ -1,221 +1,207 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
-
3
- const index = require('../core/index.js');
4
- const MagicString = require('magic-string');
5
- const path = require('node:path');
6
- const node_module = require('node:module');
7
- const debugIdInjection = require('./debug-id-injection.js');
8
- const debugIdStamping = require('./debug-id-stamping.js');
9
- const buildPluginManager = require('../core/build-plugin-manager.js');
10
- const utils = require('../core/utils.js');
11
- const componentAnnotateHooks = require('../core/component-annotate-hooks.js');
12
- const glob = require('../core/glob.js');
13
- const getCodeInjectionPosition = require('../core/get-code-injection-position.js');
14
- const debugIdUpload = require('../core/debug-id-upload.js');
15
-
16
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
17
- function _interopDefault (e) { return e && e.__esModule ? e.default : e; }
18
-
19
- function _interopNamespace(e) {
20
- if (e && e.__esModule) return e;
21
- const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
22
- if (e) {
23
- for (const k in e) {
24
- n[k] = e[k];
25
- }
26
- }
27
- n.default = e;
28
- return n;
29
- }
30
-
31
- const MagicString__default = /*#__PURE__*/_interopDefault(MagicString);
32
- const path__namespace = /*#__PURE__*/_interopNamespace(path);
33
-
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_runtime = require("../_virtual/_rolldown/runtime.js");
3
+ const require_utils = require("../core/utils.js");
4
+ const require_glob = require("../core/glob.js");
5
+ const require_get_code_injection_position = require("../core/get-code-injection-position.js");
6
+ const require_component_annotate_hooks = require("../core/component-annotate-hooks.js");
7
+ const require_debug_id_upload = require("../core/debug-id-upload.js");
8
+ const require_build_plugin_manager = require("../core/build-plugin-manager.js");
9
+ const require_index = require("../core/index.js");
10
+ const require_debug_id_injection = require("./debug-id-injection.js");
11
+ const require_debug_id_stamping = require("./debug-id-stamping.js");
12
+ const require_source_map_handling = require("./source-map-handling.js");
13
+ const require_source_map_hooks = require("../vite/source-map-hooks.js");
14
+ let magic_string = require("magic-string");
15
+ magic_string = require_runtime.__toESM(magic_string);
16
+ let node_path = require("node:path");
17
+ node_path = require_runtime.__toESM(node_path);
18
+ let node_module = require("node:module");
19
+ // src/rollup/index.ts
34
20
  let viteParseAstAsyncPromise;
35
21
  const JS_MODULE_ID_FILTER = /\.[cm]?[jt]sx?(?:[?#].*)?$/;
36
22
  function getRollupMajorVersion() {
37
- try {
38
- const req = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('rollup/index.js', document.baseURI).href)));
39
- const rollup = req("rollup");
40
- return rollup.VERSION?.split(".")[0];
41
- } catch {
42
- }
43
- return void 0;
23
+ try {
24
+ return (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("rollup").VERSION?.split(".")[0];
25
+ } catch {}
44
26
  }
45
27
  function getViteParseAstAsync() {
46
- if (!viteParseAstAsyncPromise) {
47
- viteParseAstAsyncPromise = Promise.resolve().then(async () => {
48
- const viteModule = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('rollup/index.js', document.baseURI).href)))("vite");
49
- if (typeof viteModule.parseAstAsync !== "function") {
50
- return null;
51
- }
52
- try {
53
- await viteModule.parseAstAsync("const x = <div />;", { lang: "tsx" });
54
- } catch {
55
- return null;
56
- }
57
- return viteModule.parseAstAsync;
58
- }).catch(() => null);
59
- }
60
- return viteParseAstAsyncPromise;
28
+ if (!viteParseAstAsyncPromise) viteParseAstAsyncPromise = Promise.resolve().then(async () => {
29
+ const viteModule = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href)("vite");
30
+ if (typeof viteModule.parseAstAsync !== "function") return null;
31
+ try {
32
+ await viteModule.parseAstAsync("const x = <div />;", { lang: "tsx" });
33
+ } catch {
34
+ return null;
35
+ }
36
+ return viteModule.parseAstAsync;
37
+ }).catch(() => null);
38
+ return viteParseAstAsyncPromise;
39
+ }
40
+ /**
41
+ * @ignore - internal plugin factory shared by the Rollup and Vite plugins.
42
+ *
43
+ * `main` carries injection, release creation and the upload. `post` runs last in `generateBundle`,
44
+ * copies chunks and their source maps into the upload staging folder and drops the map assets
45
+ * from the bundle, so the bundler never writes them.
46
+ */
47
+ function _createRollupPluginInternals(userOptions = {}, buildTool, buildToolMajorVersion) {
48
+ const sentryBuildPluginManager = require_build_plugin_manager.createSentryBuildPluginManager(userOptions, {
49
+ loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[sentry-${buildTool}-plugin]`,
50
+ buildTool,
51
+ buildToolMajorVersion: buildToolMajorVersion || getRollupMajorVersion()
52
+ });
53
+ const { logger, normalizedOptions: options, bundleSizeOptimizationReplacementValues: replacementValues, bundleMetadata, createDependencyOnBuildArtifacts } = sentryBuildPluginManager;
54
+ if (options.disable) return {
55
+ main: { name: "sentry-noop-plugin" },
56
+ post: void 0
57
+ };
58
+ if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
59
+ const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
60
+ const upload = require_debug_id_upload.createDebugIdUploadFunction({ sentryBuildPluginManager });
61
+ const sourcemapsEnabled = options.sourcemaps?.disable !== true;
62
+ const sourceMapHandling = require_source_map_handling.createSourceMapHandling(sentryBuildPluginManager);
63
+ const releaseInjectionCode = new require_utils.CodeInjection();
64
+ const chunkInjectionCode = new require_utils.CodeInjection();
65
+ if (!options.release.inject) logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
66
+ else if (!options.release.name) logger.debug("No release name provided. Will not inject release. Please set the `release.name` option to identify your release.");
67
+ else releaseInjectionCode.append(require_utils.generateReleaseInjectorCode({
68
+ release: options.release.name,
69
+ injectBuildInformation: options._experiments.injectBuildInformation || false
70
+ }));
71
+ if (Object.keys(bundleMetadata).length > 0) chunkInjectionCode.append(require_utils.generateModuleMetadataInjectorCode(bundleMetadata));
72
+ const transformAnnotations = options.reactComponentAnnotation?.enabled ? require_component_annotate_hooks.createComponentNameAnnotateHooks(options.reactComponentAnnotation?.ignoredComponents || [], !!options.reactComponentAnnotation?._experimentalInjectIntoHtml, {
73
+ getParseAstAsync: buildTool === "vite" && buildToolMajorVersion === "8" ? getViteParseAstAsync : void 0,
74
+ logger
75
+ }) : void 0;
76
+ const transformReplace = Object.keys(replacementValues).length > 0;
77
+ const shouldTransform = transformAnnotations || transformReplace;
78
+ function buildStart() {
79
+ sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {});
80
+ }
81
+ async function transform(code, id, meta) {
82
+ if (transformAnnotations) {
83
+ const result = await transformAnnotations.transform(code, id, meta);
84
+ if (result) return result;
85
+ }
86
+ if (transformReplace) return require_utils.replaceBooleanFlagsInCode(code, replacementValues);
87
+ return null;
88
+ }
89
+ function renderChunk(code, chunk, _, meta) {
90
+ if (!require_index.isJsFile(chunk.fileName)) return null;
91
+ if (require_index.shouldSkipCodeInjection(code, chunk.facadeModuleId)) return null;
92
+ const injectCode = new require_utils.CodeInjection();
93
+ if (require_index.isInitialChunk(chunk, meta?.chunks)) injectCode.append(releaseInjectionCode);
94
+ injectCode.append(chunkInjectionCode);
95
+ if (sourcemapsEnabled && !require_debug_id_injection.hasExistingDebugID(code)) {
96
+ const debugId = require_debug_id_injection.getDebugIdForChunk(code, !!this?.meta?.rolldownVersion);
97
+ injectCode.append(require_index.getDebugIdSnippet(debugId));
98
+ }
99
+ if (injectCode.isEmpty()) return null;
100
+ const ms = meta?.magicString || new magic_string.default(code, { filename: chunk.fileName });
101
+ const injectionPosition = require_get_code_injection_position.getCodeInjectionPosition(code);
102
+ const codeToInject = injectionPosition === code.length ? `\n${injectCode.code()}` : injectCode.code();
103
+ ms.appendLeft(injectionPosition, codeToInject);
104
+ if (ms?.constructor?.name === "BindingMagicString") return { code: ms };
105
+ return {
106
+ code: ms.toString(),
107
+ map: ms.generateMap({
108
+ file: chunk.fileName,
109
+ hires: "boundary"
110
+ })
111
+ };
112
+ }
113
+ /**
114
+ * Resolves Rolldown's placeholder debug IDs, then stamps debug IDs into the emitted chunks and
115
+ * source maps.
116
+ *
117
+ * `disable-upload` skips the upload routine (which stamps debug IDs into temp copies), so the emitted
118
+ * artifacts get stamped here instead. Not in `renderChunk`: minifiers running after it would strip the
119
+ * comment. Rollup computes `[hash]` file names before this hook, so only plugins that hash the final
120
+ * assets afterwards (e.g. subresource integrity) see the stamped content.
121
+ */
122
+ function generateBundle(_outputOptions, bundle) {
123
+ if (this?.meta?.rolldownVersion) require_debug_id_injection.finalizeRolldownDebugIds(bundle);
124
+ if (options.sourcemaps?.disable !== "disable-upload") return;
125
+ require_debug_id_stamping.stampDebugIds(bundle, true);
126
+ }
127
+ async function writeBundle(outputOptions, bundle) {
128
+ const staging = await sourceMapHandling.takeStaging(outputOptions, bundle);
129
+ let stagingHandedOver = false;
130
+ try {
131
+ await sentryBuildPluginManager.createRelease();
132
+ if (sourcemapsEnabled && options.sourcemaps?.disable !== "disable-upload") {
133
+ let buildArtifacts;
134
+ if (outputOptions.dir) {
135
+ const outputDir = outputOptions.dir;
136
+ const JS_AND_MAP_PATTERNS = [
137
+ "/**/*.js",
138
+ "/**/*.mjs",
139
+ "/**/*.cjs",
140
+ "/**/*.js.map",
141
+ "/**/*.mjs.map",
142
+ "/**/*.cjs.map"
143
+ ].map((q) => `${q}?(\\?*)?(#*)`);
144
+ buildArtifacts = await require_glob.globFiles(JS_AND_MAP_PATTERNS, { root: outputDir });
145
+ } else if (outputOptions.file) buildArtifacts = [outputOptions.file];
146
+ else buildArtifacts = Object.keys(bundle ?? {}).map((asset) => node_path.join(node_path.resolve(), asset));
147
+ stagingHandedOver = true;
148
+ await upload(buildArtifacts, { staging });
149
+ } else {
150
+ stagingHandedOver = true;
151
+ await staging?.discard();
152
+ }
153
+ } catch (e) {
154
+ if (!stagingHandedOver) await staging?.keep("The source map upload did not run.");
155
+ throw e;
156
+ } finally {
157
+ freeGlobalDependencyOnBuildArtifacts();
158
+ await sentryBuildPluginManager.deleteArtifacts();
159
+ }
160
+ }
161
+ const name = `sentry-${buildTool}-plugin`;
162
+ const transformHook = buildTool === "vite" ? {
163
+ filter: { id: JS_MODULE_ID_FILTER },
164
+ handler: transform
165
+ } : transform;
166
+ const viteSourceMapHooks = buildTool === "vite" ? require_source_map_hooks.createViteSourceMapHooks(sentryBuildPluginManager, sourceMapHandling) : void 0;
167
+ return {
168
+ main: {
169
+ name,
170
+ buildStart,
171
+ ...shouldTransform ? { transform: transformHook } : {},
172
+ ...viteSourceMapHooks ? { configResolved: viteSourceMapHooks.configResolved } : { outputOptions: sourceMapHandling.outputOptions },
173
+ renderChunk,
174
+ generateBundle: {
175
+ order: "pre",
176
+ handler: generateBundle
177
+ },
178
+ writeBundle
179
+ },
180
+ post: {
181
+ name: buildTool === "vite" ? "sentry-vite-upload-staging" : "sentry-rollup-upload-staging",
182
+ ...viteSourceMapHooks ? { config: viteSourceMapHooks.config } : {},
183
+ generateBundle: {
184
+ order: "post",
185
+ async handler(outputOptions, bundle, isWrite) {
186
+ if (buildTool === "vite" && options.sourcemaps?.disable === "disable-upload") require_debug_id_stamping.stampDebugIds(bundle, false);
187
+ await sourceMapHandling.stageSourceMaps(outputOptions, bundle, isWrite);
188
+ }
189
+ }
190
+ }
191
+ };
61
192
  }
193
+ /**
194
+ * @ignore - this is the internal plugin factory function only used for the Vite plugin!
195
+ */
62
196
  function _rollupPluginInternal(userOptions = {}, buildTool, buildToolMajorVersion) {
63
- const sentryBuildPluginManager = buildPluginManager.createSentryBuildPluginManager(userOptions, {
64
- loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[sentry-${buildTool}-plugin]`,
65
- buildTool,
66
- buildToolMajorVersion: buildToolMajorVersion || getRollupMajorVersion()
67
- });
68
- const {
69
- logger,
70
- normalizedOptions: options,
71
- bundleSizeOptimizationReplacementValues: replacementValues,
72
- bundleMetadata,
73
- createDependencyOnBuildArtifacts
74
- } = sentryBuildPluginManager;
75
- if (options.disable) {
76
- return {
77
- name: "sentry-noop-plugin"
78
- };
79
- }
80
- if (process.cwd().match(/\\node_modules\\|\/node_modules\//)) {
81
- logger.warn("Running Sentry plugin from within a `node_modules` folder. Some features may not work.");
82
- }
83
- const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();
84
- const upload = debugIdUpload.createDebugIdUploadFunction({ sentryBuildPluginManager });
85
- const sourcemapsEnabled = options.sourcemaps?.disable !== true;
86
- const releaseInjectionCode = new utils.CodeInjection();
87
- const chunkInjectionCode = new utils.CodeInjection();
88
- if (!options.release.inject) {
89
- logger.debug("Release injection disabled via `release.inject` option. Will not inject release.");
90
- } else if (!options.release.name) {
91
- logger.debug(
92
- "No release name provided. Will not inject release. Please set the `release.name` option to identify your release."
93
- );
94
- } else {
95
- releaseInjectionCode.append(
96
- utils.generateReleaseInjectorCode({
97
- release: options.release.name,
98
- injectBuildInformation: options._experiments.injectBuildInformation || false
99
- })
100
- );
101
- }
102
- if (Object.keys(bundleMetadata).length > 0) {
103
- chunkInjectionCode.append(utils.generateModuleMetadataInjectorCode(bundleMetadata));
104
- }
105
- const transformAnnotations = options.reactComponentAnnotation?.enabled ? componentAnnotateHooks.createComponentNameAnnotateHooks(
106
- options.reactComponentAnnotation?.ignoredComponents || [],
107
- !!options.reactComponentAnnotation?._experimentalInjectIntoHtml,
108
- {
109
- // Vite 8 already loads an oxc-based parser, so reuse it.
110
- getParseAstAsync: buildTool === "vite" && buildToolMajorVersion === "8" ? getViteParseAstAsync : void 0,
111
- logger
112
- }
113
- ) : void 0;
114
- const transformReplace = Object.keys(replacementValues).length > 0;
115
- const shouldTransform = transformAnnotations || transformReplace;
116
- function buildStart() {
117
- void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {
118
- });
119
- }
120
- async function transform(code, id, meta) {
121
- if (transformAnnotations) {
122
- const result = await transformAnnotations.transform(code, id, meta);
123
- if (result) {
124
- return result;
125
- }
126
- }
127
- if (transformReplace) {
128
- return utils.replaceBooleanFlagsInCode(code, replacementValues);
129
- }
130
- return null;
131
- }
132
- function renderChunk(code, chunk, _, meta) {
133
- if (!index.isJsFile(chunk.fileName)) {
134
- return null;
135
- }
136
- if (index.shouldSkipCodeInjection(code, chunk.facadeModuleId)) {
137
- return null;
138
- }
139
- const injectCode = new utils.CodeInjection();
140
- if (index.isInitialChunk(chunk, meta?.chunks)) {
141
- injectCode.append(releaseInjectionCode);
142
- }
143
- injectCode.append(chunkInjectionCode);
144
- if (sourcemapsEnabled && !debugIdInjection.hasExistingDebugID(code)) {
145
- const debugId = debugIdInjection.getDebugIdForChunk(code, !!this?.meta?.rolldownVersion);
146
- injectCode.append(index.getDebugIdSnippet(debugId));
147
- }
148
- if (injectCode.isEmpty()) {
149
- return null;
150
- }
151
- const ms = meta?.magicString || new MagicString__default(code, { filename: chunk.fileName });
152
- const injectionPosition = getCodeInjectionPosition.getCodeInjectionPosition(code);
153
- const codeToInject = injectionPosition === code.length ? `
154
- ${injectCode.code()}` : injectCode.code();
155
- ms.appendLeft(injectionPosition, codeToInject);
156
- if (ms?.constructor?.name === "BindingMagicString") {
157
- return { code: ms };
158
- }
159
- return {
160
- code: ms.toString(),
161
- map: ms.generateMap({ file: chunk.fileName, hires: "boundary" })
162
- };
163
- }
164
- function generateBundle(_outputOptions, bundle) {
165
- if (this?.meta?.rolldownVersion) {
166
- debugIdInjection.finalizeRolldownDebugIds(bundle);
167
- }
168
- if (options.sourcemaps?.disable !== "disable-upload") {
169
- return;
170
- }
171
- debugIdStamping.stampDebugIds(bundle, true);
172
- }
173
- async function writeBundle(outputOptions, bundle) {
174
- try {
175
- await sentryBuildPluginManager.createRelease();
176
- if (sourcemapsEnabled && options.sourcemaps?.disable !== "disable-upload") {
177
- if (outputOptions.dir) {
178
- const outputDir = outputOptions.dir;
179
- const JS_AND_MAP_PATTERNS = [
180
- "/**/*.js",
181
- "/**/*.mjs",
182
- "/**/*.cjs",
183
- "/**/*.js.map",
184
- "/**/*.mjs.map",
185
- "/**/*.cjs.map"
186
- ].map((q) => `${q}?(\\?*)?(#*)`);
187
- const buildArtifacts = await glob.globFiles(JS_AND_MAP_PATTERNS, { root: outputDir });
188
- await upload(buildArtifacts);
189
- } else if (outputOptions.file) {
190
- await upload([outputOptions.file]);
191
- } else {
192
- const buildArtifacts = Object.keys(bundle).map((asset) => path__namespace.join(path__namespace.resolve(), asset));
193
- await upload(buildArtifacts);
194
- }
195
- }
196
- } finally {
197
- freeGlobalDependencyOnBuildArtifacts();
198
- await sentryBuildPluginManager.deleteArtifacts();
199
- }
200
- }
201
- const name = `sentry-${buildTool}-plugin`;
202
- const transformHook = buildTool === "vite" ? {
203
- filter: { id: JS_MODULE_ID_FILTER },
204
- handler: transform
205
- } : transform;
206
- return {
207
- name,
208
- buildStart,
209
- ...shouldTransform ? { transform: transformHook } : {},
210
- renderChunk,
211
- generateBundle: { order: "pre", handler: generateBundle },
212
- writeBundle
213
- };
197
+ return _createRollupPluginInternals(userOptions, buildTool, buildToolMajorVersion).main;
214
198
  }
215
199
  function sentryRollupPlugin(userOptions = {}) {
216
- return [_rollupPluginInternal(userOptions, "rollup")];
200
+ const { main, post } = _createRollupPluginInternals(userOptions, "rollup");
201
+ return post ? [main, post] : [main];
217
202
  }
218
-
203
+ exports._createRollupPluginInternals = _createRollupPluginInternals;
219
204
  exports._rollupPluginInternal = _rollupPluginInternal;
220
205
  exports.sentryRollupPlugin = sentryRollupPlugin;
221
- //# sourceMappingURL=index.js.map
206
+
207
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/rollup/index.ts"],"sourcesContent":["import type { ChunkGraphNode, Options } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n isJsFile,\n isInitialChunk,\n shouldSkipCodeInjection,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n globFiles,\n createComponentNameAnnotateHooks,\n replaceBooleanFlagsInCode,\n CodeInjection,\n getCodeInjectionPosition,\n} from '../core';\nimport type { ComponentAnnotationTransformMeta } from '../core/component-annotation-oxc';\nimport type { SourceMap } from 'magic-string';\nimport MagicString from 'magic-string';\nimport * as path from 'node:path';\nimport { createRequire } from 'node:module';\nimport { finalizeRolldownDebugIds, getDebugIdForChunk, hasExistingDebugID } from './debug-id-injection';\nimport { stampDebugIds, type OutputBundle } from './debug-id-stamping';\n\n// The subset of Rollup's `TransformResult` that this plugin's `transform`\n// hook actually returns. Defined locally instead of imported from `rollup`\n// because `rollup` is an optional dependency.\ntype TransformResult = { code: string; map?: SourceMap | string | { mappings: string } | null } | null | undefined;\n\ntype ViteModule = {\n parseAstAsync?: (code: string, options: { lang: 'jsx' | 'tsx' }) => Promise<unknown>;\n};\n\ntype ViteParseAstAsync = NonNullable<ViteModule['parseAstAsync']>;\n\nlet viteParseAstAsyncPromise: Promise<ViteParseAstAsync | null> | undefined;\n\n// Rolldown sets `meta.rolldownVersion` on the plugin context.\ntype PluginContext = { meta?: { rolldownVersion?: string } };\n\nconst JS_MODULE_ID_FILTER = /\\.[cm]?[jt]sx?(?:[?#].*)?$/;\n\nfunction getRollupMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const rollup = req('rollup') as { VERSION?: string };\n return rollup.VERSION?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nfunction getViteParseAstAsync(): Promise<ViteParseAstAsync | null> {\n if (!viteParseAstAsyncPromise) {\n viteParseAstAsyncPromise = Promise.resolve()\n .then(async () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Vite is an optional runtime peer for this package\n const viteModule = createRequire(import.meta.url)('vite') as ViteModule;\n\n if (typeof viteModule.parseAstAsync !== 'function') {\n return null;\n }\n\n try {\n await viteModule.parseAstAsync('const x = <div />;', { lang: 'tsx' });\n } catch {\n return null;\n }\n\n return viteModule.parseAstAsync;\n })\n .catch(() => null);\n }\n\n return viteParseAstAsyncPromise;\n}\n\n/**\n * @ignore - this is the internal plugin factory function only used for the Vite plugin!\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function _rollupPluginInternal(\n userOptions: Options = {},\n buildTool: 'rollup' | 'vite',\n buildToolMajorVersion?: string,\n) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[sentry-${buildTool}-plugin]`,\n buildTool,\n buildToolMajorVersion: buildToolMajorVersion || getRollupMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n name: 'sentry-noop-plugin',\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n const sourcemapsEnabled = options.sourcemaps?.disable !== true;\n const releaseInjectionCode = new CodeInjection();\n const chunkInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n releaseInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n chunkInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n const transformAnnotations = options.reactComponentAnnotation?.enabled\n ? createComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n !!options.reactComponentAnnotation?._experimentalInjectIntoHtml,\n {\n // Vite 8 already loads an oxc-based parser, so reuse it.\n getParseAstAsync: buildTool === 'vite' && buildToolMajorVersion === '8' ? getViteParseAstAsync : undefined,\n logger,\n },\n )\n : undefined;\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n const shouldTransform = transformAnnotations || transformReplace;\n\n function buildStart(): void {\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n }\n\n async function transform(\n code: string,\n id: string,\n meta?: ComponentAnnotationTransformMeta,\n ): Promise<TransformResult> {\n // Component annotations are only in user code and boolean flag replacements are\n // only in Sentry code. If we successfully add annotations, we can return early.\n if (transformAnnotations) {\n const result = await transformAnnotations.transform(code, id, meta);\n if (result) {\n return result;\n }\n }\n\n if (transformReplace) {\n return replaceBooleanFlagsInCode(code, replacementValues);\n }\n\n return null;\n }\n\n function renderChunk(\n this: PluginContext | undefined,\n code: string,\n chunk: { fileName: string; facadeModuleId?: string | null; isEntry?: boolean },\n _?: unknown,\n meta?: { magicString?: MagicString; chunks?: Record<string, ChunkGraphNode> },\n ): {\n code: string;\n map?: SourceMap;\n } | null {\n if (!isJsFile(chunk.fileName)) {\n return null; // returning null means not modifying the chunk at all\n }\n\n // Skip empty chunks and HTML facade chunks (Vite MPA)\n if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {\n return null;\n }\n\n const injectCode = new CodeInjection();\n\n if (isInitialChunk(chunk, meta?.chunks)) {\n injectCode.append(releaseInjectionCode);\n }\n\n injectCode.append(chunkInjectionCode);\n\n if (sourcemapsEnabled && !hasExistingDebugID(code)) {\n const debugId = getDebugIdForChunk(code, !!this?.meta?.rolldownVersion);\n injectCode.append(getDebugIdSnippet(debugId));\n }\n\n if (injectCode.isEmpty()) {\n return null;\n }\n\n const ms = meta?.magicString || new MagicString(code, { filename: chunk.fileName });\n const injectionPosition = getCodeInjectionPosition(code);\n const codeToInject = injectionPosition === code.length ? `\\n${injectCode.code()}` : injectCode.code();\n ms.appendLeft(injectionPosition, codeToInject);\n\n // Rolldown can pass a native MagicString instance in meta.magicString\n // https://rolldown.rs/in-depth/native-magic-string#usage-examples\n if (ms?.constructor?.name === 'BindingMagicString') {\n // Rolldown docs say to return the magic string instance directly in this case\n return { code: ms as unknown as string };\n }\n\n return {\n code: ms.toString(),\n map: ms.generateMap({ file: chunk.fileName, hires: 'boundary' }),\n };\n }\n\n /**\n * Resolves Rolldown's placeholder debug IDs, then stamps debug IDs into the emitted chunks and\n * source maps.\n *\n * `disable-upload` skips the upload routine (which stamps debug IDs into temp copies), so the emitted\n * artifacts get stamped here instead. Not in `renderChunk`: minifiers running after it would strip the\n * comment. Rollup computes `[hash]` file names before this hook, so only plugins that hash the final\n * assets afterwards (e.g. subresource integrity) see the stamped content.\n */\n function generateBundle(this: PluginContext | undefined, _outputOptions: unknown, bundle: OutputBundle): void {\n if (this?.meta?.rolldownVersion) {\n finalizeRolldownDebugIds(bundle);\n }\n\n if (options.sourcemaps?.disable !== 'disable-upload') {\n return;\n }\n\n stampDebugIds(bundle, true);\n }\n\n async function writeBundle(\n outputOptions: { dir?: string; file?: string },\n bundle: { [fileName: string]: unknown },\n ): Promise<void> {\n try {\n await sentryBuildPluginManager.createRelease();\n\n if (sourcemapsEnabled && options.sourcemaps?.disable !== 'disable-upload') {\n if (outputOptions.dir) {\n const outputDir = outputOptions.dir;\n const JS_AND_MAP_PATTERNS = [\n '/**/*.js',\n '/**/*.mjs',\n '/**/*.cjs',\n '/**/*.js.map',\n '/**/*.mjs.map',\n '/**/*.cjs.map',\n ].map(q => `${q}?(\\\\?*)?(#*)`); // We want to allow query and hash strings at the end of files\n const buildArtifacts = await globFiles(JS_AND_MAP_PATTERNS, { root: outputDir });\n await upload(buildArtifacts);\n } else if (outputOptions.file) {\n await upload([outputOptions.file]);\n } else {\n const buildArtifacts = Object.keys(bundle).map(asset => path.join(path.resolve(), asset));\n await upload(buildArtifacts);\n }\n }\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n }\n\n const name = `sentry-${buildTool}-plugin`;\n const transformHook =\n buildTool === 'vite'\n ? {\n filter: { id: JS_MODULE_ID_FILTER },\n handler: transform,\n }\n : transform;\n\n return {\n name,\n buildStart,\n ...(shouldTransform ? { transform: transformHook } : {}),\n renderChunk,\n generateBundle: { order: 'pre' as const, handler: generateBundle },\n writeBundle,\n };\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-explicit-any\nexport function sentryRollupPlugin(userOptions: Options = {}): any {\n // We return an array here so we don't break backwards compatibility with what\n // unplugin used to return\n return [_rollupPluginInternal(userOptions, 'rollup')];\n}\n\nexport type { Options as SentryRollupPluginOptions } from '../core';\n"],"names":["createRequire","createSentryBuildPluginManager","createDebugIdUploadFunction","CodeInjection","generateReleaseInjectorCode","generateModuleMetadataInjectorCode","createComponentNameAnnotateHooks","replaceBooleanFlagsInCode","isJsFile","shouldSkipCodeInjection","isInitialChunk","hasExistingDebugID","getDebugIdForChunk","getDebugIdSnippet","MagicString","getCodeInjectionPosition","finalizeRolldownDebugIds","stampDebugIds","globFiles","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,IAAI,wBAAA;AAKJ,MAAM,mBAAA,GAAsB,4BAAA;AAE5B,SAAS,qBAAA,GAA4C;AACnD,EAAA,IAAI;AAGF,IAAA,MAAM,GAAA,GAAMA,yBAAA,CAAc,iQAAe,CAAA;AACzC,IAAA,MAAM,MAAA,GAAS,IAAI,QAAQ,CAAA;AAC3B,IAAA,OAAO,MAAA,CAAO,OAAA,EAAS,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AAAA,EACrC,CAAA,CAAA,MAAQ;AAAA,EAER;AAEA,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,oBAAA,GAA0D;AACjE,EAAA,IAAI,CAAC,wBAAA,EAA0B;AAC7B,IAAA,wBAAA,GAA2B,OAAA,CAAQ,OAAA,EAAQ,CACxC,IAAA,CAAK,YAAY;AAGhB,MAAA,MAAM,UAAA,GAAaA,yBAAA,CAAc,iQAAe,EAAE,MAA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,EAAS;AAAA,GACX,GACA,SAAA;AAEN,EAAA,OAAO;AAAA,IACL,IAAA;AAAA,IACA,UAAA;AAAA,IACA,GAAI,eAAA,GAAkB,EAAE,SAAA,EAAW,aAAA,KAAkB,EAAC;AAAA,IACtD,WAAA;AAAA,IACA,cAAA,EAAgB,EAAE,KAAA,EAAO,KAAA,EAAgB,SAAS,cAAA,EAAe;AAAA,IACjE;AAAA,GACF;AACF;AAGO,SAAS,kBAAA,CAAmB,WAAA,GAAuB,EAAC,EAAQ;AAGjE,EAAA,OAAO,CAAC,qBAAA,CAAsB,WAAA,EAAa,QAAQ,CAAC,CAAA;AACtD;;;;;"}
1
+ {"version":3,"file":"index.js","names":["createRequire","createSentryBuildPluginManager","createDebugIdUploadFunction","createSourceMapHandling","CodeInjection","generateReleaseInjectorCode","generateModuleMetadataInjectorCode","createComponentNameAnnotateHooks","replaceBooleanFlagsInCode","isJsFile","shouldSkipCodeInjection","isInitialChunk","hasExistingDebugID","getDebugIdForChunk","getDebugIdSnippet","MagicString","getCodeInjectionPosition","finalizeRolldownDebugIds","stampDebugIds","globFiles","path","createViteSourceMapHooks"],"sources":["../../../src/rollup/index.ts"],"sourcesContent":["import type { ChunkGraphNode, InternalOptions, Options } from '../core';\nimport {\n createSentryBuildPluginManager,\n generateReleaseInjectorCode,\n generateModuleMetadataInjectorCode,\n isJsFile,\n isInitialChunk,\n shouldSkipCodeInjection,\n getDebugIdSnippet,\n createDebugIdUploadFunction,\n globFiles,\n createComponentNameAnnotateHooks,\n replaceBooleanFlagsInCode,\n CodeInjection,\n getCodeInjectionPosition,\n} from '../core';\nimport type { ComponentAnnotationTransformMeta } from '../core/component-annotation-oxc';\nimport type { SourceMap } from 'magic-string';\nimport MagicString from 'magic-string';\nimport * as path from 'node:path';\nimport { createRequire } from 'node:module';\nimport { finalizeRolldownDebugIds, getDebugIdForChunk, hasExistingDebugID } from './debug-id-injection';\nimport { stampDebugIds, type OutputBundle } from './debug-id-stamping';\nimport { createSourceMapHandling, type OutputDestinationOptions } from './source-map-handling';\nimport { createViteSourceMapHooks } from '../vite/source-map-hooks';\n\n// The subset of Rollup's `TransformResult` that this plugin's `transform`\n// hook actually returns. Defined locally instead of imported from `rollup`\n// because `rollup` is an optional dependency.\ntype TransformResult = { code: string; map?: SourceMap | string | { mappings: string } | null } | null | undefined;\n\ntype ViteModule = {\n parseAstAsync?: (code: string, options: { lang: 'jsx' | 'tsx' }) => Promise<unknown>;\n};\n\ntype ViteParseAstAsync = NonNullable<ViteModule['parseAstAsync']>;\n\nlet viteParseAstAsyncPromise: Promise<ViteParseAstAsync | null> | undefined;\n\n// Rolldown sets `meta.rolldownVersion` on the plugin context.\ntype PluginContext = { meta?: { rolldownVersion?: string } };\n\nconst JS_MODULE_ID_FILTER = /\\.[cm]?[jt]sx?(?:[?#].*)?$/;\n\nfunction getRollupMajorVersion(): string | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Rollup already transpiles this for us\n const req = createRequire(import.meta.url);\n const rollup = req('rollup') as { VERSION?: string };\n return rollup.VERSION?.split('.')[0];\n } catch {\n // do nothing, we'll just not report a version\n }\n\n return undefined;\n}\n\nfunction getViteParseAstAsync(): Promise<ViteParseAstAsync | null> {\n if (!viteParseAstAsyncPromise) {\n viteParseAstAsyncPromise = Promise.resolve()\n .then(async () => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore - Vite is an optional runtime peer for this package\n const viteModule = createRequire(import.meta.url)('vite') as ViteModule;\n\n if (typeof viteModule.parseAstAsync !== 'function') {\n return null;\n }\n\n try {\n await viteModule.parseAstAsync('const x = <div />;', { lang: 'tsx' });\n } catch {\n return null;\n }\n\n return viteModule.parseAstAsync;\n })\n .catch(() => null);\n }\n\n return viteParseAstAsyncPromise;\n}\n\n/**\n * @ignore - internal plugin factory shared by the Rollup and Vite plugins.\n *\n * `main` carries injection, release creation and the upload. `post` runs last in `generateBundle`,\n * copies chunks and their source maps into the upload staging folder and drops the map assets\n * from the bundle, so the bundler never writes them.\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function _createRollupPluginInternals(\n userOptions: InternalOptions = {},\n buildTool: 'rollup' | 'vite',\n buildToolMajorVersion?: string,\n) {\n const sentryBuildPluginManager = createSentryBuildPluginManager(userOptions, {\n loggerPrefix: userOptions._metaOptions?.loggerPrefixOverride ?? `[sentry-${buildTool}-plugin]`,\n buildTool,\n buildToolMajorVersion: buildToolMajorVersion || getRollupMajorVersion(),\n });\n\n const {\n logger,\n normalizedOptions: options,\n bundleSizeOptimizationReplacementValues: replacementValues,\n bundleMetadata,\n createDependencyOnBuildArtifacts,\n } = sentryBuildPluginManager;\n\n if (options.disable) {\n return {\n main: {\n name: 'sentry-noop-plugin',\n },\n post: undefined,\n };\n }\n\n if (process.cwd().match(/\\\\node_modules\\\\|\\/node_modules\\//)) {\n logger.warn('Running Sentry plugin from within a `node_modules` folder. Some features may not work.');\n }\n\n const freeGlobalDependencyOnBuildArtifacts = createDependencyOnBuildArtifacts();\n const upload = createDebugIdUploadFunction({ sentryBuildPluginManager });\n const sourcemapsEnabled = options.sourcemaps?.disable !== true;\n const sourceMapHandling = createSourceMapHandling(sentryBuildPluginManager);\n const releaseInjectionCode = new CodeInjection();\n const chunkInjectionCode = new CodeInjection();\n\n if (!options.release.inject) {\n logger.debug('Release injection disabled via `release.inject` option. Will not inject release.');\n } else if (!options.release.name) {\n logger.debug(\n 'No release name provided. Will not inject release. Please set the `release.name` option to identify your release.',\n );\n } else {\n releaseInjectionCode.append(\n generateReleaseInjectorCode({\n release: options.release.name,\n injectBuildInformation: options._experiments.injectBuildInformation || false,\n }),\n );\n }\n\n if (Object.keys(bundleMetadata).length > 0) {\n chunkInjectionCode.append(generateModuleMetadataInjectorCode(bundleMetadata));\n }\n\n const transformAnnotations = options.reactComponentAnnotation?.enabled\n ? createComponentNameAnnotateHooks(\n options.reactComponentAnnotation?.ignoredComponents || [],\n !!options.reactComponentAnnotation?._experimentalInjectIntoHtml,\n {\n // Vite 8 already loads an oxc-based parser, so reuse it.\n getParseAstAsync: buildTool === 'vite' && buildToolMajorVersion === '8' ? getViteParseAstAsync : undefined,\n logger,\n },\n )\n : undefined;\n\n const transformReplace = Object.keys(replacementValues).length > 0;\n const shouldTransform = transformAnnotations || transformReplace;\n\n function buildStart(): void {\n void sentryBuildPluginManager.telemetry.emitBundlerPluginExecutionSignal().catch(() => {\n // Telemetry failures are acceptable\n });\n }\n\n async function transform(\n code: string,\n id: string,\n meta?: ComponentAnnotationTransformMeta,\n ): Promise<TransformResult> {\n // Component annotations are only in user code and boolean flag replacements are\n // only in Sentry code. If we successfully add annotations, we can return early.\n if (transformAnnotations) {\n const result = await transformAnnotations.transform(code, id, meta);\n if (result) {\n return result;\n }\n }\n\n if (transformReplace) {\n return replaceBooleanFlagsInCode(code, replacementValues);\n }\n\n return null;\n }\n\n function renderChunk(\n this: PluginContext | undefined,\n code: string,\n chunk: { fileName: string; facadeModuleId?: string | null; isEntry?: boolean },\n _?: unknown,\n meta?: { magicString?: MagicString; chunks?: Record<string, ChunkGraphNode> },\n ): {\n code: string;\n map?: SourceMap;\n } | null {\n if (!isJsFile(chunk.fileName)) {\n return null; // returning null means not modifying the chunk at all\n }\n\n // Skip empty chunks and HTML facade chunks (Vite MPA)\n if (shouldSkipCodeInjection(code, chunk.facadeModuleId)) {\n return null;\n }\n\n const injectCode = new CodeInjection();\n\n if (isInitialChunk(chunk, meta?.chunks)) {\n injectCode.append(releaseInjectionCode);\n }\n\n injectCode.append(chunkInjectionCode);\n\n if (sourcemapsEnabled && !hasExistingDebugID(code)) {\n const debugId = getDebugIdForChunk(code, !!this?.meta?.rolldownVersion);\n injectCode.append(getDebugIdSnippet(debugId));\n }\n\n if (injectCode.isEmpty()) {\n return null;\n }\n\n const ms = meta?.magicString || new MagicString(code, { filename: chunk.fileName });\n const injectionPosition = getCodeInjectionPosition(code);\n const codeToInject = injectionPosition === code.length ? `\\n${injectCode.code()}` : injectCode.code();\n ms.appendLeft(injectionPosition, codeToInject);\n\n // Rolldown can pass a native MagicString instance in meta.magicString\n // https://rolldown.rs/in-depth/native-magic-string#usage-examples\n if (ms?.constructor?.name === 'BindingMagicString') {\n // Rolldown docs say to return the magic string instance directly in this case\n return { code: ms as unknown as string };\n }\n\n return {\n code: ms.toString(),\n map: ms.generateMap({ file: chunk.fileName, hires: 'boundary' }),\n };\n }\n\n /**\n * Resolves Rolldown's placeholder debug IDs, then stamps debug IDs into the emitted chunks and\n * source maps.\n *\n * `disable-upload` skips the upload routine (which stamps debug IDs into temp copies), so the emitted\n * artifacts get stamped here instead. Not in `renderChunk`: minifiers running after it would strip the\n * comment. Rollup computes `[hash]` file names before this hook, so only plugins that hash the final\n * assets afterwards (e.g. subresource integrity) see the stamped content.\n */\n function generateBundle(this: PluginContext | undefined, _outputOptions: unknown, bundle: OutputBundle): void {\n if (this?.meta?.rolldownVersion) {\n finalizeRolldownDebugIds(bundle);\n }\n\n if (options.sourcemaps?.disable !== 'disable-upload') {\n return;\n }\n\n stampDebugIds(bundle, true);\n }\n\n async function writeBundle(outputOptions: OutputDestinationOptions, bundle: OutputBundle | undefined): Promise<void> {\n const staging = await sourceMapHandling.takeStaging(outputOptions, bundle);\n let stagingHandedOver = false;\n\n try {\n await sentryBuildPluginManager.createRelease();\n\n if (sourcemapsEnabled && options.sourcemaps?.disable !== 'disable-upload') {\n let buildArtifacts: string[];\n if (outputOptions.dir) {\n const outputDir = outputOptions.dir;\n const JS_AND_MAP_PATTERNS = [\n '/**/*.js',\n '/**/*.mjs',\n '/**/*.cjs',\n '/**/*.js.map',\n '/**/*.mjs.map',\n '/**/*.cjs.map',\n ].map(q => `${q}?(\\\\?*)?(#*)`); // We want to allow query and hash strings at the end of files\n buildArtifacts = await globFiles(JS_AND_MAP_PATTERNS, { root: outputDir });\n } else if (outputOptions.file) {\n buildArtifacts = [outputOptions.file];\n } else {\n buildArtifacts = Object.keys(bundle ?? {}).map(asset => path.join(path.resolve(), asset));\n }\n stagingHandedOver = true;\n await upload(buildArtifacts, { staging });\n } else {\n stagingHandedOver = true;\n await staging?.discard();\n }\n } catch (e) {\n if (!stagingHandedOver) {\n await staging?.keep('The source map upload did not run.');\n }\n throw e;\n } finally {\n freeGlobalDependencyOnBuildArtifacts();\n await sentryBuildPluginManager.deleteArtifacts();\n }\n }\n\n const name = `sentry-${buildTool}-plugin`;\n const transformHook =\n buildTool === 'vite'\n ? {\n filter: { id: JS_MODULE_ID_FILTER },\n handler: transform,\n }\n : transform;\n\n // Vite warns about `rollupOptions.output.sourcemap`, so the Vite plugin\n // decides in a `config` hook instead.\n const viteSourceMapHooks =\n buildTool === 'vite' ? createViteSourceMapHooks(sentryBuildPluginManager, sourceMapHandling) : undefined;\n\n const main = {\n name,\n buildStart,\n ...(shouldTransform ? { transform: transformHook } : {}),\n ...(viteSourceMapHooks\n ? { configResolved: viteSourceMapHooks.configResolved }\n : { outputOptions: sourceMapHandling.outputOptions }),\n renderChunk,\n generateBundle: { order: 'pre' as const, handler: generateBundle },\n writeBundle,\n };\n\n const post = {\n name: buildTool === 'vite' ? 'sentry-vite-upload-staging' : 'sentry-rollup-upload-staging',\n // On the post plugin, so framework plugins that set `build.sourcemap`\n // themselves run first and the decision sees the merged setting.\n ...(viteSourceMapHooks ? { config: viteSourceMapHooks.config } : {}),\n generateBundle: {\n order: 'post' as const,\n async handler(outputOptions: OutputDestinationOptions, bundle: OutputBundle, isWrite?: boolean): Promise<void> {\n if (buildTool === 'vite' && options.sourcemaps?.disable === 'disable-upload') {\n // Vite's module preload rewrite in `generateBundle` regenerates the source map of every\n // chunk with a dynamic import, which drops the debug ID the main plugin stamped in its\n // `pre` hook. Restore it without touching the chunk code, so file hashes stay valid.\n stampDebugIds(bundle, false);\n }\n\n await sourceMapHandling.stageSourceMaps(outputOptions, bundle, isWrite);\n },\n },\n };\n\n return { main, post };\n}\n\n/**\n * @ignore - this is the internal plugin factory function only used for the Vite plugin!\n */\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nexport function _rollupPluginInternal(\n userOptions: Options = {},\n buildTool: 'rollup' | 'vite',\n buildToolMajorVersion?: string,\n) {\n return _createRollupPluginInternals(userOptions, buildTool, buildToolMajorVersion).main;\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/no-explicit-any\nexport function sentryRollupPlugin(userOptions: Options = {}): any {\n const { main, post } = _createRollupPluginInternals(userOptions, 'rollup');\n // We return an array here so we don't break backwards compatibility with what\n // unplugin used to return\n return post ? [main, post] : [main];\n}\n\nexport type { Options as SentryRollupPluginOptions } from '../core';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqCA,IAAI;AAKJ,MAAM,sBAAsB;AAE5B,SAAS,wBAA4C;CACnD,IAAI;EAKF,QAAA,GAFYA,YAAAA,cAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,IACK,CAAC,CAAC,QACP,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,CAAC;CACpC,QAAQ,CAER;AAGF;AAEA,SAAS,uBAA0D;CACjE,IAAI,CAAC,0BACH,2BAA2B,QAAQ,QAAQ,CAAC,CACzC,KAAK,YAAY;EAGhB,MAAM,cAAA,GAAaA,YAAAA,cAAAA,CAAAA,QAAAA,KAAAA,CAAAA,CAAAA,cAAAA,UAAAA,CAAAA,CAAAA,IAA6B,CAAC,CAAC,MAAM;EAExD,IAAI,OAAO,WAAW,kBAAkB,YACtC,OAAO;EAGT,IAAI;GACF,MAAM,WAAW,cAAc,sBAAsB,EAAE,MAAM,MAAM,CAAC;EACtE,QAAQ;GACN,OAAO;EACT;EAEA,OAAO,WAAW;CACpB,CAAC,CAAC,CACD,YAAY,IAAI;CAGrB,OAAO;AACT;;;;;;;;AAUA,SAAgB,6BACd,cAA+B,CAAC,GAChC,WACA,uBACA;CACA,MAAM,2BAA2BC,6BAAAA,+BAA+B,aAAa;EAC3E,cAAc,YAAY,cAAc,wBAAw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