forked from getsentry/sentry-javascript-bundler-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
58 lines (51 loc) · 1.91 KB
/
index.ts
File metadata and controls
58 lines (51 loc) · 1.91 KB
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
import {
sentryUnpluginFactory,
Options,
createRollupInjectionHooks,
createRollupDebugIdUploadHooks,
SentrySDKBuildFlags,
createRollupBundleSizeOptimizationHooks,
createComponentNameAnnotateHooks,
Logger,
} from "@sentry/bundler-plugin-core";
import type { UnpluginOptions } from "unplugin";
function rollupComponentNameAnnotatePlugin(ignoredComponents?: string[]): UnpluginOptions {
return {
name: "sentry-rollup-component-name-annotate-plugin",
rollup: createComponentNameAnnotateHooks(ignoredComponents),
};
}
function rollupInjectionPlugin(injectionCode: string, debugIds: boolean): UnpluginOptions {
return {
name: "sentry-rollup-injection-plugin",
rollup: createRollupInjectionHooks(injectionCode, debugIds),
};
}
function rollupDebugIdUploadPlugin(
upload: (buildArtifacts: string[]) => Promise<void>,
logger: Logger,
createDependencyOnBuildArtifacts: () => () => void
): UnpluginOptions {
return {
name: "sentry-rollup-debug-id-upload-plugin",
rollup: createRollupDebugIdUploadHooks(upload, logger, createDependencyOnBuildArtifacts),
};
}
function rollupBundleSizeOptimizationsPlugin(
replacementValues: SentrySDKBuildFlags
): UnpluginOptions {
return {
name: "sentry-rollup-bundle-size-optimizations-plugin",
rollup: createRollupBundleSizeOptimizationHooks(replacementValues),
};
}
const sentryUnplugin = sentryUnpluginFactory({
injectionPlugin: rollupInjectionPlugin,
componentNameAnnotatePlugin: rollupComponentNameAnnotatePlugin,
debugIdUploadPlugin: rollupDebugIdUploadPlugin,
bundleSizeOptimizationsPlugin: rollupBundleSizeOptimizationsPlugin,
});
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const sentryRollupPlugin: (options?: Options) => any = sentryUnplugin.rollup;
export type { Options as SentryRollupPluginOptions } from "@sentry/bundler-plugin-core";
export { sentryCliBinaryExists } from "@sentry/bundler-plugin-core";