mirror of https://github.com/sveltejs/svelte
remove svelte.parse and svelte.create from public API. dont see a way to support svelte.create in v3
parent
ed23d7acb3
commit
a20bbc442e
@ -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 compile } from './compile/index';
|
||||||
export { default as parse } from './parse/index';
|
|
||||||
export { default as preprocess } from './preprocess/index';
|
export { default as preprocess } from './preprocess/index';
|
||||||
|
|
||||||
export const VERSION = '__VERSION__';
|
export const VERSION = '__VERSION__';
|
@ -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(`<div>{prop}</div>`);
|
|
||||||
assert(component instanceof Function);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should throw error when source is invalid ", done => {
|
|
||||||
assert.throws(() => {
|
|
||||||
svelte.create(`<div>{prop</div>`);
|
|
||||||
}, /TODO/);
|
|
||||||
});
|
|
||||||
});
|
|
Loading…
Reference in new issue