Socket
Socket
Sign inDemoInstall

wext-manifest-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wext-manifest-webpack-plugin - npm Package Compare versions

Comparing version 1.2.1 to 1.3.0

1

lib/plugin.d.ts

@@ -7,3 +7,2 @@ /**

*/
import 'emoji-log';
import { Compiler } from 'webpack';

@@ -10,0 +9,0 @@ export declare class WextManifestWebpackPlugin {

77

lib/plugin.js

@@ -5,46 +5,71 @@ "use strict";

exports.WextManifestWebpackPlugin = void 0;
/**
* wext-manifest-webpack-plugin
*
* @author abhijithvijayan <abhijithvijayan.in>
* @license MIT License
*/
require("emoji-log");
const PLUGIN_NAME = 'wext-manifest-webpack-plugin';
function getEntryResource(module) {
const resource = null;
function getEntryResources(module) {
const resources = [];
if (module && typeof module.resource === 'string') {
return module.resource;
resources.push(module.resource);
}
return resource;
return resources;
}
function collectEntryResources(compilation, module, cache) {
var _a;
const index = (_a = compilation.moduleGraph.getPreOrderIndex(module)) !== null && _a !== void 0 ? _a : -1;
// index of module is unique per compilation
// module.id can be null, not used here
if (cache[index] !== undefined) {
return cache[index];
}
if (module && typeof module.resource === 'string') {
cache[index] = getEntryResources(module);
return cache[index];
}
const resources = [];
if (module && module.dependencies) {
const hasModuleGraphSupport = Object.prototype.hasOwnProperty.call(compilation, 'moduleGraph');
module.dependencies.forEach((dep) => {
if (dep) {
const depModule = hasModuleGraphSupport
? compilation.moduleGraph.getModule(dep)
: dep.module;
const originModule = hasModuleGraphSupport
? compilation.moduleGraph.getParentModule(dep)
: dep.originModule;
const nextModule = depModule || originModule;
if (nextModule) {
const depResources = collectEntryResources(compilation, nextModule, cache);
for (let i = 0, { length } = depResources; i !== length; i += 1) {
resources.push(depResources[i]);
}
}
}
});
}
cache[index] = resources;
return resources;
}
class WextManifestWebpackPlugin {
// Define `apply` as its prototype method which is supplied with compiler as its argument
apply(compiler) {
/**
* webpack 4+ comes with a new plugin system.
*
* (// ToDo: support old plugin system //)
*/
const { hooks } = compiler;
// Check for hooks for 4+
if (hooks) {
// Runs plugin after a compilation has been created.
hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
const resourcesCache = [];
// Triggered when an asset from a chunk was added to the compilation.
compilation.hooks.chunkAsset.tap(PLUGIN_NAME, (chunk, file) => {
// Only handle js files with entry modules
if (!file.endsWith('.js') || !chunk.hasEntryModule()) {
if (!file.endsWith('.js') ||
compilation.chunkGraph.getNumberOfEntryModules(chunk) < 1) {
return;
}
// Returns path containing name of asset
const resource = getEntryResource(chunk.entryModule);
const isManifest = (resource && /manifest\.json$/.test(resource)) || false;
const entryModules = Array.from(compilation.chunkGraph.getChunkEntryModulesIterable(chunk));
if (entryModules.length < 1) {
return;
}
const entryModule = entryModules[0];
const resources = collectEntryResources(compilation, entryModule, resourcesCache);
const isManifest = resources.every((resource) => resource && /manifest\.json$/.test(resource));
if (isManifest) {
chunk.files = chunk.files.filter((f) => {
return f !== file;
});
chunk.files.delete(file);
delete compilation.assets[file];
// https://github.com/abhijithvijayan/wext-manifest-webpack-plugin/issues/1
// console.emoji('🦄', `${PLUGIN_NAME}: removed ${file}`, 29);
console.log(`${PLUGIN_NAME}: removed ${file}`);

@@ -51,0 +76,0 @@ }

{
"name": "wext-manifest-webpack-plugin",
"version": "1.2.1",
"version": "1.3.0",
"description": "Webpack plugin to solve the problem of generating js file for manifest.json entry",

@@ -24,3 +24,3 @@ "license": "MIT",

"pack:list": "npm pack && tar -xvzf *.tgz && rm -rf package *.tgz",
"prepublishOnly": "yarn build",
"prepublishOnly": "npm run build",
"lint": "eslint . --ext .ts",

@@ -40,26 +40,23 @@ "lint:fix": "eslint . --ext .ts --fix"

],
"dependencies": {
"emoji-log": "^1.0.2"
},
"devDependencies": {
"@abhijithvijayan/eslint-config": "1.4.1",
"@abhijithvijayan/tsconfig": "^1.2.0",
"@types/loader-utils": "^2.0.1",
"@types/webpack": "^4.41.18",
"@typescript-eslint/eslint-plugin": "^3.5.0",
"@typescript-eslint/parser": "^3.5.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.0.5",
"prettier": "^2.0.5",
"@abhijithvijayan/eslint-config": "^2.8.0",
"@abhijithvijayan/eslint-config-airbnb": "^1.1.0",
"@abhijithvijayan/tsconfig": "^1.3.0",
"@babel/eslint-parser": "^7.23.9",
"@types/webpack": "^5.28.5",
"@typescript-eslint/eslint-plugin": "^6.20.0",
"@typescript-eslint/parser": "^6.20.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"prettier": "^3.2.4",
"rimraf": "^3.0.2",
"typescript": "^3.9.6",
"webpack": "^4.43.0"
"typescript": "^4.9.5",
"webpack": "^5.90.0"
}
}

@@ -8,3 +8,3 @@ <h1 align="center">wext-manifest-webpack-plugin</h1>

<a href="https://travis-ci.org/abhijithvijayan/wext-manifest-webpack-plugin">
<img src="https://travis-ci.org/abhijithvijayan/wext-manifest-webpack-plugin.svg?branch=master" alt="Travis Build" />
<img src="https://travis-ci.org/abhijithvijayan/wext-manifest-webpack-plugin.svg?branch=main" alt="Travis Build" />
</a>

@@ -15,3 +15,3 @@ </a>

</a>
<a href="https://github.com/abhijithvijayan/wext-manifest-webpack-plugin/blob/master/license">
<a href="https://github.com/abhijithvijayan/wext-manifest-webpack-plugin/blob/main/license">
<img src="https://img.shields.io/github/license/abhijithvijayan/wext-manifest-webpack-plugin.svg" alt="LICENSE" />

@@ -18,0 +18,0 @@ </a>

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