Esri / calcite-design-system

A monorepo containing the packages for Esri's Calcite Design System
https://developers.arcgis.com/calcite-design-system/
Other
293 stars 75 forks source link

Question about sourcemap generation #8902

Closed nCastle1 closed 2 months ago

nCastle1 commented 8 months ago

Summary

As a consumer of Calcite Components used through another project, it is sometimes helpful to set breakpoints in Calcite Components source. Examples of when this is helpful include debugging complex browser-specific issues and improving the quality of Calcite Components bug reports.

Currently, Calcite Components emits built output in the dist/components folder. The source maps in this folder have paths pointing to src/components/. In effect, this means the source maps point to source files at dist/components/src/components, whereas the source files are really at src/components. This isn't an issue in the browser, but the incorrect file location breaks debugging integration with tools like VS Code.

Desired Outcome

Emit sourcemaps with valid "sources" entries by default or add a sourceRoot entry to point to the correct path on disk.

Resources

Currently, I can work around this issue by updating the post-build script at packages/calcite-components/support/patchESMResolution.ts to also prepend ../../ to all paths in sourcemap files. This works for now but it is clearly a hack. Long term, it would be ideal configure Stencil to emit corrected locations by default.

jcfranco commented 8 months ago

Thanks for submitting this. Would you mind sharing more info about your use case? I'd like to know more about the build structure in particular. This might be something that needs to be handled on the consuming-project level (e.g., https://www.npmjs.com/package/source-map-loader, https://www.npmjs.com/package/rollup-plugin-sourcemaps).

jcfranco commented 8 months ago

Connected w/ @nCastle1 on this and we'll revisit this later in the year, if possible. This is a nice-to-have and not blocking workflows at the moment thanks to Nathan's workaround. cc @geospatialem

nCastle1 commented 2 months ago

Closing this, recent changes to Calcite build (I think probably the stencil update?) have rendered this moot. Sourcemaps are working correctly for my workflow in VS Code.