Esri / calcite-design-system

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

Question about sourcemap generation #8902

Open nCastle1 opened 5 months ago

nCastle1 commented 5 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 5 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 5 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