Skip to content

Commit

Permalink
[WIP] Refactor, change where validation occurs (#1721)
Browse files Browse the repository at this point in the history
Refactor, change where validation occurs
  • Loading branch information
Rich-Harris authored Sep 15, 2018
1 parent b7e07c5 commit 9031c16
Show file tree
Hide file tree
Showing 98 changed files with 2,606 additions and 2,829 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ node_modules
/test/cli/samples/*/actual
/test/sourcemaps/samples/*/output.js
/test/sourcemaps/samples/*/output.js.map
/test/sourcemaps/samples/*/output.css
/test/sourcemaps/samples/*/output.css.map
/src/compile/shared.ts
/store.umd.js
/yarn-error.log
Expand Down
18 changes: 9 additions & 9 deletions src/Stats.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Node, Warning } from './interfaces';
import Compiler from './compile/Compiler';
import Component from './compile/Component';

const now = (typeof process !== 'undefined' && process.hrtime)
? () => {
Expand Down Expand Up @@ -64,7 +64,7 @@ export default class Stats {

stop(label) {
if (label !== this.currentTiming.label) {
throw new Error(`Mismatched timing labels`);
throw new Error(`Mismatched timing labels (expected ${this.currentTiming.label}, got ${label})`);
}

this.currentTiming.end = now();
Expand All @@ -73,14 +73,14 @@ export default class Stats {
this.currentChildren = this.currentTiming ? this.currentTiming.children : this.timings;
}

render(compiler: Compiler) {
render(component: Component) {
const timings = Object.assign({
total: now() - this.startTime
}, collapseTimings(this.timings));

// TODO would be good to have this info even
// if options.generate is false
const imports = compiler && compiler.imports.map(node => {
const imports = component && component.imports.map(node => {
return {
source: node.source.value,
specifiers: node.specifiers.map(specifier => {
Expand All @@ -96,11 +96,11 @@ export default class Stats {
}
});

const hooks: Record<string, boolean> = compiler && {
oncreate: !!compiler.templateProperties.oncreate,
ondestroy: !!compiler.templateProperties.ondestroy,
onstate: !!compiler.templateProperties.onstate,
onupdate: !!compiler.templateProperties.onupdate
const hooks: Record<string, boolean> = component && {
oncreate: !!component.templateProperties.oncreate,
ondestroy: !!component.templateProperties.ondestroy,
onstate: !!component.templateProperties.onstate,
onupdate: !!component.templateProperties.onupdate
};

return {
Expand Down
Loading

0 comments on commit 9031c16

Please sign in to comment.