webpack-manifest-plugin
Advanced tools
Comparing version 2.0.0-rc.1 to 2.0.0-rc.2
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 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12619
3
200
171
+ Added@webassemblyjs/ast@1.9.0(transitive)
+ Added@webassemblyjs/floating-point-hex-parser@1.9.0(transitive)
+ Added@webassemblyjs/helper-api-error@1.9.0(transitive)
+ Added@webassemblyjs/helper-buffer@1.9.0(transitive)
+ Added@webassemblyjs/helper-code-frame@1.9.0(transitive)
+ Added@webassemblyjs/helper-fsm@1.9.0(transitive)
+ Added@webassemblyjs/helper-module-context@1.9.0(transitive)
+ Added@webassemblyjs/helper-wasm-bytecode@1.9.0(transitive)
+ Added@webassemblyjs/helper-wasm-section@1.9.0(transitive)
+ Added@webassemblyjs/ieee754@1.9.0(transitive)
+ Added@webassemblyjs/leb128@1.9.0(transitive)
+ Added@webassemblyjs/utf8@1.9.0(transitive)
+ Added@webassemblyjs/wasm-edit@1.9.0(transitive)
+ Added@webassemblyjs/wasm-gen@1.9.0(transitive)
+ Added@webassemblyjs/wasm-opt@1.9.0(transitive)
+ Added@webassemblyjs/wasm-parser@1.9.0(transitive)
+ Added@webassemblyjs/wast-parser@1.9.0(transitive)
+ Added@webassemblyjs/wast-printer@1.9.0(transitive)
+ Added@xtuc/ieee754@1.2.0(transitive)
+ Added@xtuc/long@4.2.2(transitive)
+ Addedacorn@6.4.2(transitive)
+ Addedajv-errors@1.0.1(transitive)
+ Addedaproba@1.2.0(transitive)
+ Addedbluebird@3.7.2(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedcacache@12.0.4(transitive)
+ Addedchownr@1.1.4(transitive)
+ Addedchrome-trace-event@1.0.4(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedcommondir@1.0.1(transitive)
+ Addedconcat-stream@1.6.2(transitive)
+ Addedcopy-concurrently@1.0.5(transitive)
+ Addedcyclist@1.0.2(transitive)
+ Addedduplexify@3.7.1(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedenhanced-resolve@4.5.0(transitive)
+ Addedeslint-scope@4.0.3(transitive)
+ Addedfiggy-pudding@3.5.2(transitive)
+ Addedfind-cache-dir@2.1.0(transitive)
+ Addedfind-up@3.0.0(transitive)
+ Addedflush-write-stream@1.1.1(transitive)
+ Addedfrom2@2.3.0(transitive)
+ Addedfs-write-stream-atomic@1.0.10(transitive)
+ Addediferr@0.1.5(transitive)
+ Addedimurmurhash@0.1.4(transitive)
+ Addedinfer-owner@1.0.4(transitive)
+ Addedis-wsl@1.1.0(transitive)
+ Addedjson-parse-better-errors@1.0.2(transitive)
+ Addedlocate-path@3.0.0(transitive)
+ Addedlru-cache@5.1.1(transitive)
+ Addedmake-dir@2.1.0(transitive)
+ Addedmemory-fs@0.5.0(transitive)
+ Addedmississippi@3.0.0(transitive)
+ Addedmove-concurrently@1.0.1(transitive)
+ Addedp-limit@2.3.0(transitive)
+ Addedp-locate@3.0.0(transitive)
+ Addedp-try@2.2.0(transitive)
+ Addedparallel-transform@1.2.0(transitive)
+ Addedpify@4.0.1(transitive)
+ Addedpkg-dir@3.0.0(transitive)
+ Addedpromise-inflight@1.0.1(transitive)
+ Addedpump@2.0.13.0.2(transitive)
+ Addedpumpify@1.5.1(transitive)
+ Addedrun-queue@1.0.3(transitive)
+ Addedschema-utils@1.0.0(transitive)
+ Addedserialize-javascript@4.0.0(transitive)
+ Addedsource-map-support@0.5.21(transitive)
+ Addedssri@6.0.2(transitive)
+ Addedstream-each@1.2.3(transitive)
+ Addedstream-shift@1.0.3(transitive)
+ Addedtapable@1.1.3(transitive)
+ Addedterser@4.8.1(transitive)
+ Addedterser-webpack-plugin@1.4.6(transitive)
+ Addedthrough2@2.0.5(transitive)
+ Addedtypedarray@0.0.6(transitive)
+ Addedunique-filename@1.1.1(transitive)
+ Addedunique-slug@2.0.2(transitive)
+ Addedwebpack@4.47.0(transitive)
+ Addedworker-farm@1.7.0(transitive)
+ Addedy18n@4.0.3(transitive)
+ Addedyallist@3.1.1(transitive)
- Removedmutexify@1.0.1
- Removedacorn@4.0.135.7.4(transitive)
- Removedacorn-dynamic-import@2.0.2(transitive)
- Removedalign-text@0.1.4(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedasync@2.6.4(transitive)
- Removedcamelcase@1.2.14.1.0(transitive)
- Removedcenter-align@0.1.3(transitive)
- Removedcliui@2.1.03.2.0(transitive)
- Removedcode-point-at@1.1.0(transitive)
- Removedcross-spawn@5.1.0(transitive)
- Removedd@1.0.2(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removedenhanced-resolve@3.4.1(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedes5-ext@0.10.64(transitive)
- Removedes6-iterator@2.0.3(transitive)
- Removedes6-map@0.1.5(transitive)
- Removedes6-set@0.1.6(transitive)
- Removedes6-symbol@3.1.4(transitive)
- Removedes6-weak-map@2.0.3(transitive)
- Removedescope@3.6.0(transitive)
- Removedesniff@2.0.1(transitive)
- Removedevent-emitter@0.3.5(transitive)
- Removedexeca@0.7.0(transitive)
- Removedext@1.7.0(transitive)
- Removedfind-up@2.1.0(transitive)
- Removedget-caller-file@1.0.3(transitive)
- Removedget-stream@3.0.0(transitive)
- Removedhas-flag@2.0.0(transitive)
- Removedhosted-git-info@2.8.9(transitive)
- Removedinterpret@1.4.0(transitive)
- Removedinvert-kv@1.0.0(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedis-fullwidth-code-point@1.0.0(transitive)
- Removedis-stream@1.1.0(transitive)
- Removedisexe@2.0.0(transitive)
- Removedjson-loader@0.5.7(transitive)
- Removedjson5@0.5.1(transitive)
- Removedlazy-cache@1.0.4(transitive)
- Removedlcid@1.0.0(transitive)
- Removedload-json-file@2.0.0(transitive)
- Removedlocate-path@2.0.0(transitive)
- Removedlongest@1.0.1(transitive)
- Removedlru-cache@4.1.5(transitive)
- Removedmem@1.1.0(transitive)
- Removedmimic-fn@1.2.0(transitive)
- Removedmutexify@1.0.1(transitive)
- Removednext-tick@1.1.0(transitive)
- Removednormalize-package-data@2.5.0(transitive)
- Removednpm-run-path@2.0.2(transitive)
- Removednumber-is-nan@1.0.1(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedos-locale@2.1.0(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedp-limit@1.3.0(transitive)
- Removedp-locate@2.0.0(transitive)
- Removedp-try@1.0.0(transitive)
- Removedparse-json@2.2.0(transitive)
- Removedpath-key@2.0.1(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-type@2.0.0(transitive)
- Removedpify@2.3.0(transitive)
- Removedpseudomap@1.0.2(transitive)
- Removedread-pkg@2.0.0(transitive)
- Removedread-pkg-up@2.0.0(transitive)
- Removedrequire-directory@2.1.1(transitive)
- Removedrequire-main-filename@1.0.1(transitive)
- Removedresolve@1.22.8(transitive)
- Removedright-align@0.1.3(transitive)
- Removedset-blocking@2.0.0(transitive)
- Removedshebang-command@1.2.0(transitive)
- Removedshebang-regex@1.0.0(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.20(transitive)
- Removedstring-width@1.0.2(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedstrip-bom@3.0.0(transitive)
- Removedstrip-eof@1.0.0(transitive)
- Removedsupports-color@4.5.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedtapable@0.2.9(transitive)
- Removedtype@2.7.3(transitive)
- Removeduglify-js@2.8.29(transitive)
- Removeduglify-to-browserify@1.0.2(transitive)
- Removeduglifyjs-webpack-plugin@0.4.6(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)
- Removedwebpack@3.12.0(transitive)
- Removedwhich@1.3.1(transitive)
- Removedwhich-module@2.0.1(transitive)
- Removedwindow-size@0.1.0(transitive)
- Removedwordwrap@0.0.2(transitive)
- Removedwrap-ansi@2.1.0(transitive)
- Removedy18n@3.2.2(transitive)
- Removedyallist@2.1.2(transitive)
- Removedyargs@3.10.08.0.2(transitive)
- Removedyargs-parser@7.0.0(transitive)