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.3.0 to 1.3.1

28

lib/plugin.js

@@ -15,5 +15,9 @@ "use strict";

var _a;
const index = (_a = compilation.moduleGraph.getPreOrderIndex(module)) !== null && _a !== void 0 ? _a : -1;
const hasModuleGraphSupport = Object.prototype.hasOwnProperty.call(compilation, 'moduleGraph');
// index of module is unique per compilation
// module.id can be null, not used here
const index = hasModuleGraphSupport
? (_a = compilation.moduleGraph.getPreOrderIndex(module)) !== null && _a !== void 0 ? _a : 1
: 1;
// get from cache
if (cache[index] !== undefined) {

@@ -27,4 +31,5 @@ return cache[index];

const resources = [];
// if the json file is imported using a javascript file
// will need to go through dependencies to extract the resources
if (module && module.dependencies) {
const hasModuleGraphSupport = Object.prototype.hasOwnProperty.call(compilation, 'moduleGraph');
module.dependencies.forEach((dep) => {

@@ -41,3 +46,3 @@ if (dep) {

const depResources = collectEntryResources(compilation, nextModule, cache);
for (let i = 0, { length } = depResources; i !== length; i += 1) {
for (let i = 0; i < depResources.length; i += 1) {
resources.push(depResources[i]);

@@ -62,8 +67,12 @@ }

compilation.hooks.chunkAsset.tap(PLUGIN_NAME, (chunk, file) => {
const hasChunkGraphSupport = Object.prototype.hasOwnProperty.call(compilation, 'chunkGraph');
// Only handle js files with entry modules
if (!file.endsWith('.js') ||
compilation.chunkGraph.getNumberOfEntryModules(chunk) < 1) {
(hasChunkGraphSupport &&
compilation.chunkGraph.getNumberOfEntryModules(chunk) < 1)) {
return;
}
const entryModules = Array.from(compilation.chunkGraph.getChunkEntryModulesIterable(chunk));
const entryModules = hasChunkGraphSupport
? Array.from(compilation.chunkGraph.getChunkEntryModulesIterable(chunk))
: [];
if (entryModules.length < 1) {

@@ -76,3 +85,10 @@ return;

if (isManifest) {
chunk.files.delete(file);
if (Array.isArray(chunk.files)) {
chunk.files = chunk.files.filter((f) => {
return f !== file;
});
}
else if (chunk.files instanceof Set) {
chunk.files.delete(file);
}
delete compilation.assets[file];

@@ -79,0 +95,0 @@ console.log(`${PLUGIN_NAME}: removed ${file}`);

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

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

"@babel/eslint-parser": "^7.23.9",
"@types/webpack": "^5.28.5",
"@types/webpack": "^4.41.18 || ^5.0.0",
"@typescript-eslint/eslint-plugin": "^6.20.0",

@@ -47,0 +47,0 @@ "@typescript-eslint/parser": "^6.20.0",

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