doc-han / xtensio

Browser Extension development made easy! A framework for building browser extensions
https://xtensio.io
MIT License
74 stars 10 forks source link

[Contents]: Extract getConfig with the help of static analysis. #12

Open doc-han opened 1 month ago

doc-han commented 1 month ago

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 Screenshot 2024-10-26 at 10 38 25 AM

What to look for

doc-han commented 1 month ago

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.

doc-han commented 2 weeks ago

Final Entirely achievable with static analysis only. ⚡️