New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hot-reload-extension-vite

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hot-reload-extension-vite - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

1

dist/main.d.ts
import { Plugin } from 'vite';
type hotReloadExtensionViteOptions = {
contentPath: string;
backgroundPath: string;

@@ -6,0 +5,0 @@ log?: boolean;

@@ -544,3 +544,3 @@ "use strict";

var hotReloadExtensionVite = (options) => {
const { log, contentPath, backgroundPath } = options;
const { log, backgroundPath } = options;
let ws = null;

@@ -559,10 +559,2 @@ if (isDev) {

async transform(code, id) {
if (isDev && id.includes(contentPath)) {
const buffer = import_fs.default.readFileSync(
(0, import_path.resolve)(__dirname, "scripts/content-reload.js")
);
return {
code: code + buffer.toString()
};
}
if (id.includes(backgroundPath)) {

@@ -579,3 +571,3 @@ const buffer = import_fs.default.readFileSync(

if (isDev && !ws)
chalkLogger.red("Open tab with content script to start reloading...");
chalkLogger.red("Load extension to browser...");
if (isDev && ws) {

@@ -582,0 +574,0 @@ if (log)

17

dist/scripts/background-reload.js

@@ -8,9 +8,12 @@ "use strict";

// src/scripts/background-reload.ts
chrome.runtime.onMessage.addListener((message) => {
if (message === "hot-reload-message-reload-extension" /* RELOAD_EXTENSION */) {
chrome.runtime.reload();
chrome.tabs.query({ active: true }).then(() => {
if (isDev) {
const socket = new WebSocket(
`ws://localhost:${HOT_RELOAD_EXTENSION_VITE_PORT}`
);
socket.addEventListener("message", (event) => {
if (event.data === "file-change" /* FILE_CHANGE */) {
chrome.runtime.reload();
chrome.tabs.reload();
});
}
});
}
});
}
{
"name": "hot-reload-extension-vite",
"version": "1.0.3",
"version": "1.0.4",
"description": "Simple vite plugin to reload the chrome extension.",

@@ -5,0 +5,0 @@ "main": "dist/main.js",

@@ -26,3 +26,2 @@ # Hot Reload Chrome Extension - Vite Plugin

log: true,
contentPath: 'path/to/content-script', // src/pages/content/index.ts
backgroundPath: 'path/to/background' // src/pages/background/index.ts

@@ -51,3 +50,2 @@ })

| log | boolean (optional) | Logs error and info. |
| contentPath | string (required) | Path to content script file. |
| backgroundPath | string(required) | Path to background service worker file. |

@@ -54,0 +52,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc