-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Module Registry #157
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
Comments
@mdtusz Looks like you got all the cases covered in that gist. A few comments (related to #41 (comment)):
|
Could you elaborate what you mean on the last bullet point? My thought was that we would have an index file that "builds" a standard version available via |
Correct and the location of this "dist" file is given by the
That'd be great. But, how do we tell the bundlers where |
A similar type of file could be created for the traces if we want to clean up the interface so that users can write things like e.g. // plotly.js/index.js
var Core = require('./core');
var Traces = require('./traces');
for(trace in Traces){
Core.register({ trace: Traces[trace] });
}
// despite the name Core, this would be all of Plotly
module.exports = Core; // plotly.js/core.js
var Core = {};
// add everything as needed
module.exports = Core; // plotly.js/traces.js
var Traces = {
scatter: require('./src/traces/scatter'),
box: require('./src/traces/box')
// etc.
}
module.exports = Traces; |
Right. That's what I wanted to discuss. Adding this core would require an extra build step. We'll have to choose the best way to do so. Moreover, will these component (e.g. Personally, I'd vote for checking them into git, so that users can look at their content in github. Having all these component files into a separate directory makes more sense to me than polluting the root level. For example, putting them into a That said I have no strong opinion about it. We should maybe look into what other packages are doing. |
It shouldn't require more of a build step - it will just bundle the code as usual because Browserify will resolve the We should definitely check the files into the repo though. I'd like to try to keep a clean/minimal path for end users if possible which is why I suggested var Core = require('plotly.js/core');
var Traces = require('plotly.js/core/traces'); and using the |
Browserify will do it right. But webpack and the gl modules don't get along (mainly because of |
👍 agreed. |
Hmm. I forgot about webpack. It should be possible using glslify-loader but we'd need to test it out. Otherwise you're right and we'd need to add an incremental build step to browserify the traces/components/core. |
Moreover, we should get rid of gd._modules entirely and rely only on the registry(ies) |
Just to be clear on what |
@alexcjohnson right, good point. Thanks. |
Implemented with #180 |
// in custom-plotly.js
var Plotly = require('plotly.js/lib/core');
// Load in the trace types for pie, and scatter3d
Plotly.register([
require('plotly.js/lib/pie'),
require('plotly.js/lib/scatter3d')
]);
module.exports = Plotly; Unable to pick partial module scatter3d with webpack2. |
Have you read https://github.com/plotly/plotly.js/blob/master/README.md#webpack-usage-with-modules If so, can you paste your webpack config and the error message you're seeing? |
In webpack.config { test: /node_modules/, loader: 'ify-loader'},
{ test: /\.json$/, loader: 'json-loader'}, After adding json-loader, the issue is resolved. But why is |
Really,
If so, that would be a major bug, but I'm not able to replicate it. |
The |
@alexcjohnson @etpinard @cldougl
Implementing a registry will be a big help for modularity and reducing the bundle size for people using only a few traces. The question is, how do we want to implement it.
This is one of the ways I have thought about how we could do it, but it would be good to see what you all have in mind as well.
The text was updated successfully, but these errors were encountered: