-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Switch from browserify
to webpack
in order to be able to use most recent ES modules & allow JavaScript syntax beyond ES5
#6355
Conversation
@archmoj this is looking great! My biggest comment so far: can we use |
} | ||
}, | ||
plugins: [ | ||
new NodePolyfillPlugin({ includeAliases: ['process'] }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you figure out what this is needed for? Is it something in our code or in a dependency?
webpack.config.js
Outdated
'stream': require.resolve('stream-browserify'), | ||
'buffer': require.resolve('buffer/'), | ||
'assert': require.resolve('assert/') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These too - where are these needed? (It's OK if they are needed, I'm mostly just curious, also relevant for anyone who might include plotly.js from source, not dist bundles)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. assert
and buffer
are no longer needed. Addressed in 9fc5987.
|
This reverts commit 834d411.
watch: !argv.nowatch, | ||
debug: true | ||
webpack: { | ||
target: ['web', 'es5'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered targeting es6? https://betterprogramming.pub/do-we-still-need-to-compile-es6-javascript-code-into-es5-in-2022-f5ec70509e9b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still want to continuing support es5 syntax in our output.
But now the input syntax i.e. plotly.js source files as well as node_modules
could be in es6 and further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@archmoj FWIW we just dropped IE support in Dash - and we did it in a minor https://github.com/plotly/dash/releases/tag/v2.7.0
I'd be comfortable doing the same in plotly.js, but open to discussing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened #6366.
Let's investigate it & decide on that separately.
- but I keep it during release process
The main part of config is reused now. |
var makeWatchifiedBundle = require('../../tasks/util/watchified_bundle'); | ||
var shortcutPaths = require('../../tasks/util/shortcut_paths'); | ||
var config = require('../../webpack.config.js'); | ||
config.optimization = { minimize: false }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally even the test build would be minified, to give us further confidence we're testing the behavior of the real bundle, plus a sourcemap. Right now with no sourcemap all I see in the test dashboard is the single huge unminified bundle - all the code is there unmodified but it'd be a pain to connect it back to the source files during debugging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The debugging is addressed in 458921f.
Now using development mode
, the bundle content is different from production mode; but it builds & rebuilds faster.
This should be good for now. And we could further improve this configuration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That'll work - what you see in the debugger isn't quite the same as the source files - it's been reformatted a bit and the require statements are transformed - but it's pretty close and easy to move from one to another 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💃 Let's do it!
@plotly/plotly_js
TODOs:
regl_codegen/devtools.js
similar totest_dashboard/devtools.js
.glslify
transform for regl based tracesstackgl_modules
using webpackstrict_d3.js
? Possibly no!watchified_bundle.js
.scattergl
test failures inwebgl-jasmine
container.LICENSE.txt
filescompress_attributes
transform when when creating bundles other thanplotly-with-meta.js
plotly-with-meta.js