@bundle-stats/plugin-webpack-filter 4.7.4 → 4.7.5-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bundle-stats/plugin-webpack-filter",
3
- "version": "4.7.4",
3
+ "version": "4.7.5-beta.0",
4
4
  "description": "BundleStats webpack filter plugin",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-esm/index.js",
@@ -40,7 +40,7 @@
40
40
  "devDependencies": {
41
41
  "@types/jest": "29.5.5",
42
42
  "@types/webpack": "5.28.3",
43
- "core-js": "3.32.2",
43
+ "core-js": "3.33.0",
44
44
  "jest": "29.7.0",
45
45
  "jest-cli": "29.7.0",
46
46
  "jest-date-mock": "1.0.8",
@@ -52,5 +52,5 @@
52
52
  "peerDependencies": {
53
53
  "core-js": "^3.0.0"
54
54
  },
55
- "gitHead": "77f3d18c64e1eee75fac27cf26e6b59be152447a"
55
+ "gitHead": "ed4abfb7ca2f146c978030d975a722077b738927"
56
56
  }
package/CHANGELOG.md DELETED
@@ -1,75 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [3.2.8](https://github.com/relative-ci/bundle-stats/compare/v3.2.7...v3.2.8) (2022-03-10)
7
-
8
- **Note:** Version bump only for package @bundle-stats/plugin-webpack-filter
9
-
10
-
11
-
12
-
13
-
14
- ## [3.2.6](https://github.com/relative-ci/bundle-stats/compare/v3.2.5...v3.2.6) (2022-03-04)
15
-
16
- **Note:** Version bump only for package @bundle-stats/plugin-webpack-filter
17
-
18
-
19
-
20
-
21
-
22
- ## [3.2.5](https://github.com/relative-ci/bundle-stats/compare/v3.2.4...v3.2.5) (2022-02-15)
23
-
24
- **Note:** Version bump only for package @bundle-stats/plugin-webpack-filter
25
-
26
-
27
-
28
-
29
-
30
- ## [3.2.4](https://github.com/relative-ci/bundle-stats/compare/v3.2.3...v3.2.4) (2022-01-17)
31
-
32
- **Note:** Version bump only for package @bundle-stats/plugin-webpack-filter
33
-
34
-
35
-
36
-
37
-
38
- ## [3.2.3](https://github.com/relative-ci/bundle-stats/compare/v3.2.2...v3.2.3) (2022-01-10)
39
-
40
- **Note:** Version bump only for package @bundle-stats/plugin-webpack-filter
41
-
42
-
43
-
44
-
45
-
46
- ## [3.2.2](https://github.com/relative-ci/bundle-stats/compare/v3.2.1...v3.2.2) (2021-12-08)
47
-
48
- **Note:** Version bump only for package @bundle-stats/plugin-webpack-filter
49
-
50
-
51
-
52
-
53
-
54
- ## [3.2.1](https://github.com/relative-ci/bundle-stats/compare/v3.2.0...v3.2.1) (2021-11-23)
55
-
56
- **Note:** Version bump only for package @bundle-stats/plugin-webpack-filter
57
-
58
-
59
-
60
-
61
-
62
- # [3.2.0](https://github.com/relative-ci/bundle-stats/compare/v3.1.3...v3.2.0) (2021-10-13)
63
-
64
-
65
- ### Bug Fixes
66
-
67
- * Consistent dependency versions across packages ([cceebb7](https://github.com/relative-ci/bundle-stats/commit/cceebb7724670a7c40c156c395449fc65d183690))
68
-
69
-
70
-
71
-
72
-
73
- # [3.1.0](https://github.com/relative-ci/bundle-stats/compare/v3.0.1...v3.1.0) (2021-07-28)
74
-
75
- **Note:** Version bump only for package @bundle-stats/plugin-webpack-filter
package/src/index.test.ts DELETED
@@ -1,33 +0,0 @@
1
- import filter from './index';
2
-
3
- /* eslint-disable import/no-relative-packages */
4
- import webpackStats from '../../utils/__fixtures__/webpack-stats-1';
5
- import webpackStatsExtracted from '../../utils/__fixtures__/webpack-stats-1.extracted';
6
- import webpackStatsConcatenatedModules from '../../utils/__fixtures__/webpack-stats-3';
7
- import webpackStatsConcatenatedModulesExtracted from '../../utils/__fixtures__/webpack-stats-3.extracted';
8
- /* eslint-enable import/no-relative-packages */
9
-
10
- describe('Webpack filter', () => {
11
- test('should return empty meta', () => {
12
- const actual = filter({
13
- ...webpackStats,
14
- builtAt: undefined,
15
- hash: undefined,
16
- } as any);
17
- expect({
18
- ...webpackStatsExtracted,
19
- builtAt: undefined,
20
- hash: undefined,
21
- }).toEqual(actual);
22
- });
23
-
24
- test('should return meta', () => {
25
- const actual = filter(webpackStats as any);
26
- expect(actual).toEqual(webpackStatsExtracted);
27
- });
28
-
29
- test('should filter concatenated modules', () => {
30
- const actual = filter(webpackStatsConcatenatedModules as any);
31
- expect(actual).toEqual(webpackStatsConcatenatedModulesExtracted);
32
- });
33
- });
package/src/index.ts DELETED
@@ -1,137 +0,0 @@
1
- // eslint-disable-next-line import/no-extraneous-dependencies
2
- import { StatsCompilation } from 'webpack';
3
-
4
- const PATH_IGNORE_PATTERN = '.map$';
5
-
6
- interface BundleStatsOptions {
7
- pathIgnorePattern?: string;
8
- }
9
-
10
- export interface WebpackStatsFilteredAsset {
11
- name: string;
12
- size?: number;
13
- }
14
-
15
- export interface WebpackStatsFilteredChunk {
16
- entry: boolean;
17
- id: number | string;
18
- initial: boolean;
19
- files?: Array<string>;
20
- names?: Array<string>;
21
- }
22
-
23
- export interface WebpackStatsFilteredModule {
24
- name: string;
25
- size?: number;
26
- chunks: Array<string | number>;
27
- }
28
-
29
- export interface WebpackStatsFilteredConcatenatedModule {
30
- name: string;
31
- size?: number;
32
- }
33
-
34
- export interface WebpackStatsFilteredRootModule extends WebpackStatsFilteredModule {
35
- modules?: Array<WebpackStatsFilteredConcatenatedModule>;
36
- }
37
-
38
- export interface WebpackStatsFiltered {
39
- builtAt?: number;
40
- hash?: string;
41
- assets?: Array<WebpackStatsFilteredAsset>;
42
- chunks?: Array<WebpackStatsFilteredChunk>;
43
- modules?: Array<WebpackStatsFilteredRootModule>;
44
- }
45
-
46
- /**
47
- * Filter webpack stats data
48
- */
49
- export default (
50
- source: StatsCompilation,
51
- options: BundleStatsOptions = {},
52
- ): WebpackStatsFiltered => {
53
- const pathIgnorePattern = new RegExp(options.pathIgnorePattern || PATH_IGNORE_PATTERN);
54
-
55
- // meta
56
- const { builtAt, hash } = source;
57
-
58
- // rawData
59
- const assets =
60
- source.assets?.reduce((agg, asset) => {
61
- // Skip assets with empty name or ignore pattern
62
- if (!asset.name || pathIgnorePattern.test(asset.name)) {
63
- return agg;
64
- }
65
-
66
- agg.push({
67
- name: asset.name,
68
- size: asset.size,
69
- });
70
-
71
- return agg;
72
- }, [] as Array<WebpackStatsFilteredAsset>) || [];
73
-
74
- const chunks =
75
- source.chunks?.reduce((agg, chunk) => {
76
- // Skip chunks with empty ids
77
- if (typeof chunk.id === 'undefined' || chunk.id === null) {
78
- return agg;
79
- }
80
-
81
- agg.push({
82
- id: chunk.id,
83
- entry: chunk.entry,
84
- initial: chunk.initial,
85
- files: chunk.files,
86
- names: chunk.names,
87
- });
88
-
89
- return agg;
90
- }, [] as Array<WebpackStatsFilteredChunk>) || [];
91
-
92
- const modules =
93
- source.modules?.reduce((agg, moduleStats) => {
94
- // Skip modules without name
95
- if (!moduleStats.name) {
96
- return agg;
97
- }
98
-
99
- const moduleChunks =
100
- moduleStats.chunks?.filter(
101
- (chunkId) => chunkId !== null && typeof chunkId !== 'undefined',
102
- ) || [];
103
-
104
- const concatenatedModules = moduleStats.modules?.reduce(
105
- (aggConcatenatedModules, concatenatedModule) => {
106
- if (!concatenatedModule.name) {
107
- return aggConcatenatedModules;
108
- }
109
-
110
- aggConcatenatedModules.push({
111
- name: concatenatedModule.name,
112
- size: concatenatedModule.size,
113
- });
114
-
115
- return aggConcatenatedModules;
116
- },
117
- [] as Array<WebpackStatsFilteredConcatenatedModule>,
118
- );
119
-
120
- agg.push({
121
- name: moduleStats.name,
122
- size: moduleStats.size,
123
- chunks: moduleChunks,
124
- ...(concatenatedModules && { modules: concatenatedModules }),
125
- });
126
-
127
- return agg;
128
- }, [] as Array<WebpackStatsFilteredRootModule>) || [];
129
-
130
- return {
131
- builtAt,
132
- hash,
133
- assets,
134
- chunks,
135
- modules,
136
- };
137
- };