@statoscope/webpack-stats-extension-package-info
Advanced tools
Comparing version 5.19.1 to 5.19.3
@@ -24,34 +24,44 @@ "use strict"; | ||
compiler.hooks.compilation.tap(pluginName, (compilation) => { | ||
const items = []; | ||
const handleResolverResult = (result) => { | ||
const pkg = result.descriptionFileData; | ||
if (pkg && result.descriptionFileRoot) { | ||
const instancePath = path_1.default.relative(context, result.descriptionFileRoot); | ||
items.push({ | ||
compilation.resolverFactory.hooks.resolver.intercept({ | ||
// @ts-ignore | ||
factory(key, hook) { | ||
hook.tap('MyPlugin', (resolver) => { | ||
resolver.hooks.result.tap('MyPlugin', handleResolverResult); | ||
}); | ||
return hook; | ||
}, | ||
}); | ||
}); | ||
const handleResolverResult = (result) => { | ||
const pkg = result.descriptionFileData; | ||
if (pkg && result.descriptionFileRoot) { | ||
const instancePath = path_1.default.relative(context, result.descriptionFileRoot); | ||
const item = { | ||
packageName: pkg.name, | ||
instancePath, | ||
info: { version: pkg.version }, | ||
}; | ||
this.generator.handleInstance(null, item.packageName, item.instancePath, item.info); | ||
// webpack 4 uses absolute path for some modules | ||
// @ts-ignore | ||
const compilation = compiler._lastCompilation || {}; | ||
if (!compilation.chunkGraph && instancePath.match(/^\.\./)) { | ||
const item = { | ||
packageName: pkg.name, | ||
instancePath, | ||
instancePath: result.descriptionFileRoot, | ||
info: { version: pkg.version }, | ||
}); | ||
// webpack 4 uses absolute path for some modules | ||
if (!compilation.chunkGraph && instancePath.match(/^\.\./)) { | ||
items.push({ | ||
packageName: pkg.name, | ||
instancePath: result.descriptionFileRoot, | ||
info: { version: pkg.version }, | ||
}); | ||
} | ||
}; | ||
this.generator.handleInstance(null, item.packageName, item.instancePath, item.info); | ||
} | ||
return result; | ||
}; | ||
compilation.hooks.afterHash.tap(pluginName, () => { | ||
for (const item of items) { | ||
this.generator.handleInstance(compilation.hash, item.packageName, item.instancePath, item.info); | ||
} | ||
}); | ||
[ | ||
compilation.resolverFactory.get('normal'), | ||
compilation.resolverFactory.get('normal', { dependencyType: 'esm' }), | ||
].forEach((resolver) => { | ||
resolver.hooks.result.tap('MyPlugin', handleResolverResult); | ||
}); | ||
} | ||
return result; | ||
}; | ||
compiler.resolverFactory.hooks.resolver.intercept({ | ||
// @ts-ignore | ||
factory(key, hook) { | ||
hook.tap('MyPlugin', (resolver) => { | ||
resolver.hooks.result.tap('MyPlugin', handleResolverResult); | ||
}); | ||
return hook; | ||
}, | ||
}); | ||
@@ -61,2 +71,2 @@ } | ||
exports.default = WebpackCompressedExtension; | ||
//# sourceMappingURL=index.js.map | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@statoscope/webpack-stats-extension-package-info", | ||
"version": "5.19.1", | ||
"version": "5.19.3", | ||
"description": "Webpack adapter for @statoscope/stats-extension-package-info", | ||
@@ -22,4 +22,4 @@ "main": "./dist/index.js", | ||
"@statoscope/stats": "5.14.1", | ||
"@statoscope/stats-extension-package-info": "5.19.0", | ||
"@statoscope/webpack-model": "5.19.1", | ||
"@statoscope/stats-extension-package-info": "5.19.3", | ||
"@statoscope/webpack-model": "5.19.3", | ||
"@types/webpack": "^5.0.0" | ||
@@ -30,3 +30,3 @@ }, | ||
}, | ||
"gitHead": "f87c943d617f2dfe1a479962ec84d7e2251473c9" | ||
"gitHead": "e214503eebc26181f87885e55e46487aee43b4d3" | ||
} |
6136
80
+ Added@statoscope/stats-extension-package-info@5.19.3(transitive)
+ Added@statoscope/webpack-model@5.19.3(transitive)
- Removed@statoscope/stats-extension-package-info@5.19.0(transitive)
- Removed@statoscope/webpack-model@5.19.1(transitive)