package-build-stats 7.3.3 → 7.3.8

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.
Files changed (34) hide show
  1. package/build/common.types.d.ts +31 -53
  2. package/build/common.types.js +2 -2
  3. package/build/config/config.d.ts +3 -3
  4. package/build/config/config.js +8 -10
  5. package/build/config/makeWebpackConfig.d.ts +10 -16
  6. package/build/config/makeWebpackConfig.js +214 -231
  7. package/build/errors/CustomError.d.ts +20 -18
  8. package/build/errors/CustomError.js +58 -51
  9. package/build/fixed/parseReference.js +5353 -0
  10. package/build/getDependencySizeTree.d.ts +6 -12
  11. package/build/getDependencySizeTree.js +224 -269
  12. package/build/getPackageExportSizes.d.ts +44 -63
  13. package/build/getPackageExportSizes.js +71 -116
  14. package/build/getPackageStats.d.ts +69 -91
  15. package/build/getPackageStats.js +79 -127
  16. package/build/getParseTime.d.ts +8 -13
  17. package/build/getParseTime.js +45 -57
  18. package/build/index.d.ts +5 -5
  19. package/build/index.js +24 -54
  20. package/build/utils/build.utils.d.ts +78 -121
  21. package/build/utils/build.utils.js +249 -337
  22. package/build/utils/common.utils.d.ts +13 -22
  23. package/build/utils/common.utils.js +93 -111
  24. package/build/utils/exports.utils.d.ts +8 -14
  25. package/build/utils/exports.utils.js +219 -253
  26. package/build/utils/installation.utils.d.ts +7 -11
  27. package/build/utils/installation.utils.js +119 -150
  28. package/build/utils/telemetry.utils.d.ts +13 -69
  29. package/build/utils/telemetry.utils.js +122 -169
  30. package/package.json +2 -2
  31. package/src/errors/CustomError.ts +8 -0
  32. package/src/getPackageStats.ts +9 -10
  33. package/src/config/.DS_Store +0 -0
  34. package/src/config/.temp_cache/.DS_Store +0 -0
