Skip to content
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

fix(engine): fixes issue #710 - add better error for invalid template #718

Merged
merged 1 commit into from
Oct 8, 2018

Conversation

caridy
Copy link
Contributor

@caridy caridy commented Oct 7, 2018

Details

Follow up PR after PR #693

Does this PR introduce a breaking change?

  • No

@caridy caridy requested a review from diervo October 7, 2018 21:55

export function isTemplateRegistered(tmpl: Template) {
if (!VERIFIED_TEMPLATE_SET.has(tmpl)) {
throw new TypeError('Unknown template');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moving the throwing logic to the invoker of this method to we have access to the vm, and other details of the component to provide better message.

@@ -1,14 +1,14 @@
import { Template } from "./template";

const VERIFIED_TEMPLATE_SET = new Set();
const signedTemplateSet: Set<Template> = new Set();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just renaming and typing

* List of property names that are accessed of the component instance
* from the template.
*/
ids?: string[];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this interface was incompleted, surfaced the issue after adding the proper type to the html argument in validateFields

isTemplateRegistered(html);
// Check that the template was built by the compiler
if (!isTemplateRegistered(html)) {
throw new ReferenceError(`The template rendered by ${vm} must return an imported template tag (e.g.: \`import html from "./${vm.def.name}.html"\`) or undefined, instead, it has returned a function.`);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to add the component stack here since the invocation of this function is inside a try/catch in invoker, that's the one that will add the error details.

@salesforce-best-lwc-internal
Copy link

Benchmark results

Base commit: 9c5cf3f | Target commit: 8e89ef3

lwc-engine-benchmark

table-append-1k metric base(9c5cf3f) target(8e89ef3) trend
benchmark-table/append/1k duration 155.45 (±6.85 ms) 159.70 (±6.15 ms) +4.3ms (2.7%) 👎
table-clear-1k metric base(9c5cf3f) target(8e89ef3) trend
benchmark-table/clear/1k duration 12.10 (±0.70 ms) 12.55 (±0.55 ms) +0.5ms (3.7%) 👎
table-create-10k metric base(9c5cf3f) target(8e89ef3) trend
benchmark-table/create/10k duration 889.95 (±6.45 ms) 883.95 (±5.45 ms) -6.0ms (0.7%) 👍
table-create-1k metric base(9c5cf3f) target(8e89ef3) trend
benchmark-table/create/1k duration 110.60 (±2.40 ms) 112.95 (±2.85 ms) +2.4ms (2.1%) 👎
table-update-10th-1k metric base(9c5cf3f) target(8e89ef3) trend
benchmark-table/update-10th/1k duration 86.95 (±2.10 ms) 98.15 (±6.00 ms) +11.2ms (12.9%) 👎
tablecmp-append-1k metric base(9c5cf3f) target(8e89ef3) trend
benchmark-table-component/append/1k duration 236.55 (±6.70 ms) 234.45 (±6.80 ms) -2.1ms (0.9%) 👍
tablecmp-clear-1k metric base(9c5cf3f) target(8e89ef3) trend
benchmark-table-component/clear/1k duration 20.00 (±2.50 ms) 20.60 (±1.95 ms) +0.6ms (3.0%) 👌
tablecmp-create-10k metric base(9c5cf3f) target(8e89ef3) trend
benchmark-table-component/create/10k duration 1611.50 (±20.95 ms) 1602.40 (±14.60 ms) -9.1ms (0.6%) 👌
tablecmp-create-1k metric base(9c5cf3f) target(8e89ef3) trend
benchmark-table-component/create/1k duration 181.20 (±5.55 ms) 186.30 (±5.45 ms) +5.1ms (2.8%) 👎
tablecmp-update-10th-1k metric base(9c5cf3f) target(8e89ef3) trend
benchmark-table-component/update-10th/1k duration 84.00 (±6.60 ms) 82.85 (±5.85 ms) -1.2ms (1.4%) 👌
wc-append-1k metric base(9c5cf3f) target(8e89ef3) trend
benchmark-table-wc/append/1k duration 265.40 (±14.90 ms) 279.20 (±11.50 ms) +13.8ms (5.2%) 👎
wc-clear-1k metric base(9c5cf3f) target(8e89ef3) trend
benchmark-table-wc/clear/1k duration 28.40 (±2.00 ms) 29.65 (±2.55 ms) +1.3ms (4.4%) 👌
wc-create-10k metric base(9c5cf3f) target(8e89ef3) trend
benchmark-table-wc/create/10k duration 2069.00 (±9.30 ms) 2083.40 (±10.80 ms) +14.4ms (0.7%) 👎
wc-create-1k metric base(9c5cf3f) target(8e89ef3) trend
benchmark-table-wc/create/1k duration 226.25 (±5.00 ms) 225.40 (±6.10 ms) -0.8ms (0.4%) 👌
wc-update-10th-1k metric base(9c5cf3f) target(8e89ef3) trend
benchmark-table-wc/update-10th/1k duration 83.90 (±7.30 ms) 85.20 (±6.45 ms) +1.3ms (1.5%) 👌

@diervo diervo merged commit 7c6009f into master Oct 8, 2018
@diervo diervo deleted the caridy/fix-issue-710 branch October 8, 2018 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants