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

Fix sourcemaps in dev builds #25901

Merged
merged 2 commits into from
May 1, 2023
Merged

Conversation

donmccurdy
Copy link
Collaborator

@donmccurdy donmccurdy commented Apr 21, 2023

Sourcemaps have been broken in development builds since we began using custom Rollup plugins, as far as I can tell. This PR updates our existing Rollup plugins to preserve source maps, so that we can set debug points in source files (rather than three.module.js) during development.

The update requires npm package magic-string as a dev dependency, 6.4kb minzipped, by the author of Rollup.

Related:

@github-actions
Copy link

github-actions bot commented Apr 21, 2023

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
634 kB (157.2 kB) 634 kB (157.2 kB) +0 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Filesize dev Filesize PR Diff
425.2 kB (103.1 kB) 425.2 kB (103.1 kB) +0 B

@donmccurdy donmccurdy changed the title Build sourcemaps during development Fix sourcemaps in dev builds Apr 21, 2023
@LeviPesin
Copy link
Contributor

For what source maps are used? I never used them personally.

@donmccurdy
Copy link
Collaborator Author

donmccurdy commented Apr 21, 2023

If you're debugging bundled code in your browser's developer tools and can see source files, then your bundler has provided sourcemaps. Sourcemaps allow the browser to display and set breakpoints in the source code, even though compiled code is what's running.

sourcemaps

For me this is helpful – knowing I want to debug something in KeyframeTrack.js, I can open the Source tab and jump straight to that file (Cmd + P) rather than searching for line 39,380 in the compiled code.

There's also a link at the bottom of the source file if you want to view the compiled code instead.

@donmccurdy donmccurdy added this to the r153 milestone Apr 23, 2023
@donmccurdy
Copy link
Collaborator Author

donmccurdy commented May 1, 2023

Going to merge — This PR fixes the errors shown in the logs during a build, and makes it much easier for me to debug code in the renderer (required for #25909).

@donmccurdy donmccurdy merged commit 3084e3b into mrdoob:dev May 1, 2023
@donmccurdy donmccurdy deleted the feat/sourcemaps branch May 1, 2023 04:50
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