Coder Social home page Coder Social logo

webextension-toolbox / webpack-webextension-plugin Goto Github PK

View Code? Open in Web Editor NEW
79.0 3.0 21.0 1.59 MB

Webpack plugin that compiles WebExtension manifest.json files and adds smart auto reload

Home Page: https://www.npmjs.com/package/@webextension-toolbox/webpack-webextension-plugin

License: Other

JavaScript 6.66% TypeScript 93.34%
webpack-plugin autoreload websockets firefox webpack webextension

webpack-webextension-plugin's People

Contributors

balcsida avatar dependabot-preview[bot] avatar dependabot[bot] avatar erictrinh avatar ermik avatar evhaus avatar fchastanet avatar fregante avatar greenkeeper[bot] avatar handtrix avatar here-nerd avatar platy avatar renovate-bot avatar robinvdbroeck avatar rthaut avatar tm1000 avatar vwheezy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

webpack-webextension-plugin's Issues

Localized strings are now being removed from manifest.json

It seems localized strings in the manifest.json file are erroneously being removed during the "compilation" process.

A source manifest.json file containing the following contents:

{
  "manifest_version": 3,
  "name": "__MSG_extensionName__",
  "description": "__MSG_extensionDescription__",
  "version": "1.0"
}

Results in this invalid manifest.json (note the empty name and description properties):

{
  "manifest_version": 3,
  "name": "",
  "description": "",
  "version": "1.0"
}

However, the expected output is:

{
  "manifest_version": 3,
  "name": "__MSG_extensionName__",
  "description": "__MSG_extensionDescription__",
  "version": "1.0"
}

I haven't done any debugging yet, but a cursory glance leads me to believe the transformManifestValuesFromENV() method introduced in v2.0.1 is the culprit, as the was not an issue in v1.0,0 and earlier.

Can't connect to WS server via WSL 2

I'm running the extension from WSL2 Ubuntu on windows 10. I just can't seem to get the auto-reloading to work because of the connectivity issue. Everything else works fine.. my APIs which are also inside WSL2 connect perfectly fine via localhost.

Screenshot 2021-04-28 122620

I also tried the server host to 0.0.0.0 but it changed nothing.

Any help is appreciated.

Is it possible to set the content scripts file name?

Ideally I would like to have the content hash as part of the file name for the scripts '[contenthash]-[name].js', but I don't see anything about this accepting webpack output config, paths, or names, or accepting webpack template strings.

Is this possible, or does the script name have to be something that is predetermined?

Docs on usage not working

The docs on Usage did not work in my setup. I was getting a TypeError: saying WebextensionPlugin is not a constructor. I had to replace it with the following:

import { WebextensionPlugin } from "@webextension-toolbox/webpack-webextension-plugin";

const config = {
  plugins: [
    new WebextensionPlugin({
      vendor: "chrome",
    }),
  ],
};

I can submit a PR for this, but I'm not sure if this is the correct behavior or if my setup had to do with the issue.

Not working with [email protected]

webpack-webextension-plugin listens on ws://localhost:35729
[webpack-cli] TypeError: fileSystemInfo._fileTimestamps.entries is not a function
    at WebextensionPlugin.extractChangedFiles (***\node_modules\webpack-webextension-plugin\index.js:245:48)
    at WebextensionPlugin.reloadExtensions (***\node_modules\webpack-webextension-plugin\index.js:226:31)
    at WebextensionPlugin.done (***\node_modules\webpack-webextension-plugin\index.js:98:10)
    at Hook.eval [as callAsync] (eval at create (***\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:9:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (***\node_modules\tapable\lib\Hook.js:18:14)
    at Watching._done (***\node_modules\webpack\lib\Watching.js:273:28)
    at ***\node_modules\webpack\lib\Watching.js:195:21
    at Compiler.emitRecords (***\node_modules\webpack\lib\Compiler.js:874:39)
    at ***\node_modules\webpack\lib\Watching.js:173:22
    at ***\node_modules\webpack\lib\Compiler.js:856:14

Repeated file changes doesn't properly compile manifest

Using a mostly standard setup, the first dev compile outputs the correct manifest.json but every reload after uses the non-compiled version.

E.g. first compilation outputs:

manifest.json
{
  "name": "__MSG_appName__",
  "description": "__MSG_appDescription__",
  "version": "1.0.0",
  "short_name": "__MSG_appShortName__",
  "manifest_version": 3,
  "default_locale": "en",
  "background": {
    "scripts": [
      "serviceWorker.js",
      "webextension-toolbox/background_page.js"
    ]
  },
  "content_scripts": [
    {
      "matches": [
        "<all_urls>"
      ],
      "js": [
        "contentScript.js"
      ]
    }
  ],
  "permissions": [
    "storage",
    "scripting"
  ],
  "options_ui": {
    "page": "pages/options.html",
    "open_in_tab": true
  },
  "action": {
    "default_title": "__MSG_browserActionTitle__",
    "default_popup": "pages/popup.html",
    "default_icon": {
      "16": "images/icon-16x.png",
      "32": "images/icon-32x.png",
      "48": "images/icon-48x.png",
      "128": "images/icon-128x.png"
    }
  },
  "icons": {
    "16": "images/icon-16x.png",
    "32": "images/images-32x.png",
    "48": "images/icon-48x.png",
    "128": "images/icon-128x.png"
  },
  "browser_specific_settings": {
    "gecko": {
      "id": "[email protected]"
    }
  }
}

Second compilation:

manifest.json
{
  "name": "__MSG_appName__",
  "short_name": "__MSG_appShortName__",
  "description": "__MSG_appDescription__",
  "manifest_version": 3,
  "default_locale": "en",
  "background": {
    "scripts": ["serviceWorker.js"]
  },
  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["contentScript.js"]
    }
  ],
  "permissions": ["storage", "scripting"],
  "options_ui": {
    "page": "pages/options.html",
    "open_in_tab": true
  },
  "action": {
    "default_title": "__MSG_browserActionTitle__",
    "default_popup": "pages/popup.html",
    "default_icon": {
      "16": "images/icon-16x.png",
      "32": "images/icon-32x.png",
      "48": "images/icon-48x.png",
      "128": "images/icon-128x.png"
    }
  },
  "icons": {
    "16": "images/icon-16x.png",
    "32": "images/images-32x.png",
    "48": "images/icon-48x.png",
    "128": "images/icon-128x.png"
  },
  "__firefox|safari__browser_specific_settings": {
    "gecko": {
      "id": "[email protected]"
    }
  }
}

