-
-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathcheck-exports.mjs
73 lines (61 loc) · 2.23 KB
/
check-exports.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import * as browser from '@sentry/browser';
import * as renderer from '../esm/renderer/index.js';
import * as utility from '../esm/utility/index.js';
import * as node from '@sentry/node';
// We need to shim electron to avoid errors when importing the main process code into plain-old-node that doesn't have
// the electron module built-in.
import './electron-shim.mjs';
const main = await import('../esm/main/index.js');
const browserExports = Object.keys(browser);
const rendererExports = Object.keys(renderer);
const nodeExports = Object.keys(node);
const mainExports = Object.keys(main);
const utilityExports = Object.keys(utility);
const ignoredBrowser = [
'SDK_VERSION',
'WINDOW',
'Integrations',
'close',
'flush',
'defaultStackLineParsers',
// These wont ever be used
'geckoStackLineParser',
'opera10StackLineParser',
'opera11StackLineParser',
'winjsStackLineParser',
// If you use the browser transports, just use the browser SDK
'makeBrowserOfflineTransport',
'makeFetchTransport',
'makeMultiplexedTransport',
'lazyLoadIntegration',
// deprecated
'captureUserFeedback',
];
const ignoredNode = [
'SDK_VERSION',
'makeNodeTransport',
'getSentryRelease',
// There's no way to use this in the main process
'preloadOpenTelemetry',
// We don't include these by default in the Electron SDK
'getDefaultIntegrationsWithoutPerformance',
'initWithoutDefaultIntegrations',
// We can't call these from Electron
'vercelAIIntegration',
];
const ignoredUtility = [...ignoredNode, 'anrIntegration'];
const missingRenderer = browserExports.filter((key) => !rendererExports.includes(key) && !ignoredBrowser.includes(key));
const missingMain = nodeExports.filter((key) => !mainExports.includes(key) && !ignoredNode.includes(key));
const missingUtility = nodeExports.filter((key) => !utilityExports.includes(key) && !ignoredUtility.includes(key));
if (missingRenderer.length || missingMain.length || missingUtility.length) {
if (missingRenderer.length) {
console.error('Missing renderer exports:', missingRenderer);
}
if (missingMain.length) {
console.error('Missing main exports:', missingMain);
}
if (missingUtility.length) {
console.error('Missing utility exports:', missingUtility);
}
process.exit(1);
}