Skip to content

Commit

Permalink
More accurate fix for #69
Browse files Browse the repository at this point in the history
  • Loading branch information
btd committed Apr 8, 2020
1 parent 2d3f732 commit 623226b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
19 changes: 11 additions & 8 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ const runBuildTest_e2e = async (template = "treemap") => {
await bundle.write(outputOptions);
};

const runBuildTest_gh59 = async () => {
const runBuildTest_gh59 = async (template) => {
const input = {
index: "test/gh59/src/index",
"components/index": "test/gh59/src/components/index",
Expand All @@ -181,7 +181,7 @@ const runBuildTest_gh59 = async () => {
require("./")({
title: "test gh59",
filename: `stats.gh59${fileExt}`,
template: "treemap",
template,
...simpleOptions,
}),
],
Expand All @@ -198,7 +198,7 @@ const runBuildTest_gh59 = async () => {
await bundle.write(outputOptions);
};

const runBuildTest_gh69 = async () => {
const runBuildTest_gh69 = async (template) => {
const input = "test/gh69/main.js";

const inputOptions = {
Expand All @@ -207,7 +207,7 @@ const runBuildTest_gh69 = async () => {
require("./")({
title: "test gh69",
filename: `stats.gh69${fileExt}`,
template: "treemap",
template,
...simpleOptions,
}),
],
Expand All @@ -224,17 +224,20 @@ const runBuildTest_gh69 = async () => {
await bundle.write(outputOptions);
};

const buildAll = (action) =>
Promise.all(templatesToBuild.map((t) => action(t)));

const run = async () => {
await Promise.all(TEMPLATE.map((t) => runBuild(t)));
if (argv.dev) {
await Promise.all(templatesToBuild.map((t) => runBuildDev(t)));
await buildAll(runBuildDev);
}
if (argv.e2e) {
await Promise.all(templatesToBuild.map((t) => runBuildTest_e2e(t)));
await buildAll(runBuildTest_e2e);
}
if (argv.test) {
await runBuildTest_gh59();
await runBuildTest_gh69();
await buildAll(runBuildTest_gh59);
await buildAll(runBuildTest_gh69);
}
};

Expand Down
1 change: 0 additions & 1 deletion plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ module.exports = function (opts) {
tree = buildTree(id, Object.entries(modules), mapper);
} else {
const modules = Object.entries(bundle.modules);
if (modules.length === 0) continue; //TODO this is not exactly right

tree = buildTree(id, modules, mapper);
}
Expand Down
6 changes: 3 additions & 3 deletions src/script-sunburst.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ const Main = ({ width, height, data: { tree, nodes, options = {} } }) => {
for (const prop of availableSizeProperties) {
value[prop] = 0;
}
const children = node.children;
if (children != null) {
let i = children.length;
if (node.data.children != null) {
const children = node.children;
let i = node.data.children.length;
while (--i >= 0) {
for (const prop of availableSizeProperties) {
value[prop] += children[i].originalValue[prop];
Expand Down
10 changes: 7 additions & 3 deletions src/script-treemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,13 @@ const Main = ({
for (const prop of availableSizeProperties) {
value[prop] = 0;
}
const children = node.children;
if (children != null) {
let i = children.length;

// use node.data.children because if it is empty d3 will skip this node
// and it will look like it is actually a leaf - which technically it is but not exactly
// it is just a chunk without deps - usually just with imports
if (node.data.children != null) {
const children = node.children;
let i = node.data.children.length;
while (--i >= 0) {
for (const prop of availableSizeProperties) {
value[prop] += children[i].originalValue[prop];
Expand Down

0 comments on commit 623226b

Please sign in to comment.