Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module issuer path #2959

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/plugin-webpack-filter/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,21 @@ export interface WebpackStatsFilteredChunk {
names?: Array<string>;
}

export interface WebpackStatsFilteredModuleIssuer {
name: string;
}

export interface WebpackStatsFilteredModule {
name: string;
size?: number;
chunks: Array<string | number>;
issuerPath?: Array<WebpackStatsFilteredModuleIssuer>;
}

export interface WebpackStatsFilteredConcatenatedModule {
name: string;
size?: number;
issuer?: string;
}

export interface WebpackStatsFilteredRootModule extends WebpackStatsFilteredModule {
Expand Down Expand Up @@ -117,10 +123,21 @@ export default (
[] as Array<WebpackStatsFilteredConcatenatedModule>,
);

const issuerPath: Array<WebpackStatsFilteredModuleIssuer> = [];

moduleStats.issuerPath?.forEach((issuer) => {
if (issuer?.name) {
issuerPath.push({
name: issuer.name,
});
}
});

agg.push({
name: moduleStats.name,
size: moduleStats.size,
chunks: moduleChunks,
issuerPath,
...(concatenatedModules && { modules: concatenatedModules }),
});

Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-webpack-validate/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ describe('Webpack/validate', () => {
name: 'node_modules/package-a/main.js',
size: 10,
chunks: [1],
issuerPath: [
{
name: './index.js',
},
],
},
{
type: 'hidden modules',
Expand All @@ -40,6 +45,7 @@ describe('Webpack/validate', () => {
name: './main.js + 2 concantenated modules',
size: 10,
chunks: [1],
issuerPath: [{ name: './index.js' }],
modules: [
{
name: './main.js',
Expand Down
1 change: 1 addition & 0 deletions packages/plugin-webpack-validate/src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const WebpackSourceModuleStruct = type({
size: number(),
chunks: array(nullable(union([number(), string()]))),
modules: optional(array(type({ name: string(), size: number() }))),
issuerPath: nullable(array(type({ name: optional(string()) }))),
});

export const WebpackSourceModuleHiddenStruct = type({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ const RowHeader = ({ row, chunks, labels, CustomComponentLink }) => {
}

return (
<HoverCard label={content}>
<HoverCard label={content} hoverCardClassName={css.hoverCard}>
<ModuleInfo
className={css.namePopover}
item={row}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@
display: inline;
vertical-align: middle;
}

.hoverCard {
max-width: 480px;
}
13 changes: 12 additions & 1 deletion packages/ui/src/components/module-info/module-info.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,18 @@ export const ModuleInfo = (props) => {
</div>
)}

<FileName className={css.fileName} as="code" name={run?.name || '-'} />
<p>Name: <FileName className={css.fileName} as="code" name={run?.name || '-'} /></p>

{run?.issuerPath && (
<Stack>
<p>Issuer path:</p>
{run?.issuerPath?.map((issuer) => (
<p className={css.issuer} key={issuer}>
<FileName className={css.fileName} as="code" name={issuer} />
</p>
))}
</Stack>
)}
</Stack>
);
})}
Expand Down
4 changes: 4 additions & 0 deletions packages/utils/__fixtures__/webpack-stats-1.extracted.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,25 @@ module.exports = {
chunks: [1],
name: 'node_modules/package-a/index.js',
size: 1000,
issuerPath: [{ name: 'module-a' }],
},
{
chunks: [1],
name: 'node_modules/package-a/node_modules/package-c/index.js',
size: 1000,
issuerPath: [{ name: 'module-a' }, { name: 'node_modules/package-a/index.js' }],
},
{
chunks: [1],
name: 'node_modules/package-b/index.js',
size: 1000,
issuerPath: [{ name: 'module-b' }],
},
{
chunks: [1],
name: 'node_modules/package-c/index.js',
size: 1000,
issuerPath: [{ name: 'module-c' }],
},
],
};
12 changes: 12 additions & 0 deletions packages/utils/src/jobs/__tests__/__snapshots__/create-job.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ exports[`createJob no baseline 1`] = `
"1",
],
"duplicated": false,
"issuerPath": undefined,
"name": "module-a",
"value": 1000,
},
Expand All @@ -112,6 +113,7 @@ exports[`createJob no baseline 1`] = `
"1",
],
"duplicated": false,
"issuerPath": undefined,
"name": "module-b",
"value": 2000,
},
Expand All @@ -120,6 +122,7 @@ exports[`createJob no baseline 1`] = `
"1",
],
"duplicated": false,
"issuerPath": undefined,
"name": "node_modules/package-a/index.js",
"value": 1000,
},
Expand All @@ -128,6 +131,7 @@ exports[`createJob no baseline 1`] = `
"1",
],
"duplicated": false,
"issuerPath": undefined,
"name": "node_modules/package-a/node_modules/package-c/index.js",
"value": 1000,
},
Expand All @@ -136,6 +140,7 @@ exports[`createJob no baseline 1`] = `
"1",
],
"duplicated": false,
"issuerPath": undefined,
"name": "node_modules/package-b/index.js",
"value": 1000,
},
Expand All @@ -144,6 +149,7 @@ exports[`createJob no baseline 1`] = `
"1",
],
"duplicated": false,
"issuerPath": undefined,
"name": "node_modules/package-c/index.js",
"value": 1000,
},
Expand Down Expand Up @@ -449,6 +455,7 @@ exports[`createJob with baseline 1`] = `
"1",
],
"duplicated": false,
"issuerPath": undefined,
"name": "module-a",
"value": 1000,
},
Expand All @@ -457,6 +464,7 @@ exports[`createJob with baseline 1`] = `
"1",
],
"duplicated": false,
"issuerPath": undefined,
"name": "module-b",
"value": 2000,
},
Expand All @@ -465,6 +473,7 @@ exports[`createJob with baseline 1`] = `
"1",
],
"duplicated": false,
"issuerPath": undefined,
"name": "node_modules/package-a/index.js",
"value": 1000,
},
Expand All @@ -473,6 +482,7 @@ exports[`createJob with baseline 1`] = `
"1",
],
"duplicated": false,
"issuerPath": undefined,
"name": "node_modules/package-a/node_modules/package-c/index.js",
"value": 1000,
},
Expand All @@ -481,6 +491,7 @@ exports[`createJob with baseline 1`] = `
"1",
],
"duplicated": false,
"issuerPath": undefined,
"name": "node_modules/package-b/index.js",
"value": 1000,
},
Expand All @@ -489,6 +500,7 @@ exports[`createJob with baseline 1`] = `
"1",
],
"duplicated": false,
"issuerPath": undefined,
"name": "node_modules/package-c/index.js",
"value": 1000,
},
Expand Down
17 changes: 17 additions & 0 deletions packages/utils/src/report/__tests__/__snapshots__/create.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ exports[`report / createReport multiple sources 1`] = `
"displayDeltaPercentage": "0%",
"displayValue": "1000B",
"duplicated": false,
"issuerPath": undefined,
"name": "module-a",
"value": 1000,
},
Expand All @@ -181,6 +182,7 @@ exports[`report / createReport multiple sources 1`] = `
],
"displayValue": "1000B",
"duplicated": false,
"issuerPath": undefined,
"name": "module-a",
"value": 1000,
},
Expand All @@ -203,6 +205,7 @@ exports[`report / createReport multiple sources 1`] = `
"displayDeltaPercentage": "+33.33%",
"displayValue": "1.95KiB",
"duplicated": false,
"issuerPath": undefined,
"name": "module-b",
"value": 2000,
},
Expand All @@ -212,6 +215,7 @@ exports[`report / createReport multiple sources 1`] = `
],
"displayValue": "1.46KiB",
"duplicated": false,
"issuerPath": undefined,
"name": "module-b",
"value": 1500,
},
Expand All @@ -234,6 +238,7 @@ exports[`report / createReport multiple sources 1`] = `
"displayDeltaPercentage": "0%",
"displayValue": "1000B",
"duplicated": false,
"issuerPath": undefined,
"name": "node_modules/package-a/index.js",
"value": 1000,
},
Expand All @@ -243,6 +248,7 @@ exports[`report / createReport multiple sources 1`] = `
],
"displayValue": "1000B",
"duplicated": false,
"issuerPath": undefined,
"name": "node_modules/package-a/index.js",
"value": 1000,
},
Expand All @@ -265,6 +271,7 @@ exports[`report / createReport multiple sources 1`] = `
"displayDeltaPercentage": "+100%",
"displayValue": "1000B",
"duplicated": false,
"issuerPath": undefined,
"name": "node_modules/package-a/node_modules/package-c/index.js",
"value": 1000,
},
Expand All @@ -288,6 +295,7 @@ exports[`report / createReport multiple sources 1`] = `
"displayDeltaPercentage": "0%",
"displayValue": "1000B",
"duplicated": false,
"issuerPath": undefined,
"name": "node_modules/package-b/index.js",
"value": 1000,
},
Expand All @@ -297,6 +305,7 @@ exports[`report / createReport multiple sources 1`] = `
],
"displayValue": "1000B",
"duplicated": false,
"issuerPath": undefined,
"name": "node_modules/package-b/index.js",
"value": 1000,
},
Expand All @@ -319,6 +328,7 @@ exports[`report / createReport multiple sources 1`] = `
"displayDeltaPercentage": "0%",
"displayValue": "1000B",
"duplicated": false,
"issuerPath": undefined,
"name": "node_modules/package-c/index.js",
"value": 1000,
},
Expand All @@ -328,6 +338,7 @@ exports[`report / createReport multiple sources 1`] = `
],
"displayValue": "1000B",
"duplicated": false,
"issuerPath": undefined,
"name": "node_modules/package-c/index.js",
"value": 1000,
},
Expand Down Expand Up @@ -1071,6 +1082,7 @@ exports[`report / createReport single source 1`] = `
],
"displayValue": "1000B",
"duplicated": false,
"issuerPath": undefined,
"name": "module-a",
"value": 1000,
},
Expand All @@ -1088,6 +1100,7 @@ exports[`report / createReport single source 1`] = `
],
"displayValue": "1.95KiB",
"duplicated": false,
"issuerPath": undefined,
"name": "module-b",
"value": 2000,
},
Expand All @@ -1105,6 +1118,7 @@ exports[`report / createReport single source 1`] = `
],
"displayValue": "1000B",
"duplicated": false,
"issuerPath": undefined,
"name": "node_modules/package-a/index.js",
"value": 1000,
},
Expand All @@ -1122,6 +1136,7 @@ exports[`report / createReport single source 1`] = `
],
"displayValue": "1000B",
"duplicated": false,
"issuerPath": undefined,
"name": "node_modules/package-a/node_modules/package-c/index.js",
"value": 1000,
},
Expand All @@ -1139,6 +1154,7 @@ exports[`report / createReport single source 1`] = `
],
"displayValue": "1000B",
"duplicated": false,
"issuerPath": undefined,
"name": "node_modules/package-b/index.js",
"value": 1000,
},
Expand All @@ -1156,6 +1172,7 @@ exports[`report / createReport single source 1`] = `
],
"displayValue": "1000B",
"duplicated": false,
"issuerPath": undefined,
"name": "node_modules/package-c/index.js",
"value": 1000,
},
Expand Down
Loading