Skip to content

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

Open
@oliverdunk

Description

@oliverdunk
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.

Activity

oliverdunk

oliverdunk commented on Jul 4, 2022

@oliverdunk
OwnerAuthor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @oliverdunk

        Issue actions

          Polyfill is included in all scripts, even if they will not be run in an extension context · Issue #3 · oliverdunk/web-extension-playground