Skip to content

Commit 8407fcf

Browse files
committed
fix: extend native post-pass pre-filter to include arrow-function property assignments (#1331)
The pre-filter regex only matched `fn.method = function(){}` patterns, silently skipping files where all func-prop assignments use arrow functions (`fn.method = () => {}`). Such files were never WASM-reparsed and their method definitions were not inserted by the post-pass. Extend the regex to match both traditional function expressions and arrow function expressions (both `() => {}` and `param => {}` forms).
1 parent c036834 commit 8407fcf

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/domain/graph/builder/stages/native-orchestrator.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,13 +596,18 @@ async function runPostNativePrototypeMethods(
596596
if (jsFiles.length === 0) return;
597597

598598
// Pre-filter: only re-parse files that contain the function-as-object-property
599-
// pattern (`fn.method = function() {}`). The Rust engine now handles
600-
// `Foo.prototype.bar = fn` natively, so `.prototype.` files no longer need
601-
// a WASM re-parse here.
599+
// pattern (`fn.method = function(){}` or `fn.method = () => {}`). The Rust engine
600+
// now handles `Foo.prototype.bar = fn` natively, so `.prototype.` files no longer
601+
// need a WASM re-parse here.
602602
const protoFiles = jsFiles.filter((relPath) => {
603603
try {
604604
const content = readFileSafe(path.join(rootDir, relPath));
605-
return /\b(?!prototype\.)\w+\.\w+\s*=\s*function/.test(content);
605+
// Match `fn.method = function(){}` (traditional) or `fn.method = () => {}`/
606+
// `fn.method = param => {}` (arrow). The negative lookahead excludes `.prototype.`
607+
// patterns already handled natively by the Rust extractor.
608+
return /\b(?!prototype\.)\w+\.\w+\s*=\s*(?:function\b|(?:\([^)]*\)|[A-Za-z_$]\w*)\s*=>)/.test(
609+
content,
610+
);
606611
} catch {
607612
return false;
608613
}

0 commit comments

Comments
 (0)