You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -51,40 +63,70 @@ function esbuildDebugIdInjectionPlugin(logger: Logger): UnpluginOptions {
51
63
52
64
esbuild: {
53
65
setup({ initialOptions, onLoad, onResolve }){
66
+
// Clear state from previous builds (important for watch mode and test suites)
67
+
debugIdWrappedPaths.clear();
68
+
// Also clear metadataProxyEntryPoints here because if moduleMetadataInjectionPlugin
69
+
// is not instantiated in this build (e.g., moduleMetadata was disabled), we don't
70
+
// want stale entries from a previous build to affect the current one.
71
+
metadataProxyEntryPoints.clear();
72
+
54
73
if(!initialOptions.bundle){
55
74
logger.warn(
56
75
"The Sentry esbuild plugin only supports esbuild with `bundle: true` being set in the esbuild build options. Esbuild will probably crash now. Sorry about that. If you need to upload sourcemaps without `bundle: true`, it is recommended to use Sentry CLI instead: https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/cli/"
57
76
);
58
77
}
59
78
60
79
onResolve({filter: /.*/},(args)=>{
61
-
if(args.kind!=="entry-point"){
80
+
// Inject debug IDs into entry points and into imports from metadata proxy modules
81
+
constisEntryPoint=args.kind==="entry-point";
82
+
83
+
// Check if this import is coming from a metadata proxy module
84
+
// The metadata plugin registers entry points it wraps in the shared Set
85
+
// We need to strip the query string suffix because esbuild includes the suffix
86
+
// (e.g., ?sentryMetadataProxyModule=true) in args.importer
87
+
constimporterPath=args.importer?.split("?")[0];
88
+
constisImportFromMetadataProxy=
89
+
args.kind==="import-statement"&&
90
+
importerPath!==undefined&&
91
+
metadataProxyEntryPoints.has(importerPath);
92
+
93
+
if(!isEntryPoint&&!isImportFromMetadataProxy){
62
94
return;
63
-
}else{
64
-
// Injected modules via the esbuild `inject` option do also have `kind == "entry-point"`.
65
-
// We do not want to inject debug IDs into those files because they are already bundled into the entrypoints
66
-
if(initialOptions.inject?.includes(args.path)){
67
-
return;
68
-
}
95
+
}
69
96
70
-
return{
71
-
pluginName,
72
-
// needs to be an abs path, otherwise esbuild will complain
0 commit comments