Split gz.ts properly into node and browser variants #5764
+140
−61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed that webpack was still including the gz worker in the generated symbolicator-cli bundle. And esbuild was even putting it in a separate file. But we don't need the gz worker in the symbolicator-cli bundle; symbolicator-cli targets node so we really just want to run the node version of gz.ts.
This PR makes the "node" version the default behaviour of gz.ts, and then adds a browser override via the package.json "browser" mapping to use the worker version.
In our tests we want to use the worker version though, because we want to test what happens in a browser environment. So we use a custom jest-resolver.js. I tried to use
browser-resolve(as suggested in the Jest docs) in it but it ended up resolving some ESM dependencies like valibot to their mjs variant instead of their CJS variant and broke the tests, so I kept a manual implementation instead. I didn't dig very deep.With this change, the symbolicator-cli bundle no longer contains the gz worker code.