Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

webpack-manifest-plugin

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack-manifest-plugin - npm Package Compare versions

Comparing version 2.0.0-rc.1 to 2.0.0-rc.2

98

lib/plugin.js
var path = require('path');
var fse = require('fs-extra');
var _ = require('lodash');
var mutexify = require('mutexify');
var lock = mutexify();
var manifestMap = {};

@@ -18,2 +17,6 @@ function ManifestPlugin(opts) {

generate: null,
sort: null,
serialize: function(manifest) {
return JSON.stringify(manifest, null, 2);
},
}, opts || {});

@@ -36,12 +39,10 @@ }

compiler.plugin("compilation", function (compilation) {
compilation.plugin('module-asset', function (module, file) {
moduleAssets[file] = path.join(
path.dirname(file),
path.basename(module.userRequest)
);
});
});
var moduleAsset = function (module, file) {
moduleAssets[file] = path.join(
path.dirname(file),
path.basename(module.userRequest)
);
};
compiler.plugin('emit', function(compilation, compileCallback) {
var emit = function(compilation, compileCallback) {
var publicPath = compilation.options.output.publicPath;

@@ -61,2 +62,5 @@ var stats = compilation.getStats().toJson();

// Webpack 4: .isOnlyInitial()
// Webpack 3: .isInitial()
// Webpack 1/2: .initial
return files.concat({

@@ -66,3 +70,3 @@ path: path,

name: name,
isInitial: chunk.isInitial ? chunk.isInitial() : chunk.initial,
isInitial: chunk.isOnlyInitial ? chunk.isOnlyInitial() : (chunk.isInitial ? chunk.isInitial() : chunk.initial),
isChunk: true,

@@ -107,3 +111,7 @@ isAsset: false,

// Don't add hot updates to manifest
return file.path.indexOf('hot-update') === -1;
var isUpdateChunk = file.path.indexOf('hot-update') >= 0;
// Don't add manifest from another instance
var isManifest = manifestMap[file.name];
return !isUpdateChunk && !isManifest;
});

@@ -158,3 +166,3 @@

var json = JSON.stringify(manifest, null, 2);
var output = this.opts.serialize(manifest);

@@ -167,6 +175,6 @@ var outputFolder = compilation.options.output.path;

source: function() {
return json;
return output;
},
size: function() {
return json.length;
return output.length;
}

@@ -176,17 +184,57 @@ };

if (this.opts.writeToFileEmit) {
fse.outputFileSync(outputFile, json);
fse.outputFileSync(outputFile, output);
}
// NOTE: make sure webpack is not writing multiple manifests simultaneously
lock(function(release) {
compiler.plugin('after-emit', function(compilation, cb) {
release();
cb();
});
if (!manifestMap[outputName]) {
manifestMap[outputName] = {
running: false,
queue: []
};
}
compilation.applyPluginsAsync('webpack-manifest-plugin-after-emit', manifest, compileCallback);
function unqueueNext() {
if (manifestMap[outputName].queue.length > 0) {
manifestMap[outputName].running = true;
manifestMap[outputName].queue.shift()();
} else {
manifestMap[outputName].running = false;
}
}
manifestMap[outputName].queue.push(function () {
if (compiler.hooks) {
compiler.hooks.afterEmit.tap('ManifestPlugin', function(compilation) {
// TODO: when we deprecate webpack < 3, we can remove the queue logic
unqueueNext()
});
} else {
compiler.plugin('after-emit', function(compilation, cb) {
unqueueNext();
cb();
});
compilation.applyPluginsAsync('webpack-manifest-plugin-after-emit', manifest, compileCallback);
}
})
if(!manifestMap[outputName].running) {
manifestMap[outputName].running = true;
manifestMap[outputName].queue.shift()();
}
}.bind(this);
if (compiler.hooks) {
compiler.hooks.compilation.tap('ManifestPlugin', function (compilation) {
compilation.hooks.moduleAsset.tap('ManifestPlugin', moduleAsset);
});
}.bind(this));
compiler.hooks.emit.tap('ManifestPlugin', emit);
} else {
compiler.plugin('compilation', function (compilation) {
compilation.plugin('module-asset', moduleAsset);
});
compiler.plugin('emit', emit);
}
};
module.exports = ManifestPlugin;
{
"name": "webpack-manifest-plugin",
"version": "2.0.0-rc.1",
"version": "2.0.0-rc.2",
"description": "webpack plugin for generating asset manifests",

@@ -15,3 +15,3 @@ "main": "index.js",

"peerDependencies": {
"webpack": "2 || 3"
"webpack": "2 || 3 || 4"
},

@@ -21,3 +21,3 @@ "devDependencies": {

"css-loader": "^0.9.1",
"extract-text-webpack-plugin": "^3.0.0",
"extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^0.9.0",

@@ -45,4 +45,3 @@ "jasmine": "^2.2.1",

"fs-extra": "^0.30.0",
"lodash": ">=3.5 <5",
"mutexify": "1.0.1"
"lodash": ">=3.5 <5"
},

@@ -49,0 +48,0 @@ "nyc": {

@@ -6,3 +6,3 @@ # Webpack Manifest Plugin [![Build Status](https://travis-ci.org/danethurber/webpack-manifest-plugin.svg?branch=master)](https://travis-ci.org/danethurber/webpack-manifest-plugin) [![codecov](https://codecov.io/gh/danethurber/webpack-manifest-plugin/badge.svg?branch=master)](https://codecov.io/gh/danethurber/webpack-manifest-plugin?branch=master) [![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/webpack-manifest-plugin#)

> NOTE: The following is related to the next major version of `weboack-manifest-plugin`, please check https://github.com/danethurber/webpack-manifest-plugin/blob/1.x/README.md for `v1` documentation
> NOTE: The following is related to the next major version of `webpack-manifest-plugin`, please check https://github.com/danethurber/webpack-manifest-plugin/blob/1.x/README.md for `v1` documentation

@@ -119,3 +119,9 @@ ## Install

### `options.serialize`
Type: `function`<br>
Default: `(manifest) => JSON.stringify(manifest, null, 2)`
Output manifest file in different format then json (i.e. yaml).
## Hooks Options

@@ -122,0 +128,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