diff --git a/src/index.ts b/src/index.ts index 1b9fc8fa61..a82cc48ffe 100644 --- a/src/index.ts +++ b/src/index.ts @@ -150,7 +150,7 @@ function create(source: string, _options: CompileOptions = {}) { } try { - return (new Function(compiled.js.code))(); + return (new Function(`return ${compiled.js.code}`))(); } catch (err) { if (_options.onerror) { _options.onerror(err); diff --git a/test/create/index.js b/test/create/index.js index 3c2387d737..cb4beb623a 100644 --- a/test/create/index.js +++ b/test/create/index.js @@ -4,7 +4,7 @@ import { svelte, deindent } from "../helpers.js"; describe("create", () => { it("should return a component constructor", () => { const source = deindent` -