diff --git a/packages/lib/src/lib.rs b/packages/lib/src/lib.rs index 60f6821..bfb3c0a 100644 --- a/packages/lib/src/lib.rs +++ b/packages/lib/src/lib.rs @@ -2,6 +2,7 @@ use std::process::ExitCode; use lua::task::{TaskScheduler, TaskSchedulerResumeExt, TaskSchedulerScheduleExt}; use mlua::prelude::*; +use mlua::Compiler as LuaCompiler; use tokio::task::LocalSet; pub(crate) mod builtins; @@ -68,6 +69,7 @@ impl Lune { ) -> Result { // Create our special lune-flavored Lua object with extra registry values let lua = lua::create_lune_lua()?; + let script_bytecode = LuaCompiler::default().compile(script_contents); // Create our task scheduler and all globals // NOTE: Some globals require the task scheduler to exist on startup let sched = TaskScheduler::new(lua)?.into_static(); @@ -75,7 +77,7 @@ impl Lune { importer::create(lua, self.args.clone())?; // Create the main thread and schedule it let main_chunk = lua - .load(script_contents.as_ref()) + .load(script_bytecode) .set_name(script_name.as_ref()) .into_function()?; let main_thread = lua.create_thread(main_chunk)?;