First compile output shows:

asset manifest.json 1.08 KiB [emitted]

Second compile output shows:

asset manifest.json 997 bytes [emitted] [from: manifest.json] [copied]

I've outputted the changedFiles variables and it's everything in the source tree excluding dist, but including manifest.json for some reason.

Tried using --copy-ignore but couldn't figure out how to inject "packages" with globs.

If this is a code issue, I could help submit a PR. If this is a setup issue, any help would be greatly appreciated!

Handle DEP_WEBPACK_COMPILATION_ASSETS

[DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
        Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.        Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.

Manifest.json custom path

Hi! Thank for the great job that has been done here.

I have a question though, is there a way to define a custom path to the manifest.json file?

Since I'm not very use to work with webpack and related tools, I might be missing something. But, as far as I understand, the plugin will always look for the manifest in options.context path. Maybe an additional option to set the manifest path could do the job? With a fallback to the default one.

Deprecation warning with Webpack 5.28.0

Upgrading our setup to Webpack 5.28.0 yields this warning:

(node:12778) [DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
	Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
	Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.
    at WebextensionPlugin.addManifest (.../node_modules/webpack-webextension-plugin/index.js:211:41)
    at async Promise.all (index 1)

Note: running node --trace-deprecation ./node_modules/webpack/bin/webpack.js to provide a stack trace.

It correspond to this code line.

support webpack 5

Hello,

I'm using webpack 5, I have this error

[webpack-cli] TypeError: Cannot read property 'entries' of undefined
    at WebextensionPlugin.extractChangedFiles (C:\projects\ck_ip_browser_extension\node_modules\webpack-webextension-plugin\index.js:246:57)
    at WebextensionPlugin.reloadExtensions (C:\projects\ck_ip_browser_extension\node_modules\webpack-webextension-plugin\index.js:226:31)
    at WebextensionPlugin.done (C:\projects\ck_ip_browser_extension\node_modules\webpack-webextension-plugin\index.js:98:10)
    at Hook.eval [as callAsync] (eval at create (C:\projects\ck_ip_browser_extension\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:26:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (C:\projects\ck_ip_browser_extension\node_modules\tapable\lib\Hook.js:18:14)
    at Watching._done (C:\projects\ck_ip_browser_extension\node_modules\webpack\lib\Watching.js:260:28)
    at C:\projects\ck_ip_browser_extension\node_modules\webpack\lib\Watching.js:183:21
    at Compiler.emitRecords (C:\projects\ck_ip_browser_extension\node_modules\webpack\lib\Compiler.js:864:39)
    at C:\projects\ck_ip_browser_extension\node_modules\webpack\lib\Watching.js:161:22
    at C:\projects\ck_ip_browser_extension\node_modules\webpack\lib\Compiler.js:846:14

from this doc I found that
Compilation.fileTimestamps and contextTimestamps removed
MIGRATION: Use Compilation.fileSystemInfo instead

update dependencies

this package depends on joi version ^13.3.0 which depends on hoek version 5.x.x which has been deleted for security reasons. therefore I think this package needs to update joi package to its latest version.

I could make a PR but I am not sure how to test these changes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.