Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Issue 104 - Add source map to NPM and PyPi packages #105

Merged
merged 4 commits into from
Dec 7, 2018

Conversation

Marc-Andre-Rivet
Copy link
Contributor

@Marc-Andre-Rivet Marc-Andre-Rivet commented Dec 6, 2018

Fixes #104
Relates to plotly/dash#478
Relates to plotly/dash-table#284
Relates to plotly/dash-core-components#404

  • Add source-map to build output
  • Add source-map to npm package
  • Add source-map to PyPi package

include dash_renderer/dash_renderer.dev.js
include dash_renderer/dash_renderer.dev.js.map
include dash_renderer/dash_renderer.min.js
include dash_renderer/dash_renderer.min.js.map
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding map files, reordering

'https://unpkg.com/dash-renderer@{}'
'/dash_renderer/dash_renderer.min.js.map'
).format(__version__),
'namespace': 'dash_renderer'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add maps to Dash

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure it needs an entry here for the map, the _js_dist are files automatically served on the index. I think the js bundle will request the map on it's own.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right that the JS file will request it on its own if the dev tools are opened -- but it will resolve it to its relative path, for example
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or will Dash still allow the request to go through even if it's not defined here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In any case, I'll try it -- I assumed it was necessary :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes dash should allow it, before the map changes in dash I remember seeing 500 errors for map requests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tested it out against the dash-table's examples and if the map is not present here, it doesn't get loaded. Dash probably tells the browser there is no such resource; and the browser continues on with its life?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So it seems this additional entry is required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but the 500 only happens if there is no extension support for map and the map is in the init file

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah your right just looked at the code and we check the if the path is registered so it needs to be in the dist for dash to allow it.

@@ -1 +1 @@
__version__ = '0.15.1'
__version__ = '0.15.2'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bump version

@@ -1,6 +1,6 @@
{
"name": "dash-renderer",
"version": "0.15.0",
"version": "0.15.2",
Copy link
Contributor Author

@Marc-Andre-Rivet Marc-Andre-Rivet Dec 6, 2018

Choose a reason for hiding this comment

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

Bump version.. for some reason this had not been bumped to 0.15.1 for NPM

@@ -31,6 +31,7 @@ module.exports = (env, argv) => {
library: dashLibraryName,
libraryTarget: 'window',
},
devtool: 'source-map',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Source map! This setting is slower but more accurate than other mappings. See here: https://webpack.js.org/configuration/devtool/

Copy link
Contributor

Choose a reason for hiding this comment

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

Need to be sure I don't lose my debugging support with this, I remember the plain source-maps did not work so well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this the in-IDE support you mentioned to me a little while ago?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I'll try it to be sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. If it doesn't work I'll change it to:
mode === 'development' ? 'eval-source-map' : 'source-map'
which will give you the old behavior in dev

Copy link
Contributor

@valentijnnieman valentijnnieman left a comment

Choose a reason for hiding this comment

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

🎉 Love it! Been wanting to get source maps in for a while but never got around to it. Approving it right away but let's make sure @T4rk1n's IDE support doesn't break.

valentijnnieman
valentijnnieman approved these changes Dec 6, 2018
@valentijnnieman
Copy link
Contributor

Got a 500 error the first time I did a review, seems it posted it twice now. Whoops!

@Marc-Andre-Rivet
Copy link
Contributor Author

If anyone wonders, the dev js file is smaller but removing the "eval source map" causes it to take 1 line per code line instead of squishing everything (with evals), explaining the 30k lines diff

@T4rk1n
Copy link
Contributor

T4rk1n commented Dec 6, 2018

Getting a Uncaught SyntaxError: Unexpected token : log with the dev bundle.

@Marc-Andre-Rivet
Copy link
Contributor Author

That's because we're not using the dynamic flag yet. When loaded "correctly" through the devtools this will not happen anymore.

@T4rk1n
Copy link
Contributor

T4rk1n commented Dec 6, 2018

The external code map works for debugging, looked like it was even more stable for dev bundle. The min bundle also debugged but it was jumping over things.

💃

@Marc-Andre-Rivet
Copy link
Contributor Author

The external code map works for debugging, looked like it was even more stable for dev bundle. The min bundle also debugged but it was jumping over things.

Thanks for checking this out. I thought we might be able to get rid of the dev build after the change but if you see improved behavior when debugging with it, let's keep it.

@Marc-Andre-Rivet Marc-Andre-Rivet merged commit 4c324db into master Dec 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants