🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@grantnelson-wf
Copy link
Collaborator

@grantnelson-wf grantnelson-wf commented Oct 22, 2025

Adding JS writer to source map filter so that we can also map the JS files (prelude and .inc.js) into the source map. When doing this, it moved more of the source mapping code into sourcemapx. This will help with debugging when the error comes from the preludes. For example, if we call "Hello"[1:800] it will panic for the out-of-bounds index, but that error comes from the prelude JS files it wasn't being mapped. To make the mapping work, I reused the esbuild dependency that was added to the prelude for minimization for creating a source map for JS even when not minimized.

esbuild does some stuff to the JS code when not being minimized. I turned as much of that off as I could figure out how to do. It looks like most of the added stuff is to define properties and help with tree shaking. There will still be some differences between the prelude and output, but they are negligible. The minimized version is nearly identical with the JS changes turned off as they were prior to this PR.

This might be related to #943


I also fixed the lint issue that got into master (I'm not sure why lint issues aren't being reported all the time in PRs and we should probably fix that so we don't get a red x on master just because of an extra line).


The change in the js size is not significant but obviously it will increase the js.map size.

Branch minimized js (bytes) js.map (bytes)
srcMapPrelude 5,079,824 397,761
srcMapPrelude X 3,218,929 377,690
master 5,091,184 349,192
master X 3,217,561 335,166
diff -11,360 +48,569
diff X +1,368 +42,524
diff (%) -0.233 +13.909
diff (%) X +0.043 +12.687

@grantnelson-wf grantnelson-wf self-assigned this Oct 22, 2025
@grantnelson-wf grantnelson-wf force-pushed the srcMapPrelude branch 5 times, most recently from c19ae7a to c3c2abb Compare October 22, 2025 22:53
Copy link
Member

@nevkontakte nevkontakte left a comment

Choose a reason for hiding this comment

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

This is quite neat, thank you!

@grantnelson-wf grantnelson-wf marked this pull request as ready for review October 28, 2025 22:23
@grantnelson-wf grantnelson-wf merged commit 32d7337 into gopherjs:master Oct 29, 2025
10 checks passed
@grantnelson-wf grantnelson-wf deleted the srcMapPrelude branch October 29, 2025 20:47
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.

2 participants