From a20bbc442ed451b0b5404d645faf85f721f07509 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 2 Dec 2018 17:36:27 -0500 Subject: [PATCH] remove svelte.parse and svelte.create from public API. dont see a way to support svelte.create in v3 --- src/index.ts | 17 +---------------- test/create/index.js | 15 --------------- test/js/index.js | 2 +- test/parser/index.js | 20 +++++++------------- 4 files changed, 9 insertions(+), 45 deletions(-) delete mode 100644 test/create/index.js diff --git a/src/index.ts b/src/index.ts index df9f2781f7..c80b449825 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,19 +1,4 @@ -import compile from './compile/index'; -import { CompileOptions } from './interfaces'; - -export function create(source: string, options: CompileOptions = {}) { - options.format = 'eval'; - - const compiled = compile(source, options); - - if (!compiled || !compiled.js.code) { - return; - } - - return (new Function(`return ${compiled.js.code}`))(); -} - export { default as compile } from './compile/index'; -export { default as parse } from './parse/index'; export { default as preprocess } from './preprocess/index'; + export const VERSION = '__VERSION__'; \ No newline at end of file diff --git a/test/create/index.js b/test/create/index.js deleted file mode 100644 index d88870bf9d..0000000000 --- a/test/create/index.js +++ /dev/null @@ -1,15 +0,0 @@ -import assert from "assert"; -import { svelte, deindent } from "../helpers.js"; - -describe("create", () => { - it("should return a component constructor", () => { - const component = svelte.create(`
{prop}
`); - assert(component instanceof Function); - }); - - it("should throw error when source is invalid ", done => { - assert.throws(() => { - svelte.create(`
{prop
`); - }, /TODO/); - }); -}); diff --git a/test/js/index.js b/test/js/index.js index 71416d8cf3..3ee1a1da2d 100644 --- a/test/js/index.js +++ b/test/js/index.js @@ -3,7 +3,7 @@ import * as fs from "fs"; import * as path from "path"; import { loadConfig, svelte } from "../helpers.js"; -describe.only("js", () => { +describe("js", () => { fs.readdirSync("test/js/samples").forEach(dir => { if (dir[0] === ".") return; diff --git a/test/parser/index.js b/test/parser/index.js index 1cf0bc29ab..8f20c77abd 100644 --- a/test/parser/index.js +++ b/test/parser/index.js @@ -23,13 +23,15 @@ describe('parse', () => { const expectedError = tryToLoadJson(`test/parser/samples/${dir}/error.json`); try { - const actual = svelte.parse(input, options); + const { ast } = svelte.compile(input, Object.assign(options, { + generate: false + })); - fs.writeFileSync(`test/parser/samples/${dir}/_actual.json`, JSON.stringify(actual, null, '\t')); + fs.writeFileSync(`test/parser/samples/${dir}/_actual.json`, JSON.stringify(ast, null, '\t')); - assert.deepEqual(actual.html, expectedOutput.html); - assert.deepEqual(actual.css, expectedOutput.css); - assert.deepEqual(actual.js, expectedOutput.js); + assert.deepEqual(ast.html, expectedOutput.html); + assert.deepEqual(ast.css, expectedOutput.css); + assert.deepEqual(ast.js, expectedOutput.js); } catch (err) { if (err.name !== 'ParseError') throw err; if (!expectedError) throw err; @@ -47,12 +49,4 @@ describe('parse', () => { } }); }); - - it('includes AST in svelte.compile output', () => { - const source = fs.readFileSync(`test/parser/samples/attribute-dynamic/input.html`, 'utf-8'); - - const { ast } = svelte.compile(source); - const parsed = svelte.parse(source); - assert.deepEqual(ast, parsed); - }); });