Socket
Socket
Sign inDemoInstall

closure-webpack-plugin

Package Overview
Dependencies
311
Maintainers
2
Versions
65
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 2.2.0

2

package.json
{
"name": "closure-webpack-plugin",
"version": "2.1.0",
"version": "2.2.0",
"description": "Webpack Google Closure Compiler and Closure Library plugin",

@@ -5,0 +5,0 @@ "author": "Chad Killingsworth (@ChadKillingsworth)",

@@ -69,2 +69,5 @@ # closure-webpack-plugin

for details.
* **test** - An optional string or regular expression to determine whether a chunk is included in the compilation
* **extraCommandArgs** - Optional string or Array of strings to pass to the google-closure-compiler plugin.
Can be used to pass flags to the java process.

@@ -71,0 +74,0 @@ ## Compiler Flags

@@ -637,3 +637,3 @@ const fs = require('fs');

if (primaryChunk && primaryChunk.entryModule) {
if (!baseChunk) {
if (!baseChunk || chunkGroup.getParents().length === 0) {
primaryParentNames.push(this.BASE_CHUNK_NAME);

@@ -1105,4 +1105,4 @@ }

* @param {?} compilation
* @param {!Chunk} chunk
* @param {!Array<string>} parentChunkNames - logical chunk parent of this tree
* @param {!Chunk} initialChunk
* @param {!Array<string>} initialParentChunkNames - logical chunk parent of this tree
* @param {!ChunkMap} chunkDefs

@@ -1113,58 +1113,64 @@ * @param {!Array<string>} entrypoints modules

compilation,
chunk,
parentChunkNames,
initialChunk,
initialParentChunkNames,
chunkDefs,
entrypoints
) {
const chunkName = this.getChunkName(compilation, chunk);
const safeChunkName = chunkName.replace(/\.js$/, '');
const chunkSources = [];
chunk.files.forEach((chunkFile) => {
if (!chunkFile.match(this.options.test)) {
return;
}
let src = '';
let sourceMap = null;
try {
const souceAndMap = compilation.assets[chunkFile].sourceAndMap();
src = souceAndMap.source;
if (souceAndMap.map) {
sourceMap = souceAndMap.map;
const chunkQueue = [
{
chunk: initialChunk,
parentChunkNames: initialParentChunkNames,
},
];
while (chunkQueue.length > 0) {
const { chunk, parentChunkNames } = chunkQueue.pop();
const chunkName = this.getChunkName(compilation, chunk);
const safeChunkName = chunkName.replace(/\.js$/, '');
const chunkSources = [];
chunk.files.forEach((chunkFile) => {
if (!chunkFile.match(this.options.test)) {
return;
}
} catch (e) {
compilation.errors.push(e);
}
chunkSources.push({
path: chunkName,
src,
sourceMap,
let src = '';
let sourceMap = null;
try {
const souceAndMap = compilation.assets[chunkFile].sourceAndMap();
src = souceAndMap.source;
if (souceAndMap.map) {
sourceMap = souceAndMap.map;
}
} catch (e) {
compilation.errors.push(e);
}
chunkSources.push({
path: chunkName,
src,
sourceMap,
});
});
});
const chunkDef = {
name: safeChunkName,
parentNames: new Set(),
sources: chunkSources,
outputWrapper: '(function(){%s}).call(this || window)',
};
if (parentChunkNames) {
parentChunkNames.forEach((parentName) => {
chunkDef.parentNames.add(parentName);
});
}
chunkDefs.set(safeChunkName, chunkDef);
const forEachChildChunk = (childChunk) => {
this.addChunkToCompilationStandard(
compilation,
childChunk,
[safeChunkName],
chunkDefs,
entrypoints
);
};
for (const group of chunk.groupsIterable) {
for (const childGroup of group.childrenIterable) {
childGroup.chunks.forEach(forEachChildChunk);
const chunkDef = {
name: safeChunkName,
parentNames: new Set(),
sources: chunkSources,
outputWrapper: '(function(){%s}).call(this || window)',
};
if (parentChunkNames) {
parentChunkNames.forEach((parentName) => {
chunkDef.parentNames.add(parentName);
});
}
chunkDefs.set(safeChunkName, chunkDef);
for (const group of chunk.groupsIterable) {
for (const childGroup of group.childrenIterable) {
const chunksToAdd = [];
childGroup.chunks.forEach((childChunk) => {
chunksToAdd.unshift({
chunk: childChunk,
parentNames: [safeChunkName],
});
});
chunkQueue.push(...chunksToAdd);
}
}
}

@@ -1171,0 +1177,0 @@ }

/**
* Find an ancestor of a chunk. Return the distance from the target or -1 if not found.
*
* @param {string} src
* @param {string} target
* @param {number} currentDistance
* @param {ChunkGroup} initialSrc
* @param {ChunkGroup} target
* @param {number} initialDistance
* @return {number} distance from target of parent or -1 when not found
*/
function findAncestorDistance(src, target, currentDistance) {
if (target === src) {
return currentDistance;
}
function findAncestorDistance(initialSrc, target, initialDistance) {
const distances = [];
src.getParents().forEach((srcParentChunkGroup) => {
const distance = findAncestorDistance(
srcParentChunkGroup,
target,
currentDistance + 1
);
if (distance >= 0) {
distances.push(distance);
const parentChunkQueue = [
{
src: initialSrc,
currentDistance: initialDistance,
},
];
while (parentChunkQueue.length > 0) {
const { src, currentDistance } = parentChunkQueue.pop();
if (target === src) {
if (currentDistance >= 0) {
distances.push(currentDistance);
}
} else {
const parentChunkGroups = src.getParents();
for (let i = parentChunkGroups.length - 1; i >= 0; i--) {
parentChunkQueue.push({
src: parentChunkGroups[i],
currentDistance: currentDistance + 1,
});
}
}
});
}
if (distances.length === 0) {

@@ -26,0 +34,0 @@ return -1;

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc