xtensio
xtensio copied to clipboard
[Contents]: Extract getConfig with the help of static analysis.
Description
Currently, when extracting getConfig object from content files. We simulate an environment to execute the file. The issue is that in this same file exists some other JS code that is waiting to be executed on the web. This other code might fail at the stage we're trying to just extract the getConfig object.
Example getConfig function
What to look for
- With static analysis, can we cleanup content files to contain just
getConfigfunction and its dependency modules so that we don't execute extra code. - checkout the typescript compiler api or recast
Idea 01
I think with static analysis we can just check the children nodes of program and find an exported function or variable with name getConfig then remove all other children nodes that aren't that or imports. When it comes to cleaning up imports, how about running eslint --fix with a single rule remove-ununsed-imports to avoid walking down the tree.
Final Entirely achievable with static analysis only. ⚡️