Skip to content

Conversation

vivekchavan14
Copy link
Contributor

Description

Fixes #6894

The TypeScript parser now correctly detects preprocessor functions that are re-exported from other modules using named exports.

Problem

Previously, users could not use:

export { preprocessor } from "./extract_user_info_from_jwt_token";

They had to use this workaround:

import { preprocessor as extractor } from "./extract_user_info_from_jwt_token";

export async function preprocessor(event: any) {
  return await extractor(event);
}

Solution

The parser now checks ExportNamed AST nodes in addition to function declarations, detecting any specifier named preprocessor.

Changes

  • Modified windmill-parser-ts/src/lib.rs to detect preprocessor in named exports
  • Added 4 comprehensive tests covering:
    • Simple re-export: export { preprocessor } from "./other"
    • Re-export with renaming
    • Mixed exports with multiple identifiers
    • Negative case (exports without preprocessor)

Testing

All 23 tests pass, including the new ones specifically for this fix.

cargo test
# test result: ok. 23 passed; 0 failed

Fixes windmill-labs#6894

The TypeScript parser now correctly detects preprocessor functions
that are re-exported from other modules using named exports like:
  export { preprocessor } from "./other_module";

Previously, only function declarations were detected. Now the parser
also checks ExportNamed AST nodes for any specifier named 'preprocessor'.

This allows developers to easily reuse preprocessor functions across
multiple scripts without the workaround of wrapping them in a new function.

Added comprehensive tests covering:
- Simple re-export: export { preprocessor } from "./other"
- Re-export with renaming: export { preprocessor as preprocessor }
- Mixed exports: export { foo, preprocessor, bar }
- Negative case: exports without preprocessor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: proprocessor cannot be imported into scripts easily

1 participant