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

feat: web accessible scripts #31

Merged
merged 6 commits into from Jun 17, 2022

Conversation

blake-regalia
Copy link
Contributor

Adds ability to transpile scripts that user includes as web accessible resources. For instance, if a content script needs to inject an inpage script into the webpage at runtime, the user can simply include the path to the inpage script as a web_accessible_resource and the plugin will take care of the rest.

This PR also adds a new plugin option webAccessibleScripts that simply mirrors the inputs to createFilter, allowing user to control which files will match as scripts:

interface ViteWebExtensionOptions {
  webAccessibleScripts?: {
    include?: Pattern;
    exclude?: Pattern;
    options?: {
      resolve?: string | false | null;
    };
  };
}

@blake-regalia
Copy link
Contributor Author

blake-regalia commented May 15, 2022

Closes #30

@samrum
Copy link
Owner

samrum commented May 18, 2022

Thanks for the PR! Could you add some tests for these changes? Should be very similar to test/fixture/index/javascript/manifestV2/webAccessibleResourceHtml.ts and test/fixture/index/javascript/manifestV3/webAccessibleResourceHtml.ts

@blake-regalia
Copy link
Contributor Author

Added some tests following the pattern for resources.

@blake-regalia
Copy link
Contributor Author

ping @samrum ?

@blake-regalia
Copy link
Contributor Author

Ah, I see a missing dev dependency, but on my local machine I'm getting the same test failures about unhandled/*.html -- not sure where that is coming from as I didn't touch those tests.

Copy link
Owner

@samrum samrum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of things, the test failures related to html are because of the unfiltered web accessible resource input pushes

src/manifestParser/manifestV2.ts Outdated Show resolved Hide resolved
src/manifestParser/manifestV2.ts Outdated Show resolved Hide resolved
src/manifestParser/manifestV2.ts Show resolved Hide resolved
src/manifestParser/manifestV3.ts Outdated Show resolved Hide resolved
@samrum
Copy link
Owner

samrum commented Jun 10, 2022

Also, your tests need to be added to test/fixture/index/javascript/manifestV2/index.ts and test/fixture/index/javascript/manifestV3/index.ts for them to run

@blake-regalia
Copy link
Contributor Author

@samrum Thank you for the guidance, it was a huge help! I believe that should take care of it.

samrum
samrum previously approved these changes Jun 15, 2022
@blake-regalia
Copy link
Contributor Author

@samrum I see the merge is blocked since those commits aren't signed, how do you suggest we proceed? Do you want me to open a new PR with a squashed and signed commit?

@blake-regalia
Copy link
Contributor Author

@samrum okay, I've retroactively signed all commits. I think it's ready to merge :)

@samrum samrum merged commit 32c24a4 into samrum:main Jun 17, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants