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

considered web-extension polyfill? #18

Closed
spencerc99 opened this issue Jul 7, 2022 · 4 comments · Fixed by #174
Closed

considered web-extension polyfill? #18

spencerc99 opened this issue Jul 7, 2022 · 4 comments · Fixed by #174

Comments

@spencerc99
Copy link

just wondering if you ever considered making this generally compatible with web extension to be used in firefox as well. Seems like most people use https://github.com/mozilla/webextension-polyfill

@Jonghakseo
Copy link
Owner

Unfortunately, Firefox compatibility is not considered.
Because I personally don't use Firefox. 😞

@Jonghakseo
Copy link
Owner

Although it's a bit cumbersome, it looks like you'll have to add the polyfill yourself.

@govza
Copy link
Contributor

govza commented Aug 5, 2023

Coming across the issue, it looks like web-extension polyfill is not needed anymore for manifest v3.
Firefox support though, achievable by small edition of manifest-parser (there is some small differences).

static convertManifestToString(manifest: Manifest): string {
    if (process.env.__FIREFOX__) {
      manifest = this.convertToFirefoxCompatibleManifest(manifest);
    }
    return JSON.stringify(manifest, null, 2);
  }

  static convertToFirefoxCompatibleManifest(manifest: Manifest) {
    const manifestCopy = {
      ...manifest,
    } as { [key: string]: unknown };

    manifestCopy.background = {
      scripts: [manifest.background?.service_worker],
      type: "module",
    };
    manifestCopy.options_ui = {
      page: manifest.options_page,
      browser_style: false,
    };
    manifestCopy.content_security_policy = {
      extension_pages: "script-src 'self'; object-src 'self'",
    };
    delete manifestCopy.options_page;
    return manifestCopy as Manifest;
  }

and

export default function customDynamicImport(): PluginOption {
  return {
    name: "custom-dynamic-import",
    renderDynamicImport() {
      if (process.env.__FIREFOX__) {
        return {
          left: `
        {
          const dynamicImport = (path) => import(path);
          dynamicImport(browser.runtime.getURL('./') + 
          `,
          // eslint-disable-next-line prettier/prettier
          right: ".split('../').join(''))}",
        };
      } ...

let me know if we want this as PR.

@Jonghakseo
Copy link
Owner

@govza

I'm not a big fan of firefox, but I think this will help a lot of other people who are looking forward to firefox support.

If you could post a PR, I would be so grateful!

@Jonghakseo Jonghakseo reopened this Aug 20, 2023
govza added a commit to govza/chrome-extension-boilerplate-react-vite that referenced this issue Aug 20, 2023
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 a pull request may close this issue.

3 participants