Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): add sourcemap remapping #29786

Merged
merged 13 commits into from
Mar 12, 2025
Merged

Conversation

hpouillot
Copy link
Contributor

Problem

When changing source files, sourcemaps need to be offset.

@hpouillot hpouillot requested review from a team, daibhin and oliverb123 March 11, 2025 18:16
@oliverb123 oliverb123 force-pushed the err/hp-sourcemap-remapping branch from 76b0e33 to 3e566a7 Compare March 11, 2025 18:23
@oliverb123 oliverb123 changed the title add sourcemap remapping feat(cli): add sourcemap remapping Mar 11, 2025
@hpouillot hpouillot force-pushed the err/hp-sourcemap-remapping branch from 3e566a7 to 09270fa Compare March 11, 2025 18:54
@hpouillot hpouillot force-pushed the err/hp-sourcemap-remapping branch from 14a69c6 to 2498e22 Compare March 12, 2025 17:08
@hpouillot hpouillot marked this pull request as ready for review March 12, 2025 17:13
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR adds sourcemap remapping functionality to the PostHog CLI, enabling proper handling of sourcemaps when source files are modified, with automatic chunk ID injection and mapping adjustments.

  • Added sourcemap remapping with magic_string and sourcemap crates in /rust/posthog-cli/src/utils/sourcemaps.rs to handle source file modifications
  • Implemented chunk ID injection with runtime tracking via CODE_SNIPPET_TEMPLATE in /rust/posthog-cli/src/utils/constant.rs
  • Added comprehensive test cases in /rust/posthog-cli/tests/sourcemap.rs for verifying sourcemap pair reading and chunk ID injection
  • Simplified CLI interface by removing optional output directory in /rust/posthog-cli/src/commands/mod.rs
  • Note: There's a typo "CHUNCK" in the chunk ID placeholder constants that should be fixed

18 file(s) reviewed, 7 comment(s)
Edit PR Review Bot Settings | Greptile

hpouillot and others added 6 commits March 12, 2025 18:19
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@hpouillot hpouillot enabled auto-merge (squash) March 12, 2025 17:35
@hpouillot hpouillot merged commit 81af8a7 into master Mar 12, 2025
76 checks passed
@hpouillot hpouillot deleted the err/hp-sourcemap-remapping branch March 12, 2025 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants