From 998d86a4e3adaddf8027a5fc56a375ac46d21f45 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 4 Nov 2018 16:32:41 -0500 Subject: [PATCH] expose stats.props --- src/Stats.ts | 3 +++ src/compile/index.ts | 2 +- test/stats/samples/props/_config.js | 5 +++++ test/stats/samples/props/input.html | 23 +++++++++++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 test/stats/samples/props/_config.js create mode 100644 test/stats/samples/props/input.html diff --git a/src/Stats.ts b/src/Stats.ts index b2e16a805c..091975974f 100644 --- a/src/Stats.ts +++ b/src/Stats.ts @@ -103,7 +103,10 @@ export default class Stats { onupdate: !!component.templateProperties.onupdate }; + const computed = new Set(component.computations.map(c => c.key)); + return { + props: Array.from(component.expectedProperties).filter(key => !computed.has(key)), timings, warnings: this.warnings, imports, diff --git a/src/compile/index.ts b/src/compile/index.ts index e5a78379ea..59e204b816 100644 --- a/src/compile/index.ts +++ b/src/compile/index.ts @@ -82,7 +82,7 @@ export default function compile(source: string, options: CompileOptions = {}) { stats.stop('create component'); if (options.generate === false) { - return { ast, stats: stats.render(null), js: null, css: null }; + return { ast, stats: stats.render(component), js: null, css: null }; } if (options.generate === 'ssr') { diff --git a/test/stats/samples/props/_config.js b/test/stats/samples/props/_config.js new file mode 100644 index 0000000000..4ab71fc6e2 --- /dev/null +++ b/test/stats/samples/props/_config.js @@ -0,0 +1,5 @@ +export default { + test(assert, stats) { + assert.deepEqual(stats.props.sort(), ['cats', 'foo', 'name']); + } +}; \ No newline at end of file diff --git a/test/stats/samples/props/input.html b/test/stats/samples/props/input.html new file mode 100644 index 0000000000..e55b85e9ba --- /dev/null +++ b/test/stats/samples/props/input.html @@ -0,0 +1,23 @@ +

Hello {name}!

+ + + +

bar: {bar}

+ + \ No newline at end of file