-
Notifications
You must be signed in to change notification settings - Fork 29
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
Update infrastructure to avoid "fat" Candela bundle #503
Conversation
Codecov Report
@@ Coverage Diff @@
## master #503 +/- ##
==========================================
- Coverage 48.43% 47.72% -0.72%
==========================================
Files 40 62 +22
Lines 1627 1645 +18
==========================================
- Hits 788 785 -3
- Misses 839 860 +21
Continue to review full report at Codecov.
|
@jeffbaumes PTAL. I realize there are some major changes in this PR, so if you'd like to schedule a time to look this over together, please let me know. |
Any components wishing to use d3 v4 must make use of the d3 microlibraries instead.
Now, the microlibraries will be used to popular candela.components one-by-one as needed by a particular client application.
This commit also removes unneeded dependencies from the top-level package.json file.
…ropackages into it
This move makes these files exempt from coverage testing.
I was able to get the This template works if you place it as <body>
<script src="dist/candela-all.js" charset="utf-8"></script>
<script>
var candela = window['candela-all'];
console.log(candela);
var el = document.createElement('div')
document.body.appendChild(el);
var data = [];
for (var d = 0; d < 10; d += 1) {
data.push({
a: d,
b: d
});
}
var vis = new candela.components.BarChart(el, {
data: data,
x: 'a',
y: 'b'
});
vis.render();
</script>
</body> |
I think calling it It is really cool that we can just drop an HTML file in the repo root, build the project, and have a working "app" just by serving that file. Do you think we should include an example like that in the repo? Maybe as a one-off in the |
Sure I like that idea - would be great if it worked with the |
@jeffbaumes, take a look at 237f28b (changes I'll open an issue about the HTML example - I think I'd rather just get this PR merged at this point. |
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.
npm run examples
does not work - seems that index.html needs to reference examples.js
instead of ../examples/examples.js
. Also some of the linked examples (treeheatmap for example?) don't seem to work - it reports a missing .js file.
Otherwise this looks good.
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've confirmed that the examples problem was on my end (old build artifacts). There may be lingering doc issues, and we will need to monitor the girder candela plugin build if it tries to update to the version this merge creates, but LGTM
@jeffbaumes thanks for the (unusually painful) review! |
UPDATE: further changes were made on this PR superseding the description below the break.
This PR introduces three ways to incorporate Candela into a client project:
Easy mode. Include one of the built bundles -
candela-all.js
orcandela-all.min.js
in a<script>
tag or a webpack project. These bundles contain everything available in the codebase, bundled together with all dependencies, forming a large but ready-to-go bundle.Medium mode. Candela now partitions the built-in components into "plugins"; each plugin has an
index.js
file exporting the components, and aload.js
file that automatically adds those components tocandela.components
. This method requires using Webpack for the client project, and results in reasonable bundle sizes, only including whatever the plugins you load require. Since the other components come more or less for free once the dependencies for a given plugin are included, this caps the maximum size of your resulting application bundle.Beast mode. You can forgo the plugin loaders by
import
ing orrequire()
ing just the exact files/components you need for your project, again using Webpack. This approach will theoretically give you the smallest bundle size for the portions of Candela you wish to use.TODO:
.npmignore
specs(the following is outdated)
Previously, we were building Candela like an application bundle, which in particular meant bundling all dependencies into the resulting code bundle.
The main change here is to use the
externals
option of Webpack to avoid doing so. Instead, it will now be incumbent on the client to include the correct libraries when using Candela. The final bundle will still be relatively large, but won't include anything that's not being used, and won't include multiple copies of a single library, etc.This PR also builds multiple plugin "sub-bundles" to go along with
candela.js
andcandela.min.js
. Clients can include these directly, or they can reference the source files and use Webpack to build the final application bundle, etc.TODO:
peerDependencies
fields of plugins'package.json
files into documentationfeat
as appropriate.npmignore
update CONTRIBUTING.md and build docs