-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
feat: source maps #1609
Conversation
Thank you for the contribution! Is this impacting the bundle size? |
@willydouhard It depends on what you mean by bundle size. The bundle itself (i.e., the size of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
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 ofindex.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 upgradingtsup
to version 8.1.2 or later.Unfortunately, I wasn't able to get source maps working for
libs/*
when they are included in thefrontend
app compiled in production mode. This seems to be an issue with Vite/React/SWC, as it affects all dependencies, not justlibs/*
. However, source maps forlibs/*
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.