Skip to content

Commit 9031c16

Browse files
authored
[WIP] Refactor, change where validation occurs (sveltejs#1721)
Refactor, change where validation occurs
1 parent b7e07c5 commit 9031c16

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+2606
-2829
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ node_modules
1111
/test/cli/samples/*/actual
1212
/test/sourcemaps/samples/*/output.js
1313
/test/sourcemaps/samples/*/output.js.map
14+
/test/sourcemaps/samples/*/output.css
15+
/test/sourcemaps/samples/*/output.css.map
1416
/src/compile/shared.ts
1517
/store.umd.js
1618
/yarn-error.log

src/Stats.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Node, Warning } from './interfaces';
2-
import Compiler from './compile/Compiler';
2+
import Component from './compile/Component';
33

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

6565
stop(label) {
6666
if (label !== this.currentTiming.label) {
67-
throw new Error(`Mismatched timing labels`);
67+
throw new Error(`Mismatched timing labels (expected ${this.currentTiming.label}, got ${label})`);
6868
}
6969

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

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

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

99-
const hooks: Record<string, boolean> = compiler && {
100-
oncreate: !!compiler.templateProperties.oncreate,
101-
ondestroy: !!compiler.templateProperties.ondestroy,
102-
onstate: !!compiler.templateProperties.onstate,
103-
onupdate: !!compiler.templateProperties.onupdate
99+
const hooks: Record<string, boolean> = component && {
100+
oncreate: !!component.templateProperties.oncreate,
101+
ondestroy: !!component.templateProperties.ondestroy,
102+
onstate: !!component.templateProperties.onstate,
103+
onupdate: !!component.templateProperties.onupdate
104104
};
105105

106106
return {

0 commit comments

Comments
 (0)