44 * syncs the project itself and never comes here.
55 *
66 * Stages, on by default for deploys; `"minify": false` in typetorch.json or --no-minify turns them off:
7- * 1. strip: comments and whitespace, with darklua's parser. Lines stay where they are (generator retain_lines), so
7+ * 1. strip: comments (but the compiler's header line) and whitespace, with darklua's parser. Lines stay where they are (generator retain_lines), so
88 * error traces and analytics fingerprints still point at the compiled source.
99 * 2. define: `__DEV__` becomes false and its dead branches go, like Vite's define. React reads it from _G or
1010 * ReactGlobals, defaulting to false; a game that sets it switches this stage off.
@@ -23,6 +23,8 @@ export const PACK_DIR = ".typetorch/pack";
2323const CACHE_SUBDIR = "pack" ;
2424const WORK_DIR = ".typetorch/pack-work" ;
2525const SCRIPT = / \. ( l u a u | l u a ) $ / ;
26+ /** darklua's `except` pattern (Rust regex) for the comment rbxtsc and goblox put on line 1. */
27+ export const COMPILER_HEADER = "^--\\s*Compiled with " ;
2628/** Below this many changed modules another process doesn't pay for itself. */
2729const FILES_PER_PROCESS = 200 ;
2830const MAX_PROCESSES = 4 ;
@@ -56,7 +58,8 @@ function sha(text: string | Uint8Array): string {
5658/** darklua's settings for these stages. */
5759export function darkluaConfig ( stages : PackStages ) : object {
5860 const rules : unknown [ ] = [ ] ;
59- if ( stages . strip ) rules . push ( "remove_comments" , "remove_spaces" ) ;
61+ // The compiler's header line (`-- Compiled with roblox-ts v3.0.0`) stays: it says what produced the module.
62+ if ( stages . strip ) rules . push ( { rule : "remove_comments" , except : [ COMPILER_HEADER ] } , "remove_spaces" ) ;
6063 if ( stages . define ) {
6164 rules . push ( { rule : "inject_global_value" , identifier : "__DEV__" , value : false } , "compute_expression" , "remove_unused_if_branch" , "remove_unused_while" , "remove_empty_do" ) ;
6265 }
0 commit comments