From b2f371a3d1f5fb3ab47bda93ae9c3e4046cad917 Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Mon, 18 Feb 2019 14:19:53 -0500 Subject: [PATCH] move vars out of stats --- src/Stats.ts | 34 +--- src/compile/Component.ts | 161 ++++++++++-------- src/compile/index.ts | 12 +- .../samples/duplicate-globals/_config.js | 5 - test/stats/samples/implicit-action/_config.js | 5 - test/stats/samples/implicit/_config.js | 5 - .../samples/template-references/_config.js | 5 - test/stats/samples/undeclared/_config.js | 5 - test/vars/index.js | 60 +++++++ .../vars/samples/duplicate-globals/_config.js | 5 + .../samples/duplicate-globals/input.svelte | 0 .../duplicate-non-hoistable/_config.js | 4 +- .../duplicate-non-hoistable/input.svelte | 0 .../samples/duplicate-vars/_config.js | 4 +- .../samples/duplicate-vars/input.svelte | 0 test/vars/samples/implicit-action/_config.js | 5 + .../samples/implicit-action/input.svelte | 0 .../samples/implicit-reactive/_config.js | 4 +- .../samples/implicit-reactive/input.svelte | 0 test/vars/samples/implicit/_config.js | 5 + .../samples/implicit/input.svelte | 0 .../samples/imports/_config.js | 4 +- .../samples/imports/input.svelte | 0 .../_config.js | 4 +- .../input.svelte | 0 .../samples/mutated-vs-reassigned}/_config.js | 4 +- .../mutated-vs-reassigned/input.svelte | 0 test/{stats => vars}/samples/props/_config.js | 4 +- .../samples/props/input.svelte | 0 .../samples/store-referenced/_config.js | 4 +- .../samples/store-referenced/input.svelte | 0 .../samples/store-unreferenced/_config.js | 4 +- .../samples/store-unreferenced/input.svelte | 0 .../samples/template-references/_config.js | 5 + .../samples/template-references/input.svelte | 0 test/vars/samples/undeclared/_config.js | 5 + .../samples/undeclared/input.svelte | 0 37 files changed, 198 insertions(+), 155 deletions(-) delete mode 100644 test/stats/samples/duplicate-globals/_config.js delete mode 100644 test/stats/samples/implicit-action/_config.js delete mode 100644 test/stats/samples/implicit/_config.js delete mode 100644 test/stats/samples/template-references/_config.js delete mode 100644 test/stats/samples/undeclared/_config.js create mode 100644 test/vars/index.js create mode 100644 test/vars/samples/duplicate-globals/_config.js rename test/{stats => vars}/samples/duplicate-globals/input.svelte (100%) rename test/{stats => vars}/samples/duplicate-non-hoistable/_config.js (78%) rename test/{stats => vars}/samples/duplicate-non-hoistable/input.svelte (100%) rename test/{stats => vars}/samples/duplicate-vars/_config.js (87%) rename test/{stats => vars}/samples/duplicate-vars/input.svelte (100%) create mode 100644 test/vars/samples/implicit-action/_config.js rename test/{stats => vars}/samples/implicit-action/input.svelte (100%) rename test/{stats => vars}/samples/implicit-reactive/_config.js (86%) rename test/{stats => vars}/samples/implicit-reactive/input.svelte (100%) create mode 100644 test/vars/samples/implicit/_config.js rename test/{stats => vars}/samples/implicit/input.svelte (100%) rename test/{stats => vars}/samples/imports/_config.js (90%) rename test/{stats => vars}/samples/imports/input.svelte (100%) rename test/{stats/samples/mutated-vs-reassigned => vars/samples/mutated-vs-reassigned-bindings}/_config.js (86%) rename test/{stats => vars}/samples/mutated-vs-reassigned-bindings/input.svelte (100%) rename test/{stats/samples/mutated-vs-reassigned-bindings => vars/samples/mutated-vs-reassigned}/_config.js (86%) rename test/{stats => vars}/samples/mutated-vs-reassigned/input.svelte (100%) rename test/{stats => vars}/samples/props/_config.js (92%) rename test/{stats => vars}/samples/props/input.svelte (100%) rename test/{stats => vars}/samples/store-referenced/_config.js (87%) rename test/{stats => vars}/samples/store-referenced/input.svelte (100%) rename test/{stats => vars}/samples/store-unreferenced/_config.js (87%) rename test/{stats => vars}/samples/store-unreferenced/input.svelte (100%) create mode 100644 test/vars/samples/template-references/_config.js rename test/{stats => vars}/samples/template-references/input.svelte (100%) create mode 100644 test/vars/samples/undeclared/_config.js rename test/{stats => vars}/samples/undeclared/input.svelte (100%) diff --git a/src/Stats.ts b/src/Stats.ts index dd721c7e81..87c6c2173a 100644 --- a/src/Stats.ts +++ b/src/Stats.ts @@ -1,5 +1,3 @@ -import Component from './compile/Component'; - const now = (typeof process !== 'undefined' && process.hrtime) ? () => { const t = process.hrtime(); @@ -63,41 +61,13 @@ export default class Stats { this.currentChildren = this.currentTiming ? this.currentTiming.children : this.timings; } - render(component: Component) { + render() { 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 = component && component.imports.map(node => { - return { - source: node.source.value, - specifiers: node.specifiers.map(specifier => { - return { - name: ( - specifier.type === 'ImportDefaultSpecifier' ? 'default' : - specifier.type === 'ImportNamespaceSpecifier' ? '*' : - specifier.imported.name - ), - as: specifier.local.name - }; - }) - } - }); - return { - timings, - vars: component.vars.filter(variable => !variable.global && !variable.implicit && !variable.internal).map(variable => ({ - name: variable.name, - export_name: variable.export_name || null, - injected: variable.injected || false, - module: variable.module || false, - mutated: variable.mutated || false, - reassigned: variable.reassigned || false, - referenced: variable.referenced || false, - writable: variable.writable || false - })) + timings }; } } diff --git a/src/compile/Component.ts b/src/compile/Component.ts index 4ff1eff92d..0a718966a2 100644 --- a/src/compile/Component.ts +++ b/src/compile/Component.ts @@ -217,106 +217,121 @@ export default class Component { } generate(result: string) { - const { compileOptions, name } = this; - const { format = 'esm' } = compileOptions; + let js = null; + let css = null; - const banner = `/* ${this.file ? `${this.file} ` : ``}generated by Svelte v${"__VERSION__"} */`; + if (result) { + const { compileOptions, name } = this; + const { format = 'esm' } = compileOptions; - // TODO use same regex for both - result = result.replace(compileOptions.generate === 'ssr' ? /(@+|#+)(\w*(?:-\w*)?)/g : /(@+)(\w*(?:-\w*)?)/g, (match: string, sigil: string, name: string) => { - if (sigil === '@') { - if (internal_exports.has(name)) { - if (compileOptions.dev && internal_exports.has(`${name}Dev`)) name = `${name}Dev`; - this.helpers.add(name); - } + const banner = `/* ${this.file ? `${this.file} ` : ``}generated by Svelte v${"__VERSION__"} */`; - return this.alias(name); - } + // TODO use same regex for both + result = result.replace(compileOptions.generate === 'ssr' ? /(@+|#+)(\w*(?:-\w*)?)/g : /(@+)(\w*(?:-\w*)?)/g, (match: string, sigil: string, name: string) => { + if (sigil === '@') { + if (internal_exports.has(name)) { + if (compileOptions.dev && internal_exports.has(`${name}Dev`)) name = `${name}Dev`; + this.helpers.add(name); + } - return sigil.slice(1) + name; - }); + return this.alias(name); + } - const importedHelpers = Array.from(this.helpers) - .sort() - .map(name => { - const alias = this.alias(name); - return { name, alias }; + return sigil.slice(1) + name; }); - const module = wrapModule( - result, - format, - name, - compileOptions, - banner, - compileOptions.sveltePath, - importedHelpers, - this.imports, - this.vars.filter(variable => variable.module && variable.export_name).map(variable => ({ - name: variable.name, - as: variable.export_name - })), - this.source - ); + const importedHelpers = Array.from(this.helpers) + .sort() + .map(name => { + const alias = this.alias(name); + return { name, alias }; + }); - const parts = module.split('✂]'); - const finalChunk = parts.pop(); + const module = wrapModule( + result, + format, + name, + compileOptions, + banner, + compileOptions.sveltePath, + importedHelpers, + this.imports, + this.vars.filter(variable => variable.module && variable.export_name).map(variable => ({ + name: variable.name, + as: variable.export_name + })), + this.source + ); - const compiled = new Bundle({ separator: '' }); + const parts = module.split('✂]'); + const finalChunk = parts.pop(); - function addString(str: string) { - compiled.addSource({ - content: new MagicString(str), - }); - } + const compiled = new Bundle({ separator: '' }); - const { filename } = compileOptions; + function addString(str: string) { + compiled.addSource({ + content: new MagicString(str), + }); + } - // special case — the source file doesn't actually get used anywhere. we need - // to add an empty file to populate map.sources and map.sourcesContent - if (!parts.length) { - compiled.addSource({ - filename, - content: new MagicString(this.source).remove(0, this.source.length), - }); - } + const { filename } = compileOptions; + + // special case — the source file doesn't actually get used anywhere. we need + // to add an empty file to populate map.sources and map.sourcesContent + if (!parts.length) { + compiled.addSource({ + filename, + content: new MagicString(this.source).remove(0, this.source.length), + }); + } - const pattern = /\[✂(\d+)-(\d+)$/; + const pattern = /\[✂(\d+)-(\d+)$/; - parts.forEach((str: string) => { - const chunk = str.replace(pattern, ''); - if (chunk) addString(chunk); + parts.forEach((str: string) => { + const chunk = str.replace(pattern, ''); + if (chunk) addString(chunk); - const match = pattern.exec(str); + const match = pattern.exec(str); - const snippet = this.code.snip(+match[1], +match[2]); + const snippet = this.code.snip(+match[1], +match[2]); - compiled.addSource({ - filename, - content: snippet, + compiled.addSource({ + filename, + content: snippet, + }); }); - }); - addString(finalChunk); + addString(finalChunk); - const css = compileOptions.customElement ? - { code: null, map: null } : - this.stylesheet.render(compileOptions.cssOutputFilename, true); + css = compileOptions.customElement ? + { code: null, map: null } : + this.stylesheet.render(compileOptions.cssOutputFilename, true); - const js = { - code: compiled.toString(), - map: compiled.generateMap({ - includeContent: true, - file: compileOptions.outputFilename, - }) - }; + js = { + code: compiled.toString(), + map: compiled.generateMap({ + includeContent: true, + file: compileOptions.outputFilename, + }) + }; + } return { js, css, ast: this.ast, warnings: this.warnings, - stats: this.stats.render(this) + vars: this.vars.filter(v => !v.global && !v.implicit && !v.internal).map(v => ({ + name: v.name, + export_name: v.export_name || null, + injected: v.injected || false, + module: v.module || false, + mutated: v.mutated || false, + reassigned: v.reassigned || false, + referenced: v.referenced || false, + writable: v.writable || false + })), + stats: this.stats.render() }; } diff --git a/src/compile/index.ts b/src/compile/index.ts index 2efbaf53a2..704d5bd706 100644 --- a/src/compile/index.ts +++ b/src/compile/index.ts @@ -95,13 +95,11 @@ export default function compile(source: string, options: CompileOptions = {}) { ); stats.stop('create component'); - if (options.generate === false) { - return { ast, warnings, stats: stats.render(component), js: null, css: null }; - } - - const js = options.generate === 'ssr' - ? renderSSR(component, options) - : renderDOM(component, options); + const js = options.generate === false + ? null + : options.generate === 'ssr' + ? renderSSR(component, options) + : renderDOM(component, options); return component.generate(js); } \ No newline at end of file diff --git a/test/stats/samples/duplicate-globals/_config.js b/test/stats/samples/duplicate-globals/_config.js deleted file mode 100644 index 71c255d54b..0000000000 --- a/test/stats/samples/duplicate-globals/_config.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - test(assert, stats) { - assert.deepEqual(stats.vars, []); - }, -}; diff --git a/test/stats/samples/implicit-action/_config.js b/test/stats/samples/implicit-action/_config.js deleted file mode 100644 index 71c255d54b..0000000000 --- a/test/stats/samples/implicit-action/_config.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - test(assert, stats) { - assert.deepEqual(stats.vars, []); - }, -}; diff --git a/test/stats/samples/implicit/_config.js b/test/stats/samples/implicit/_config.js deleted file mode 100644 index 71c255d54b..0000000000 --- a/test/stats/samples/implicit/_config.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - test(assert, stats) { - assert.deepEqual(stats.vars, []); - }, -}; diff --git a/test/stats/samples/template-references/_config.js b/test/stats/samples/template-references/_config.js deleted file mode 100644 index 71c255d54b..0000000000 --- a/test/stats/samples/template-references/_config.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - test(assert, stats) { - assert.deepEqual(stats.vars, []); - }, -}; diff --git a/test/stats/samples/undeclared/_config.js b/test/stats/samples/undeclared/_config.js deleted file mode 100644 index 71c255d54b..0000000000 --- a/test/stats/samples/undeclared/_config.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - test(assert, stats) { - assert.deepEqual(stats.vars, []); - }, -}; diff --git a/test/vars/index.js b/test/vars/index.js new file mode 100644 index 0000000000..d8da8e4778 --- /dev/null +++ b/test/vars/index.js @@ -0,0 +1,60 @@ +import * as fs from 'fs'; +import * as assert from 'assert'; +import { svelte, loadConfig, tryToLoadJson } from '../helpers.js'; + +describe('vars', () => { + fs.readdirSync('test/vars/samples').forEach(dir => { + if (dir[0] === '.') return; + + // add .solo to a sample directory name to only run that test + const solo = /\.solo/.test(dir); + const skip = /\.skip/.test(dir); + + if (solo && process.env.CI) { + throw new Error('Forgot to remove `solo: true` from test'); + } + + (solo ? it.only : skip ? it.skip : it)(dir, () => { + const config = loadConfig(`./vars/samples/${dir}/_config.js`); + const filename = `test/vars/samples/${dir}/input.svelte`; + const input = fs.readFileSync(filename, 'utf-8').replace(/\s+$/, ''); + + const expectedError = tryToLoadJson( + `test/vars/samples/${dir}/error.json` + ); + + let result; + let error; + + try { + result = svelte.compile(input, config.options); + config.test(assert, result.vars); + } catch (e) { + error = e; + } + + if (error || expectedError) { + if (error && !expectedError) { + throw error; + } + + if (expectedError && !error) { + throw new Error(`Expected an error: ${expectedError.message}`); + } + + assert.equal(error.message, expectedError.message); + assert.deepEqual(error.start, expectedError.start); + assert.deepEqual(error.end, expectedError.end); + assert.equal(error.pos, expectedError.pos); + } + }); + }); + + it('returns a vars object when options.generate is false', () => { + const { vars } = svelte.compile('', { + generate: false + }); + + assert.ok(Array.isArray(vars)); + }); +}); diff --git a/test/vars/samples/duplicate-globals/_config.js b/test/vars/samples/duplicate-globals/_config.js new file mode 100644 index 0000000000..2b84e83f12 --- /dev/null +++ b/test/vars/samples/duplicate-globals/_config.js @@ -0,0 +1,5 @@ +export default { + test(assert, vars) { + assert.deepEqual(vars, []); + }, +}; diff --git a/test/stats/samples/duplicate-globals/input.svelte b/test/vars/samples/duplicate-globals/input.svelte similarity index 100% rename from test/stats/samples/duplicate-globals/input.svelte rename to test/vars/samples/duplicate-globals/input.svelte diff --git a/test/stats/samples/duplicate-non-hoistable/_config.js b/test/vars/samples/duplicate-non-hoistable/_config.js similarity index 78% rename from test/stats/samples/duplicate-non-hoistable/_config.js rename to test/vars/samples/duplicate-non-hoistable/_config.js index 4b598412a9..bb7f52d4db 100644 --- a/test/stats/samples/duplicate-non-hoistable/_config.js +++ b/test/vars/samples/duplicate-non-hoistable/_config.js @@ -1,6 +1,6 @@ export default { - test(assert, stats) { - assert.deepEqual(stats.vars, [ + test(assert, vars) { + assert.deepEqual(vars, [ { name: 'console', injected: false, diff --git a/test/stats/samples/duplicate-non-hoistable/input.svelte b/test/vars/samples/duplicate-non-hoistable/input.svelte similarity index 100% rename from test/stats/samples/duplicate-non-hoistable/input.svelte rename to test/vars/samples/duplicate-non-hoistable/input.svelte diff --git a/test/stats/samples/duplicate-vars/_config.js b/test/vars/samples/duplicate-vars/_config.js similarity index 87% rename from test/stats/samples/duplicate-vars/_config.js rename to test/vars/samples/duplicate-vars/_config.js index f4f71fe021..276ae130a1 100644 --- a/test/stats/samples/duplicate-vars/_config.js +++ b/test/vars/samples/duplicate-vars/_config.js @@ -1,6 +1,6 @@ export default { - test(assert, stats) { - assert.deepEqual(stats.vars, [ + test(assert, vars) { + assert.deepEqual(vars, [ { name: 'foo', injected: false, diff --git a/test/stats/samples/duplicate-vars/input.svelte b/test/vars/samples/duplicate-vars/input.svelte similarity index 100% rename from test/stats/samples/duplicate-vars/input.svelte rename to test/vars/samples/duplicate-vars/input.svelte diff --git a/test/vars/samples/implicit-action/_config.js b/test/vars/samples/implicit-action/_config.js new file mode 100644 index 0000000000..2b84e83f12 --- /dev/null +++ b/test/vars/samples/implicit-action/_config.js @@ -0,0 +1,5 @@ +export default { + test(assert, vars) { + assert.deepEqual(vars, []); + }, +}; diff --git a/test/stats/samples/implicit-action/input.svelte b/test/vars/samples/implicit-action/input.svelte similarity index 100% rename from test/stats/samples/implicit-action/input.svelte rename to test/vars/samples/implicit-action/input.svelte diff --git a/test/stats/samples/implicit-reactive/_config.js b/test/vars/samples/implicit-reactive/_config.js similarity index 86% rename from test/stats/samples/implicit-reactive/_config.js rename to test/vars/samples/implicit-reactive/_config.js index 0137632d2c..fd67e8b249 100644 --- a/test/stats/samples/implicit-reactive/_config.js +++ b/test/vars/samples/implicit-reactive/_config.js @@ -1,6 +1,6 @@ export default { - test(assert, stats) { - assert.deepEqual(stats.vars, [ + test(assert, vars) { + assert.deepEqual(vars, [ { name: 'a', injected: false, diff --git a/test/stats/samples/implicit-reactive/input.svelte b/test/vars/samples/implicit-reactive/input.svelte similarity index 100% rename from test/stats/samples/implicit-reactive/input.svelte rename to test/vars/samples/implicit-reactive/input.svelte diff --git a/test/vars/samples/implicit/_config.js b/test/vars/samples/implicit/_config.js new file mode 100644 index 0000000000..2b84e83f12 --- /dev/null +++ b/test/vars/samples/implicit/_config.js @@ -0,0 +1,5 @@ +export default { + test(assert, vars) { + assert.deepEqual(vars, []); + }, +}; diff --git a/test/stats/samples/implicit/input.svelte b/test/vars/samples/implicit/input.svelte similarity index 100% rename from test/stats/samples/implicit/input.svelte rename to test/vars/samples/implicit/input.svelte diff --git a/test/stats/samples/imports/_config.js b/test/vars/samples/imports/_config.js similarity index 90% rename from test/stats/samples/imports/_config.js rename to test/vars/samples/imports/_config.js index 287c5837ad..90f2468b54 100644 --- a/test/stats/samples/imports/_config.js +++ b/test/vars/samples/imports/_config.js @@ -1,6 +1,6 @@ export default { - test(assert, stats) { - assert.deepEqual(stats.vars, [ + test(assert, vars) { + assert.deepEqual(vars, [ { name: 'x', export_name: null, diff --git a/test/stats/samples/imports/input.svelte b/test/vars/samples/imports/input.svelte similarity index 100% rename from test/stats/samples/imports/input.svelte rename to test/vars/samples/imports/input.svelte diff --git a/test/stats/samples/mutated-vs-reassigned/_config.js b/test/vars/samples/mutated-vs-reassigned-bindings/_config.js similarity index 86% rename from test/stats/samples/mutated-vs-reassigned/_config.js rename to test/vars/samples/mutated-vs-reassigned-bindings/_config.js index a1d027cbb5..21fc14d820 100644 --- a/test/stats/samples/mutated-vs-reassigned/_config.js +++ b/test/vars/samples/mutated-vs-reassigned-bindings/_config.js @@ -1,6 +1,6 @@ export default { - test(assert, stats) { - assert.deepEqual(stats.vars, [ + test(assert, vars) { + assert.deepEqual(vars, [ { name: 'count', export_name: null, diff --git a/test/stats/samples/mutated-vs-reassigned-bindings/input.svelte b/test/vars/samples/mutated-vs-reassigned-bindings/input.svelte similarity index 100% rename from test/stats/samples/mutated-vs-reassigned-bindings/input.svelte rename to test/vars/samples/mutated-vs-reassigned-bindings/input.svelte diff --git a/test/stats/samples/mutated-vs-reassigned-bindings/_config.js b/test/vars/samples/mutated-vs-reassigned/_config.js similarity index 86% rename from test/stats/samples/mutated-vs-reassigned-bindings/_config.js rename to test/vars/samples/mutated-vs-reassigned/_config.js index a1d027cbb5..21fc14d820 100644 --- a/test/stats/samples/mutated-vs-reassigned-bindings/_config.js +++ b/test/vars/samples/mutated-vs-reassigned/_config.js @@ -1,6 +1,6 @@ export default { - test(assert, stats) { - assert.deepEqual(stats.vars, [ + test(assert, vars) { + assert.deepEqual(vars, [ { name: 'count', export_name: null, diff --git a/test/stats/samples/mutated-vs-reassigned/input.svelte b/test/vars/samples/mutated-vs-reassigned/input.svelte similarity index 100% rename from test/stats/samples/mutated-vs-reassigned/input.svelte rename to test/vars/samples/mutated-vs-reassigned/input.svelte diff --git a/test/stats/samples/props/_config.js b/test/vars/samples/props/_config.js similarity index 92% rename from test/stats/samples/props/_config.js rename to test/vars/samples/props/_config.js index cbec831f61..0c5c6f7e2a 100644 --- a/test/stats/samples/props/_config.js +++ b/test/vars/samples/props/_config.js @@ -1,6 +1,6 @@ export default { - test(assert, stats) { - assert.deepEqual(stats.vars, [ + test(assert, vars) { + assert.deepEqual(vars, [ { name: 'name', export_name: 'name', diff --git a/test/stats/samples/props/input.svelte b/test/vars/samples/props/input.svelte similarity index 100% rename from test/stats/samples/props/input.svelte rename to test/vars/samples/props/input.svelte diff --git a/test/stats/samples/store-referenced/_config.js b/test/vars/samples/store-referenced/_config.js similarity index 87% rename from test/stats/samples/store-referenced/_config.js rename to test/vars/samples/store-referenced/_config.js index ecb958df1e..632a9e5b3f 100644 --- a/test/stats/samples/store-referenced/_config.js +++ b/test/vars/samples/store-referenced/_config.js @@ -1,6 +1,6 @@ export default { - test(assert, stats) { - assert.deepEqual(stats.vars, [ + test(assert, vars) { + assert.deepEqual(vars, [ { name: 'foo', export_name: null, diff --git a/test/stats/samples/store-referenced/input.svelte b/test/vars/samples/store-referenced/input.svelte similarity index 100% rename from test/stats/samples/store-referenced/input.svelte rename to test/vars/samples/store-referenced/input.svelte diff --git a/test/stats/samples/store-unreferenced/_config.js b/test/vars/samples/store-unreferenced/_config.js similarity index 87% rename from test/stats/samples/store-unreferenced/_config.js rename to test/vars/samples/store-unreferenced/_config.js index 9ea5784f92..86e467c859 100644 --- a/test/stats/samples/store-unreferenced/_config.js +++ b/test/vars/samples/store-unreferenced/_config.js @@ -1,6 +1,6 @@ export default { - test(assert, stats) { - assert.deepEqual(stats.vars, [ + test(assert, vars) { + assert.deepEqual(vars, [ { name: 'foo', export_name: null, diff --git a/test/stats/samples/store-unreferenced/input.svelte b/test/vars/samples/store-unreferenced/input.svelte similarity index 100% rename from test/stats/samples/store-unreferenced/input.svelte rename to test/vars/samples/store-unreferenced/input.svelte diff --git a/test/vars/samples/template-references/_config.js b/test/vars/samples/template-references/_config.js new file mode 100644 index 0000000000..2b84e83f12 --- /dev/null +++ b/test/vars/samples/template-references/_config.js @@ -0,0 +1,5 @@ +export default { + test(assert, vars) { + assert.deepEqual(vars, []); + }, +}; diff --git a/test/stats/samples/template-references/input.svelte b/test/vars/samples/template-references/input.svelte similarity index 100% rename from test/stats/samples/template-references/input.svelte rename to test/vars/samples/template-references/input.svelte diff --git a/test/vars/samples/undeclared/_config.js b/test/vars/samples/undeclared/_config.js new file mode 100644 index 0000000000..2b84e83f12 --- /dev/null +++ b/test/vars/samples/undeclared/_config.js @@ -0,0 +1,5 @@ +export default { + test(assert, vars) { + assert.deepEqual(vars, []); + }, +}; diff --git a/test/stats/samples/undeclared/input.svelte b/test/vars/samples/undeclared/input.svelte similarity index 100% rename from test/stats/samples/undeclared/input.svelte rename to test/vars/samples/undeclared/input.svelte