getsentry / sentry-javascript-bundler-plugins

JavaScript Bundler Plugins for Sentry
https://sentry.io
BSD 3-Clause "New" or "Revised" License
136 stars 35 forks source link

[webpack] debugId on main entry file keeps changing due to other chunk #447

Open vincenthend opened 11 months ago

vincenthend commented 11 months ago

Environment

@sentry/webpack-plugin@2.7.0

Steps to Reproduce

Apparently this happened due to the use of hash for generating debugId

        new BannerPlugin({
          raw: true,
          include: /\.(js|ts|jsx|tsx|mjs|cjs)$/,
          banner: (arg?: BannerPluginCallbackArg) => {
            const debugId = arg?.chunk?.hash ? stringToUUID(arg.chunk.hash) : uuidv4();
            return getDebugIdSnippet(debugId);
          },
        })

Expected Result

Actual Result

Suggestion

Probably good if we can have it generated based on contentHash instead of hash

lforst commented 11 months ago

Since foo.js keeps changing on every build, thedebugId generated for main.js is affected

Can you explain why changing foo.js affects the hash of main.js?

But in general you're probably right that we should use the content hash instead.

vincenthend commented 11 months ago

Can you explain why changing foo.js affects the hash of main.js?

Hmm, if I'm debugging it correctly, the cause for my case is due to chunk.hash for entry files seems to be generated using the child compilation