Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/bundler-plugin-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,3 +495,5 @@ export type { Logger } from "./logger";
export type { Options, SentrySDKBuildFlags } from "./types";
export { CodeInjection, replaceBooleanFlagsInCode, stringToUUID } from "./utils";
export { createSentryBuildPluginManager } from "./build-plugin-manager";
export { generateGlobalInjectorCode, generateModuleMetadataInjectorCode } from "./utils";
export { createDebugIdUploadFunction } from "./debug-id-upload";
1 change: 0 additions & 1 deletion packages/webpack-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
},
"dependencies": {
"@sentry/bundler-plugin-core": "4.9.1",
"unplugin": "1.0.1",
"uuid": "^9.0.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/webpack-plugin/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import babel from "@rollup/plugin-babel";
import packageJson from "./package.json";
import modulePackage from "module";

const input = ["src/index.ts", "src/webpack5.ts"];
const input = ["src/index.ts", "src/webpack5.ts", "src/component-annotation-transform.ts"];

const extensions = [".ts"];

Expand Down
43 changes: 43 additions & 0 deletions packages/webpack-plugin/src/component-annotation-transform.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Webpack loader for component annotation transform
// Based on unplugin v1.0.1 transform loader pattern

export default async function transform(
this: {
async: () => (err: Error | null, content?: string, sourceMap?: unknown) => void;
resourcePath: string;
query: {
transform?: (
code: string,
id: string
) => Promise<{ code: string; map?: unknown } | null | undefined | string>;
};
},
source: string,
map: unknown
): Promise<void> {
const callback = this.async();
const { transform: transformFn } = this.query;

if (!transformFn) {
return callback(null, source, map);
}

try {
const id = this.resourcePath;
const result = await transformFn(source, id);

if (result == null) {
callback(null, source, map);
} else if (typeof result === "string") {
callback(null, result, map);
} else {
callback(null, result.code, result.map || map);
}
} catch (error) {
if (error instanceof Error) {
callback(error);
} else {
callback(new Error(String(error)));
}
}
}
12 changes: 5 additions & 7 deletions packages/webpack-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SentryWebpackPluginOptions, sentryWebpackUnpluginFactory } from "./webpack4and5";
import { SentryWebpackPluginOptions, sentryWebpackPluginFactory } from "./webpack4and5";

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore webpack is a peer dep
Expand All @@ -8,14 +8,12 @@ const BannerPlugin = webpack4or5?.BannerPlugin || webpack4or5?.default?.BannerPl

const DefinePlugin = webpack4or5?.DefinePlugin || webpack4or5?.default?.DefinePlugin;

const sentryUnplugin = sentryWebpackUnpluginFactory({
BannerPlugin,
DefinePlugin,
});

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const sentryWebpackPlugin: (options?: SentryWebpackPluginOptions) => any =
sentryUnplugin.webpack;
sentryWebpackPluginFactory({
BannerPlugin,
DefinePlugin,
});

export { sentryCliBinaryExists } from "@sentry/bundler-plugin-core";

Expand Down
Loading
Loading