@@ -1,56 +1,34 @@
1
- declare type Minifier = 'esbuild' | 'terser'
1
+ declare type Minifier = 'esbuild' | 'terser';
2
2
  declare type AllOptions = {
3
- customImports?: Array<string>
4
- splitCustomImports?: boolean
5
- debug?: boolean
6
- calcParse?: boolean
7
- esm?: boolean
8
- entryFilename?: string
9
- client?: 'npm' | 'yarn'
10
- limitConcurrency?: boolean
11
- networkConcurrency?: number
12
- additionalPackages?: Array<string>
13
- isLocal?: boolean
14
- installTimeout?: number
15
- }
16
- export declare type BuildPackageOptions = Pick<
17
- AllOptions,
18
- 'customImports' | 'splitCustomImports' | 'debug' | 'calcParse'
19
- > & {
20
- includeDependencySizes: boolean
21
- minifier: Minifier
22
- }
23
- export declare type CreateEntryPointOptions = Pick<
24
- AllOptions,
25
- 'esm' | 'customImports' | 'entryFilename'
26
- >
27
- export declare type InstallPackageOptions = Pick<
28
- AllOptions,
29
- | 'client'
30
- | 'limitConcurrency'
31
- | 'networkConcurrency'
32
- | 'additionalPackages'
33
- | 'isLocal'
34
- | 'installTimeout'
35
- >
36
- export declare type GetPackageStatsOptions = Pick<
37
- AllOptions,
38
- | 'client'
39
- | 'limitConcurrency'
40
- | 'networkConcurrency'
41
- | 'debug'
42
- | 'customImports'
43
- | 'installTimeout'
44
- > & {
45
- minifier?: Minifier
46
- }
3
+ customImports?: Array<string>;
4
+ splitCustomImports?: boolean;
5
+ debug?: boolean;
6
+ calcParse?: boolean;
7
+ esm?: boolean;
8
+ entryFilename?: string;
9
+ client?: 'npm' | 'yarn';
10
+ limitConcurrency?: boolean;
11
+ networkConcurrency?: number;
12
+ additionalPackages?: Array<string>;
13
+ isLocal?: boolean;
14
+ installTimeout?: number;
15
+ };
16
+ export declare type BuildPackageOptions = Pick<AllOptions, 'customImports' | 'splitCustomImports' | 'debug' | 'calcParse'> & {
17
+ includeDependencySizes: boolean;
18
+ minifier: Minifier;
19
+ };
20
+ export declare type CreateEntryPointOptions = Pick<AllOptions, 'esm' | 'customImports' | 'entryFilename'>;
21
+ export declare type InstallPackageOptions = Pick<AllOptions, 'client' | 'limitConcurrency' | 'networkConcurrency' | 'additionalPackages' | 'isLocal' | 'installTimeout'>;
22
+ export declare type GetPackageStatsOptions = Pick<AllOptions, 'client' | 'limitConcurrency' | 'networkConcurrency' | 'debug' | 'customImports' | 'installTimeout'> & {
23
+ minifier?: Minifier;
24
+ };
47
25
  export declare type Externals = {
48
- externalPackages: Array<string>
49
- externalBuiltIns: Array<string>
50
- }
26
+ externalPackages: Array<string>;
27
+ externalBuiltIns: Array<string>;
28
+ };
51
29
  export declare type WebpackError = {
52
- name: 'ModuleNotFoundError'
53
- details?: string
54
- error: Error
55
- }
56
- export {}
30
+ name: 'ModuleNotFoundError';
31
+ details?: string;
32
+ error: Error;
33
+ };
34
+ export {};
@@ -1,2 +1,2 @@
1
- 'use strict'
2
- Object.defineProperty(exports, '__esModule', { value: true })
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,4 @@
1
1
  declare const _default: {
2
- tmp: string
3
- }
4
- export default _default
2
+ tmp: string;
3
+ };
4
+ export default _default;
@@ -1,12 +1,10 @@
1
- 'use strict'
1
+ "use strict";
2
2
  // Use ES6 supported by Node v6.10 only!
3
- var __importDefault =
4
- (this && this.__importDefault) ||
5
- function (mod) {
6
- return mod && mod.__esModule ? mod : { default: mod }
7
- }
8
- Object.defineProperty(exports, '__esModule', { value: true })
9
- const path_1 = __importDefault(require('path'))
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const path_1 = __importDefault(require("path"));
10
8
  exports.default = {
11
- tmp: path_1.default.join('/tmp', 'tmp-build'),
12
- }
9
+ tmp: path_1.default.join('/tmp', 'tmp-build'),
10
+ };
@@ -1,17 +1,11 @@
1
- import webpack, { Entry } from 'webpack'
2
- import { Externals } from '../common.types'
1
+ import webpack, { Entry } from 'webpack';
2
+ import { Externals } from '../common.types';
3
3
  declare type MakeWebpackConfigOptions = {
4
- packageName: string
5
- externals: Externals
6
- debug?: boolean
7
- entry: string | string[] | Entry
8
- minifier: 'esbuild' | 'terser'
9
- }
10
- export default function makeWebpackConfig({
11
- packageName,
12
- entry,
13
- externals,
14
- debug,
15
- minifier,
16
- }: MakeWebpackConfigOptions): webpack.Configuration
17
- export {}
4
+ packageName: string;
5
+ externals: Externals;
6
+ debug?: boolean;
7
+ entry: string | string[] | Entry;
8
+ minifier: 'esbuild' | 'terser';
9
+ };
10
+ export default function makeWebpackConfig({ packageName, entry, externals, debug, minifier, }: MakeWebpackConfigOptions): webpack.Configuration;
11
+ export {};
@@ -1,242 +1,225 @@
1
- 'use strict'
2
- var __importDefault =
3
- (this && this.__importDefault) ||
4
- function (mod) {
5
- return mod && mod.__esModule ? mod : { default: mod }
6
- }
7
- Object.defineProperty(exports, '__esModule', { value: true })
8
- const autoprefixer_1 = __importDefault(require('autoprefixer'))
9
- const terser_webpack_plugin_1 = __importDefault(
10
- require('terser-webpack-plugin')
11
- )
12
- const mini_css_extract_plugin_1 = __importDefault(
13
- require('mini-css-extract-plugin')
14
- )
15
- const csso_webpack_plugin_1 = __importDefault(require('csso-webpack-plugin'))
16
- const write_file_webpack_plugin_1 = __importDefault(
17
- require('write-file-webpack-plugin')
18
- )
19
- const log = require('debug')('bp:webpack')
20
- const escape_string_regexp_1 = __importDefault(require('escape-string-regexp'))
21
- const builtin_modules_1 = __importDefault(require('builtin-modules'))
22
- const webpack_1 = __importDefault(require('webpack'))
23
- const esbuild_loader_1 = require('esbuild-loader')
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const autoprefixer_1 = __importDefault(require("autoprefixer"));
7
+ const terser_webpack_plugin_1 = __importDefault(require("terser-webpack-plugin"));
8
+ const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
9
+ const csso_webpack_plugin_1 = __importDefault(require("csso-webpack-plugin"));
10
+ const write_file_webpack_plugin_1 = __importDefault(require("write-file-webpack-plugin"));
11
+ const log = require('debug')('bp:webpack');
12
+ const escape_string_regexp_1 = __importDefault(require("escape-string-regexp"));
13
+ const builtin_modules_1 = __importDefault(require("builtin-modules"));
14
+ const webpack_1 = __importDefault(require("webpack"));
15
+ const esbuild_loader_1 = require("esbuild-loader");
24
16
  // @ts-ignore
