merge master -> tanhauhau/debugging-with-no-dependencies

pull/3723/head
Richard Harris 5 years ago
commit 456f5372e6

@ -56,8 +56,6 @@ export default class DebugTagWrapper extends Wrapper {
add_to_set(dependencies, expression.dependencies); add_to_set(dependencies, expression.dependencies);
}); });
const condition = changed(Array.from(dependencies));
const contextual_identifiers = this.node.expressions const contextual_identifiers = this.node.expressions
.filter(e => { .filter(e => {
const variable = var_lookup.get(e.node.name); const variable = var_lookup.get(e.node.name);
@ -67,21 +65,24 @@ export default class DebugTagWrapper extends Wrapper {
const logged_identifiers = this.node.expressions.map(e => p`${e.node.name}`); const logged_identifiers = this.node.expressions.map(e => p`${e.node.name}`);
block.chunks.update.push(b` const debug_statements = b`
if (${condition}) { const { ${contextual_identifiers} } = #ctx;
const { ${contextual_identifiers} } = #ctx; @_console.${log}({ ${logged_identifiers} });
@_console.${log}({ ${logged_identifiers} }); debugger;`;
${debug};
} if (dependencies.size) {
`); const condition = changed(Array.from(dependencies));
block.chunks.create.push(b` block.chunks.update.push(b`
{ if (${condition}) {
const { ${contextual_identifiers} } = #ctx; ${debug_statements}
@_console.${log}({ ${logged_identifiers} }); }
${debug}; `);
} }
`);
block.chunks.create.push(b`{
${debug_statements}
}`);
} }
} }
} }

@ -0,0 +1,5 @@
export default {
options: {
dev: true
}
};

@ -0,0 +1,145 @@
import {
SvelteComponentDev,
destroy_each,
detach_dev,
dispatch_dev,
empty,
init,
insert_dev,
noop,
safe_not_equal,
space,
text
} from "svelte/internal";
const file = undefined;
function get_each_context(ctx, list, i) {
const child_ctx = Object.create(ctx);
child_ctx.thing = list[i];
child_ctx.index = i;
return child_ctx;
}
function create_each_block(ctx) {
let t0;
let t1_value = ctx.thing + "";
let t1;
const block = {
c: function create() {
{
const { index } = ctx;
console.log({ index });
debugger;
}
t0 = space();
t1 = text(t1_value);
},
m: function mount(target, anchor) {
insert_dev(target, t0, anchor);
insert_dev(target, t1, anchor);
},
p: noop},
d: function destroy(detaching) {
if (detaching) detach_dev(t0);
if (detaching) detach_dev(t1);
}
};
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_each_block.name,
type: "each",
source: "(4:0) {#each things as thing, index}",
ctx
});
return block;
}
function create_fragment(ctx) {
let each_anchor;
let each_value = things;
let each_blocks = [];
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
}
const block = {
c: function create() {
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
each_anchor = empty();
},
l: function claim(nodes) {
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
},
m: function mount(target, anchor) {
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(target, anchor);
}
insert_dev(target, each_anchor, anchor);
},
p: function update(changed, ctx) {
if (changed.things) {
each_value = things;
let i;
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context(ctx, each_value, i);
if (each_blocks[i]) {
each_blocks[i].p(changed, child_ctx);
} else {
each_blocks[i] = create_each_block(child_ctx);
each_blocks[i].c();
each_blocks[i].m(each_anchor.parentNode, each_anchor);
}
}
for (; i < each_blocks.length; i += 1) {
each_blocks[i].d(1);
}
each_blocks.length = each_value.length;
}
},
i: noop,
o: noop,
d: function destroy(detaching) {
destroy_each(each_blocks, detaching);
if (detaching) detach_dev(each_anchor);
}
};
dispatch_dev("SvelteRegisterBlock", {
block,
id: create_fragment.name,
type: "component",
source: "",
ctx
});
return block;
}
class Component extends SvelteComponentDev {
constructor(options) {
super(options);
init(this, options, null, create_fragment, safe_not_equal, []);
dispatch_dev("SvelteRegisterComponent", {
component: this,
tagName: "Component",
options,
id: create_fragment.name
});
}
}
export default Component;

@ -0,0 +1,7 @@
<script>
</script>
{#each things as thing, index}
{@debug index}
{thing}
{/each}
Loading…
Cancel
Save