Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simpler mechanism for define new JS preprocessor functions/macros. #22510

Open
sbc100 opened this issue Sep 5, 2024 · 0 comments
Open

Add simpler mechanism for define new JS preprocessor functions/macros. #22510

sbc100 opened this issue Sep 5, 2024 · 0 comments

Comments

@sbc100
Copy link
Collaborator

sbc100 commented Sep 5, 2024

Currently we have a fixed set of processor macros/function that are mostly defined in parseTools.js

Adding new macros in JS libraries is possible, but its rather ugly syntax, and has some limitations:

{{{
globalThis.newMacro = () = { .. }
}}}

A major drawback (IIUC) of doing this is that the macros are not available during preprocessing since macros expansion happens after preprocessing. So to use these macros in a preprocessor directive one would need define them in a separate file that is loaded first. e.g. --js-library=my_macros.js --js-library=my_library.js. Here the macros defined in my_macros.js would be available in my_library.js.

One way to improve this would be to allow my_library.js to somehow #include "my_macros.js" .. however that isn't currently how the #include directive works. Currently #include files are placed directly into the output file and don't have macros expanded, so we would need somekind of new #include mechanism.

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

No branches or pull requests

1 participant