|
2 | 2 |
|
3 | 3 | 'use strict'; |
4 | 4 |
|
| 5 | +import type { ExternalService as IExternalService } from '../api/account-servers/external-service.js'; |
| 6 | +import { Env } from '../browser/env.js'; |
5 | 7 | import { Url } from '../core/common.js'; |
6 | 8 | import { FLAVOR, VERSION } from '../core/const.js'; |
7 | 9 | import { CatchHelper } from './catch-helper.js'; |
@@ -284,9 +286,26 @@ export class Catch { |
284 | 286 | return; |
285 | 287 | } |
286 | 288 |
|
287 | | - // eslint-disable-next-line @typescript-eslint/naming-convention |
288 | | - const { ExternalService } = await import('../api/account-servers/external-service.js'); |
289 | | - const externalService = new ExternalService(acctEmail); |
| 289 | + let externalService: IExternalService; |
| 290 | + if (Env.isContentScript()) { |
| 291 | + /** |
| 292 | + * – In content-script builds, the class is already bundled in `webmail_bundle.js` |
| 293 | + * so we just grab it from the global scope. |
| 294 | + * ⚠️ If we *ever* try to dynamically import this module from a content-script |
| 295 | + * the browser will throw: |
| 296 | + * “Denying load of chrome-extension://…/external-service.js. |
| 297 | + * Resources (including all dependencies this file uses) must be listed in the web_accessible_resources manifest key” |
| 298 | + */ |
| 299 | + // eslint-disable-next-line @typescript-eslint/ban-ts-comment |
| 300 | + // @ts-expect-error |
| 301 | + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call |
| 302 | + externalService = new ExternalService(acctEmail); |
| 303 | + } else { |
| 304 | + // eslint-disable-next-line @typescript-eslint/naming-convention |
| 305 | + const { ExternalService } = await import('../api/account-servers/external-service.js'); |
| 306 | + externalService = new ExternalService(acctEmail); |
| 307 | + } |
| 308 | + |
290 | 309 | await externalService.setUrlBasedOnFesStatus(); |
291 | 310 | await externalService.reportException(errorReport); |
292 | 311 | } |
|
0 commit comments