mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 04:50:36 +00:00
Remove legacy globals for builtins (finally)
This commit is contained in:
parent
bcdc5f14a5
commit
52c6f21aba
2 changed files with 3 additions and 10 deletions
|
@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
### Breaking Changes
|
||||
|
||||
- Globals for the `fs`, `net`, `process`, `stdio`, and `task` builtins have been removed, and the `require("@lune/...")` syntax is now the only way to access builtin libraries. If you have previously been using a global such as `fs` directly, you will now need to put `local fs = require("@lune/fs")` at the top of the file instead.
|
||||
|
||||
- Migrated several functions in the `roblox` builtin to new, more flexible APIs:
|
||||
|
||||
- `readPlaceFile -> deserializePlace`
|
||||
|
|
|
@ -5,8 +5,6 @@ mod require_waker;
|
|||
|
||||
use crate::builtins::{self, top_level};
|
||||
|
||||
const BUILTINS_AS_GLOBALS: &[&str] = &["fs", "net", "process", "stdio", "task"];
|
||||
|
||||
pub fn create(lua: &'static Lua, args: Vec<String>) -> LuaResult<()> {
|
||||
// Create all builtins
|
||||
let builtins = vec![
|
||||
|
@ -20,14 +18,6 @@ pub fn create(lua: &'static Lua, args: Vec<String>) -> LuaResult<()> {
|
|||
("roblox", builtins::roblox::create(lua)?),
|
||||
];
|
||||
|
||||
// TODO: Remove this when we have proper LSP support for custom
|
||||
// require types and no longer need to have builtins as globals
|
||||
let lua_globals = lua.globals();
|
||||
for name in BUILTINS_AS_GLOBALS {
|
||||
let builtin = builtins.iter().find(|(gname, _)| gname == name).unwrap();
|
||||
lua_globals.set(*name, builtin.1.clone())?;
|
||||
}
|
||||
|
||||
// Create our importer (require) with builtins
|
||||
let require_fn = require::create(lua, builtins)?;
|
||||
|
||||
|
@ -42,6 +32,7 @@ pub fn create(lua: &'static Lua, args: Vec<String>) -> LuaResult<()> {
|
|||
];
|
||||
|
||||
// Set top-level globals
|
||||
let lua_globals = lua.globals();
|
||||
for (name, global) in globals {
|
||||
lua_globals.set(name, global)?;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue