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

Remove browser polyfill not work #134

Open
tvrONHzhIEUz opened this issue Nov 28, 2021 · 1 comment
Open

Remove browser polyfill not work #134

tvrONHzhIEUz opened this issue Nov 28, 2021 · 1 comment

Comments

@tvrONHzhIEUz
Copy link

Describe the bug
Event configure this in vue.config.js , the dist entry files still have webextension-polyfill module code

chainWebpack: (config) => {
    // adambullmer/vue-cli-plugin-browser-extension seems conflict with webextension-polyfill-ts
    // And browser object will be undefined
    // To support Typescript, Follow https://github.com/adambullmer/vue-cli-plugin-browser-extension#browser-polyfills to remove the webpack chain 'provide-webextension-polyfill'
    config.plugins.delete('provide-webextension-polyfill')
    config.module.rules.delete('provide-webextension-polyfill')
  }

inject.js inject by content-script like this

document.addEventListener("DOMContentLoaded", function () {
    var temp = document.createElement("script");
    temp.setAttribute("type", "text/javascript");
    temp.src = chrome.extension.getURL("js/inpage.js");

    temp.onload = function () {
      this.parentNode.removeChild(this);
    };
    document.body.appendChild(temp);
  });

Expected behavior
Remove all webextesion-polyfill in dist entry file

Screenshots
image
image
image

Name Version
vue-cli-plugin-browser-extension latest
Operating System mac
Node v16.13.0
NPM/Yarn yarn 1.22.17
vue-cli 4.5.15
vue-cli-service 4.5.15
browser chrome
@mclberlin
Copy link

mclberlin commented Nov 18, 2022

@tvrONHzhIEUz
Just now I stumbled upon the same issue.
Did some digging and found out that even if you remove the plugin and loader registrations from the source code (node_modules/vue-cli-plugin-browser-extension/index.js) the polyfill will still be inserted into the scripts.
Some more digging revealed that the polyfill is being inserted by the webpack-extension-reloader*, which is used by vue-cli-plugin-browser-extension under the hood.

The extension-reloader is doing that w/o providing any options for disabling it :/
I will post an issue on its github page.

*Here is where they insert the polyfill.

Update: Here the issue, filed on the github repo page of the webpack-extension-reloader plugin

Update: Cited plugin webpack-extension-loader is for development mode only. So, having deleted** the plugin and loader from vue-cli-plugin-browser-extension the polyfill should only ever be inserted while being in development mode - which seems fine with me.

**

config.plugins.delete('provide-webextension-polyfill');
config.module.rules.delete('provide-webextension-polyfill');

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

2 participants