25
- const plugin_1 = __importDefault(require('vue-loader/lib/plugin'))
26
- function makeWebpackConfig({ packageName, entry, externals, debug, minifier }) {
27
- const externalsRegex = makeExternalsRegex(externals.externalPackages)
28
- const isExternalRequest = request => {
29
- const isPeerDep = externals.externalPackages.length
30
- ? externalsRegex.test(request)
31
- : false
32
- const isBuiltIn = externals.externalBuiltIns.includes(request)
33
- return isPeerDep || isBuiltIn
34
- }
35
- log('external packages %o', externalsRegex)
36
- const builtInNode = {}
37
- builtin_modules_1.default.forEach(mod => {
38
- builtInNode[mod] = 'empty'
39
- })
40
- builtInNode['setImmediate'] = false
41
- builtInNode['console'] = false
42
- builtInNode['process'] = false
43
- builtInNode['Buffer'] = false
44
- // Don't mark an import as built in if it is the name of the package itself
45
- // eg. `events`
46
- if (builtInNode[packageName]) {
47
- builtInNode[packageName] = false
48
- }
49
- // @ts-ignore
50
- // @ts-ignore
51
- // @ts-ignore
52
- return {
53
- entry: entry,
54
- mode: 'production',
55
- // bail: true,
56
- optimization: {
57
- namedChunks: true,
58
- runtimeChunk: { name: 'runtime' },
59
- minimize: true,
60
- splitChunks: {
61
- cacheGroups: {
62
- styles: {
63
- name: 'main',
64
- test: /\.css$/,
65
- chunks: 'all',
66
- enforce: true,
67
- },
68
- },
69
- },
70
- // @ts-ignore: Appears that the library CssoWebpackPlugin might have incorrect definitions
71
- minimizer: [
72
- ...(minifier === 'terser'
73
- ? [
74
- new terser_webpack_plugin_1.default({
75
- parallel: true,
76
- terserOptions: {
77
- ie8: false,
78
- output: {
79
- comments: false,
80
- },
17
+ const plugin_1 = __importDefault(require("vue-loader/lib/plugin"));
18
+ function makeWebpackConfig({ packageName, entry, externals, debug, minifier, }) {
19
+ const externalsRegex = makeExternalsRegex(externals.externalPackages);
20
+ const isExternalRequest = (request) => {
21
+ const isPeerDep = externals.externalPackages.length
22
+ ? externalsRegex.test(request)
23
+ : false;
24
+ const isBuiltIn = externals.externalBuiltIns.includes(request);
25
+ return isPeerDep || isBuiltIn;
26
+ };
27
+ log('external packages %o', externalsRegex);
28
+ const builtInNode = {};
29
+ builtin_modules_1.default.forEach(mod => {
30
+ builtInNode[mod] = 'empty';
31
+ });
32
+ builtInNode['setImmediate'] = false;
33
+ builtInNode['console'] = false;
34
+ builtInNode['process'] = false;
35
+ builtInNode['Buffer'] = false;
36
+ // Don't mark an import as built in if it is the name of the package itself
37
+ // eg. `events`
38
+ if (builtInNode[packageName]) {
39
+ builtInNode[packageName] = false;
40
+ }
41
+ // @ts-ignore
42
+ // @ts-ignore
43
+ // @ts-ignore
44
+ return {
45
+ entry: entry,
46
+ mode: 'production',
47
+ // bail: true,
48
+ optimization: {
49
+ namedChunks: true,
50
+ runtimeChunk: { name: 'runtime' },
51
+ minimize: true,
52
+ splitChunks: {
53
+ cacheGroups: {
54
+ styles: {
55
+ name: 'main',
56
+ test: /\.css$/,
57
+ chunks: 'all',
58
+ enforce: true,
59
+ },
81
60
  },
82
- }),
83
- ]
84
- : [
85
- new esbuild_loader_1.ESBuildMinifyPlugin({
86
- target: 'esnext',
87
- }),
88
- ]),
89
- new csso_webpack_plugin_1.default({ restructure: false }),
90
- ],
91
- },
92
- plugins: [
93
- new webpack_1.default.IgnorePlugin(/^electron$/),
94
- new plugin_1.default(),
95
- new mini_css_extract_plugin_1.default({
96
- // Options similar to the same options in webpackOptions.output
97
- // both options are optional
98
- filename: '[name].bundle.css',
99
- chunkFilename: '[id].bundle.css',
100
- }),
101
- ...(debug ? [new write_file_webpack_plugin_1.default()] : []),
102
- ],
103
- resolve: {
104
- modules: ['node_modules'],
105
- cacheWithContext: false,
106
- extensions: [
107
- '.web.mjs',
108
- '.mjs',
109
- '.web.js',
110
- '.js',
111
- '.mjs',
112
- '.json',
113
- '.css',
114
- '.sass',
115
- '.scss',
116
- ],
117
- mainFields: ['browser', 'module', 'main', 'style'],
118
- },
119
- module: {
120
- rules: [
121
- {
122
- test: /\.css$/,
123
- use: [
124
- mini_css_extract_plugin_1.default.loader,
125
- require.resolve('css-loader'),
126
- ],
127
- },
128
- // see https://github.com/apollographql/react-apollo/issues/1737
129
- {
130
- type: 'javascript/auto',
131
- test: /\.mjs$/,
132
- use: [],
133
- },
134
- {
135
- test: /\.js$/,
136
- loader: [
137
- // support CLI tools that start with a #!/usr/bin/node
138
- require.resolve('shebang-loader'),
139
- // ESBuild Minifier doesn't auto-remove license comments from code
140
- // So, we break ESBuild's heuristic for license comments match. See github.com/privatenumber/esbuild-loader/issues/87
141
- {
142
- loader: require.resolve('string-replace-loader'),
143
- options: {
144
- multiple: [
145
- { search: '@license', replace: '@silence' },
146
- { search: /\/\/!/g, replace: '//' },
147
- { search: /\/\*!/g, replace: '/*' },
148
- ],
149
- },
150
- },
151
- ],
152
- },
153
- {
154
- test: /\.(html|svelte)$/,
155
- use: {
156
- loader: require.resolve('svelte-loader'),
157
- options: {
158
- emitCss: true,
159
61
  },
160
- },
62
+ // @ts-ignore: Appears that the library CssoWebpackPlugin might have incorrect definitions
63
+ minimizer: [
64
+ ...(minifier === 'terser'
65
+ ? [
66
+ new terser_webpack_plugin_1.default({
67
+ parallel: true,
68
+ terserOptions: {
69
+ ie8: false,
70
+ output: {
71
+ comments: false,
72
+ },
73
+ },
74
+ }),
75
+ ]
76
+ : [
77
+ new esbuild_loader_1.ESBuildMinifyPlugin({
78
+ target: 'esnext',
79
+ }),
80
+ ]),
81
+ new csso_webpack_plugin_1.default({ restructure: false }),
82
+ ],
161
83
  },
162
- {
163
- test: /\.vue$/,
164
- loader: require.resolve('vue-loader'),
84
+ plugins: [
85
+ new webpack_1.default.IgnorePlugin(/^electron$/),
86
+ new plugin_1.default(),
87
+ new mini_css_extract_plugin_1.default({
88
+ // Options similar to the same options in webpackOptions.output
89
+ // both options are optional
90
+ filename: '[name].bundle.css',
91
+ chunkFilename: '[id].bundle.css',
92
+ }),
93
+ ...(debug ? [new write_file_webpack_plugin_1.default()] : []),
94
+ ],
95
+ resolve: {
96
+ modules: ['node_modules'],
97
+ cacheWithContext: false,
98
+ extensions: [
99
+ '.web.mjs',
100
+ '.mjs',
101
+ '.web.js',
102
+ '.js',
103
+ '.mjs',
104
+ '.json',
105
+ '.css',
106
+ '.sass',
107
+ '.scss',
108
+ ],
109
+ mainFields: ['browser', 'module', 'main', 'style'],
165
110
  },
166
- {
167
- test: /\.(scss|sass)$/,
168
- loader: [
169
- mini_css_extract_plugin_1.default.loader,
170
- require.resolve('css-loader'),
171
- {
172
- loader: require.resolve('postcss-loader'),
173
- options: {
174
- plugins: () => [autoprefixer_1.default()],
175
- },
176
- },
177
- require.resolve('sass-loader'),
178
- ],
179
- },
180
- {
181
- test: /\.less$/,
182
- loader: [
183
- mini_css_extract_plugin_1.default.loader,
184
- require.resolve('css-loader'),
185
- {
186
- loader: require.resolve('postcss-loader'),
187
- options: {
188
- plugins: () => [
189
- autoprefixer_1.default({
190
- browsers: [
191
- 'last 5 Chrome versions',
192
- 'last 5 Firefox versions',
193
- 'Safari >= 8',
194
- 'Explorer >= 10',
195
- 'edge >= 12',
111
+ module: {
112
+ rules: [
113
+ {
114
+ test: /\.css$/,
115
+ use: [mini_css_extract_plugin_1.default.loader, require.resolve('css-loader')],
116
+ },
117
+ // see https://github.com/apollographql/react-apollo/issues/1737
118
+ {
119
+ type: 'javascript/auto',
120
+ test: /\.mjs$/,
121
+ use: [],
122
+ },
123
+ {
124
+ test: /\.js$/,
125
+ loader: [
126
+ // support CLI tools that start with a #!/usr/bin/node
127
+ require.resolve('shebang-loader'),
128
+ // ESBuild Minifier doesn't auto-remove license comments from code
129
+ // So, we break ESBuild's heuristic for license comments match. See github.com/privatenumber/esbuild-loader/issues/87
130
+ {
131
+ loader: require.resolve('string-replace-loader'),
132
+ options: {
133
+ multiple: [
134
+ { search: '@license', replace: '@silence' },
135
+ { search: /\/\/!/g, replace: '//' },
136
+ { search: /\/\*!/g, replace: '/*' },
137
+ ],
138
+ },
139
+ },
196
140
  ],
197
- }),
198
- ],
199
- },
200
- },
201
- {
202
- loader: require.resolve('less-loader'),
203
- options: {
204
- webpackImporter: true,
205
- },
206
- },
207
- ],
141
+ },
142
+ {
143
+ test: /\.(html|svelte)$/,
144
+ use: {
145
+ loader: require.resolve('svelte-loader'),
146
+ options: {
147
+ emitCss: true,
148
+ },
149
+ },
150
+ },
151
+ {
152
+ test: /\.vue$/,
153
+ loader: require.resolve('vue-loader'),
154
+ },
155
+ {
156
+ test: /\.(scss|sass)$/,
157
+ loader: [
158
+ mini_css_extract_plugin_1.default.loader,
159
+ require.resolve('css-loader'),
160
+ {
161
+ loader: require.resolve('postcss-loader'),
162
+ options: {
163
+ plugins: () => [autoprefixer_1.default()],
164
+ },
165
+ },
166
+ require.resolve('sass-loader'),
167
+ ],
168
+ },
169
+ {
170
+ test: /\.less$/,
171
+ loader: [
172
+ mini_css_extract_plugin_1.default.loader,
173
+ require.resolve('css-loader'),
174
+ {
175
+ loader: require.resolve('postcss-loader'),
176
+ options: {
177
+ plugins: () => [
178
+ autoprefixer_1.default({
179
+ browsers: [
180
+ 'last 5 Chrome versions',
181
+ 'last 5 Firefox versions',
182
+ 'Safari >= 8',
183
+ 'Explorer >= 10',
184
+ 'edge >= 12',
185
+ ],
186
+ }),
187
+ ],
188
+ },
189
+ },
190
+ {
191
+ loader: require.resolve('less-loader'),
192
+ options: {
193
+ webpackImporter: true,
194
+ },
195
+ },
196
+ ],
197
+ },
198
+ {
199
+ test: /\.(woff|woff2|eot|ttf|svg|png|jpeg|jpg|gif|webp)$/,
200
+ loader: require.resolve('file-loader'),
201
+ options: {
202
+ name: '[name].bundle.[ext]',
203
+ emitFile: true,
204
+ },
205
+ },
206
+ ],
208
207
  },
209
- {
210
- test: /\.(woff|woff2|eot|ttf|svg|png|jpeg|jpg|gif|webp)$/,
211
- loader: require.resolve('file-loader'),
212
- options: {
213
- name: '[name].bundle.[ext]',
214
- emitFile: true,
215
- },
208
+ node: builtInNode,
209
+ output: {
210
+ filename: 'bundle.js',
211
+ pathinfo: false,
216
212
  },
217
- ],
218
- },
219
- node: builtInNode,
220
- output: {
221
- filename: 'bundle.js',
222
- pathinfo: false,
223
- },
224
- externals: (context, request, callback) =>
225
- isExternalRequest(request)
226
- ? callback(null, 'commonjs ' + request)
227
- : callback(),
228
- }
213
+ externals: (context, request, callback) => isExternalRequest(request)
214
+ ? callback(null, 'commonjs ' + request)
215
+ : callback(),
216
+ };
229
217
  }
230
- exports.default = makeWebpackConfig
218
+ exports.default = makeWebpackConfig;
231
219
  function makeExternalsRegex(externals) {
232
- let externalsRegex = externals
233
- .map(
234
- dep =>
235
- `^${escape_string_regexp_1.default(
236
- dep
237
- )}$|^${escape_string_regexp_1.default(dep)}\\/`
238
- )
239
- .join('|')
240
- externalsRegex = `(${externalsRegex})`
241
- return new RegExp(externalsRegex)
220
+ let externalsRegex = externals
221
+ .map(dep => `^${escape_string_regexp_1.default(dep)}$|^${escape_string_regexp_1.default(dep)}\\/`)
222
+ .join('|');
223
+ externalsRegex = `(${externalsRegex})`;
224
+ return new RegExp(externalsRegex);
242
225
  }