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

Polyfill is included in all scripts, even if they will not be run in an extension context #3

Open
oliverdunk opened this issue Jun 29, 2022 · 1 comment

Comments

@oliverdunk
Copy link
Owner

Currently, we add the browser polyfill to all files ending in .ts. This works nicely to make sure it's available in content scripts, but has limitations. Namely, adding a script tag to the page and referencing a JS file from the extension will try to load the polyfill, and fail because the script is being loaded in the normal world and without access to browser APIs.

We should probably make which files to polyfill configurable or do some sort of AST search for a call to browser.

@oliverdunk
Copy link
Owner Author

Starting looking at this. @typescript/sandbox does provide a way of getting the AST, but it only returns it for the current program, rather than letting you pass in individual files. This seems to cause some errors to be thrown that I need to look in to further.

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