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: source maps #1609

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

asvishnyakov
Copy link

This PR adds source map support to the Chainlit frontend and the react-client library.

Source maps make debugging easier, particularly in production environments. They allow you to debug pre-compiled code without needing to deploy a debug version or run Chainlit from the source code.

This PR enables source map generation as separate files, ensuring it does not affect the resulting bundle, package, or wheel size, except for a single line added at the end of each file to reference the corresponding source map file.

You can learn more about source maps here and the settings used here and here.

After this PR, the build system may generate numerous warnings about missing source maps and incorrectly (though this doesn't seem to have much impact) add the source map link to files twice, with the wrong file name the first time (out.js.map instead of index.js.map).

The first issue can be resolved by upgrading to vite-plugin-react-swc version 3.7.1 or later, and the second by upgrading tsup to version 8.1.2 or later.

Unfortunately, I wasn't able to get source maps working for libs/* when they are included in the frontend app compiled in production mode. This seems to be an issue with Vite/React/SWC, as it affects all dependencies, not just libs/*. However, source maps for libs/* are generated correctly and can be used in other apps that depend on these libraries.

Feel free to edit this PR if needed as I allowed edits by maintainers.

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. frontend Pertains to the frontend. labels Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend Pertains to the frontend. size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant