Prebake in settings
Update prebake without reload
This commit is contained in:
parent
b4e171f5b4
commit
9f2237e11d
11 changed files with 292 additions and 37 deletions
|
|
@ -3,3 +3,4 @@ import { transpiler } from './transpiler.mjs';
|
|||
export * from './transpiler.mjs';
|
||||
|
||||
export const evaluate = (code) => _evaluate(code, transpiler);
|
||||
export const evaluateUserPrebake = (code) => _evaluate(code, transpiler, { prebake: true });
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ export function transpiler(input, options = {}) {
|
|||
emitMiniLocations = true,
|
||||
emitWidgets = true,
|
||||
blockBased = false,
|
||||
prebake = false,
|
||||
range = [],
|
||||
} = options;
|
||||
|
||||
|
|
@ -260,7 +261,9 @@ export function transpiler(input, options = {}) {
|
|||
// For block-based eval, add silence as the return value when block ends with declaration
|
||||
body.push(silenceExpression);
|
||||
} else {
|
||||
throw new Error('unexpected ast format without body expression');
|
||||
if (!prebake) {
|
||||
throw new Error('unexpected ast format without body expression');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -273,7 +276,7 @@ export function transpiler(input, options = {}) {
|
|||
}
|
||||
|
||||
// add return to last statement
|
||||
if (addReturn) {
|
||||
if (addReturn && !prebake) {
|
||||
const { expression } = body[body.length - 1];
|
||||
body[body.length - 1] = {
|
||||
type: 'ReturnStatement',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue