1234567891011121314151617181920212223242526272829303132333435 |
- const webpackVersion = require('./get-webpack-version');
- function getModuleChunk(module, modules) {
- let chunks;
- if (webpackVersion.IS_4) {
- chunks = Array.from(module.chunksIterable);
- } else if (parseInt(webpackVersion(), 10) >= 3) {
- chunks = module.mapChunks();
- } else {
- chunks = module.chunks;
- }
-
- const issuer = typeof module.issuer === 'string'
- ? modules.find(m => m.request === module.issuer)
- : module.issuer;
- if (Array.isArray(chunks) && chunks.length > 0) {
- return chunks[chunks.length - 1];
- } else if (issuer) {
- return getModuleChunk(issuer, modules);
- }
- return null;
- }
- module.exports = getModuleChunk;
|