Bug description
#4520 removed source maps (specifically, sourcesContent) from the posthog-js package. This introduced two potential problems:
- Our Webpack was set up to include our dependencies' source maps in our front-end bundle's own source maps, for the benefit of tools like Sentry. In practice, this may not matter much - PostHog is a reliable product, so it's unlikely to appear in a Sentry error report's captured stack trace. However, that PR's statement ("no, they don't reach anyone's bundle output. That's exactly why this is cheap to fix") seems incorrect or at least inadequate: they don't reach the executable bundle, but they can be included in the bundler's output (depending on bundler and configuration).
- Webpack's source-map-loader complains when it's unable to resolve a source map entry. Since
sourcesContent is now gone and the files referenced by posthog-js's sources don't exist, this now results in 125 warnings of console spam whenever we build our front-end bundle:
WARNING in ../../node_modules/posthog-js/dist/module.js
Module Warning (from ../../node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/josh/src/app/node_modules/posthog-js/src/utils/survey-event-receiver.ts' file: Error: ENOENT: no such file or directory, open '/Users/josh/src/app/node_modules/posthog-js/src/utils/survey-event-receiver.ts'
There'a also at least one absolute path from Posthog's build server that's being emitted:
WARNING in ../../node_modules/posthog-js/dist/module.js
Module Warning (from ../../node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/Users/setup-pnpm/node_modules/.bin/store/v11/links/@/fflate/0.4.8/3d6bb6f51514b78f73eff8bf58c4fef7e18a9483e0eef595f39f3a49c6c31e1d/node_modules/fflate/esm/browser.js' file: Error: ENOENT: no such file or directory, open '/Users/setup-pnpm/node_modules/.bin/store/v11/links/@/fflate/0.4.8/3d6bb6f51514b78f73eff8bf58c4fef7e18a9483e0eef595f39f3a49c6c31e1d/node_modules/fflate/esm/browser.js'
How to reproduce
See https://github.com/joshkel/posthog-source-maps-missing for an LLM-generated test case.
Related sub-libraries
Additional context
If keeping source map debuggability is desired, then https://github.com/joshkel/posthog-source-maps-missing#suggestions contains some suggestions from the LLM on how to address the issue.
Bug description
#4520 removed source maps (specifically,
sourcesContent) from the posthog-js package. This introduced two potential problems:sourcesContentis now gone and the files referenced by posthog-js'ssourcesdon't exist, this now results in 125 warnings of console spam whenever we build our front-end bundle:There'a also at least one absolute path from Posthog's build server that's being emitted:
How to reproduce
See https://github.com/joshkel/posthog-source-maps-missing for an LLM-generated test case.
Related sub-libraries
Additional context
If keeping source map debuggability is desired, then https://github.com/joshkel/posthog-source-maps-missing#suggestions contains some suggestions from the LLM on how to address the issue.