plotly / dash

Data Apps & Dashboards for Python. No JavaScript Required.
https://plotly.com/dash
MIT License
21.15k stars 2.04k forks source link

Remove sourcemap links from bundles when we publish without sourcemaps #2356

Open afey89 opened 1 year ago

afey89 commented 1 year ago

Hi,

when installing dash-player (versions > 1.0), the file /dash_player/dash_player.min.js.map is somehow missing. I installed the package via poetry, which uses pip under the shell to install. Installation worked without errors or warnings.

I could add the .zipped package and get the file from there for now.

bart-pywalker commented 1 year ago

Same issue on my end; installed with pip python environment

alexcjohnson commented 1 year ago

We often don’t include sourcemaps in the distribution, as it makes the wheel/tarball much larger. Do you actually want the sourcemap or do you just want to avoid the console warning resulting from its absence? Ideally I guess when we’re building the distribution we should remove the sourcemap link from the end of the bundle so it doesn’t trigger that warning when it isn’t found, but we should come up with a pattern for that that we can replicate across all component packages.

bart-pywalker commented 1 year ago

We often don’t include sourcemaps in the distribution, as it makes the wheel/tarball much larger. Do you actually want the sourcemap or do you just want to avoid the console warning resulting from its absence? Ideally I guess when we’re building the distribution we should remove the sourcemap link from the end of the bundle so it doesn’t trigger that warning when it isn’t found, but we should come up with a pattern for that that we can replicate across all component packages.

Yea, I was just flustered by the warning. No issues with the package. Works great!

alexcjohnson commented 1 year ago

Moved this issue into the main dash repo, so we can some up with a repeatable pattern. Here's the JS console when you first load https://dash.plotly.com/, full of pointless warnings:

Screenshot 2022-12-07 at 08 29 27
alexcjohnson commented 1 year ago

I believe all we'd need to do is remove the last line from each bundle file, that looks something like this:

//# sourceMappingURL=dash_core_components.js.map

prior to packing the tarball & wheel - then put it back afterward for the benefit of the developer building the package. Might be worth making this a new CLI command, akin to dash-generate-components, maybe dash-pack? That could also standardize ensuring we remove old builds from dist/, build both tarball and wheel, and print out the correct twine upload command that will publish both builds.

And then we can include this in the component boilerplate so this becomes part of new components by default.