Skip to content

feat: add legacy script types and auto-infer child pattern in syncRules - #295

Open
mohammadaboalnadar wants to merge 3 commits into
argon-rbx:mainfrom
momo-city-rblx:feat/legacy-script-types
Open

mohammadaboalnadar wants to merge 3 commits into
argon-rbx:mainfrom
momo-city-rblx:feat/legacy-script-types

Conversation

@mohammadaboalnadar

Copy link
Copy Markdown

Summary

This PR introduces explicit support for legacy script types (LegacyServerScript and LegacyClientScript) in syncRules, preserves default sync rules when custom rules are defined, and automatically infers directory entry point patterns from rule suffixes.

The LegacyServerScript and LegacyClientScript variants were taken directly from Rojo's implementation to ensure seamless cross-compatibility between project schemas. This was developed primarily for internal use within our development team to achieve full cross-compatibility across our projects, and we are submitting it upstream so the Argon community can take advantage of it.

Problem Statement

  1. Legacy Script Ambiguity: With emitLegacyScripts: false becoming standard for modern RunContext workflows, projects still occasionally require true legacy LocalScript instances (e.g. for ReplicatedFirst, character containers, or legacy tool scripts). Previously, there was no way to force legacy script types via syncRules without mutating global project flags or adding .meta.json files.
  2. Default Rule Dropping: In Meta::from_project, defining custom syncRules in *.project.json replaced the entire rule list, dropping built-in rules like default_sync_rules(). As a result, standard libraries using init.luau (such as CameraShaker/init.luau) were turned into Folder instances with a nested init script instead of a single ModuleScript.
  3. Directory Entry Point Inference: Custom sync rules with suffixes required manual pattern orchestration for directories.

Solution

  1. Legacy Script Types in Middleware & ScriptType:
    Added LegacyServerScript and LegacyClientScript variants to Middleware and ScriptType, adopting the exact naming and semantics from Rojo (legacyServerScript and legacyClientScript). These guarantee emission of LocalScript and legacy Script instances regardless of the emitLegacyScripts project setting.

  2. Auto-Inference of Directory Child Patterns:
    In Meta::from_project, when a rule specifies a suffix (e.g. .local.luau), Argon automatically generates the corresponding child_pattern (init{suffix}, such as init.local.luau).

  3. Preservation of Built-in Sync Rules:
    Meta::from_project now appends default_sync_rules() after custom user rules, ensuring built-in conventions (init.luau, init.server.luau, etc.) remain fully functional when custom rules are present.

  4. Default Rules for Common Legacy Suffixes:
    Added built-in recognition for *.local.luau, *.legacy.luau, *.local.lua, and *.legacy.lua in src/constants.rs.

  5. Lint Cleanup:
    Fixed redundant reference warning in src/util.rs (useless_borrows_in_formatting).

Verification

  • Verified dual-tool roundtripping with Rojo projects.
  • Tested directory entry points (CameraShaker/init.luau and FinishTPHandler/init.local.luau).
  • CI passes across Ubuntu, macOS, and Windows.

AI Disclosure

AI was used to assist in the creation of this pull request body and implementation. I am not an experienced Rust developer personally, so while I understand what is going on, I am not fully aware or experienced in general Rust or specific Argon coding practices, so I trusted my AI for the technical details rather than the high-level design. I am open to making edits and correcting any code if highlighted by someone more experienced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant