package-build-stats 7.3.2 → 7.3.7

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": "package-build-stats",
3
- "version": "7.3.2",
3
+ "version": "7.3.7",
4
4
  "author": "Shubham Kanodia <shubham.kanodia10@gmail.com>",
5
5
  "repository": "https://github.com/pastelsky/package-build-stats",
6
6
  "publishConfig": {
@@ -102,7 +102,7 @@
102
102
  "svelte-loader": "^2.13.6",
103
103
  "terser": "^5.6.0",
104
104
  "terser-webpack-plugin": "^4.2.3",
105
- "vm2": "^3.9.1",
105
+ "vm2": "^3.9.7",
106
106
  "vue-loader": "^15.9.3",
107
107
  "vue-template-compiler": "^2.6.12",
108
108
  "webpack": "^4.44.2",
@@ -13,6 +13,14 @@ class CustomError extends Error {
13
13
  this.extra = extra
14
14
  Object.setPrototypeOf(this, CustomError.prototype)
15
15
  }
16
+
17
+ toJSON() {
18
+ return {
19
+ name: this.name,
20
+ originalError: this.originalError,
21
+ extra: this.extra,
22
+ }
23
+ }
16
24
  }
17
25
 
18
26
  export class BuildError extends CustomError {
@@ -66,17 +66,16 @@ export default async function getPackageStats(
66
66
  if (options.debug) {
67
67
  console.log('Install path:', installPath)
68
68
  }
69
-
70
- await InstallationUtils.installPackage(packageString, installPath, {
71
- isLocal,
72
- client: options.client,
73
- limitConcurrency: options.limitConcurrency,
74
- networkConcurrency: options.networkConcurrency,
75
- installTimeout: options.installTimeout,
76
- })
77
-
78
- const externals = getExternals(packageName, installPath)
79
69
  try {
70
+ await InstallationUtils.installPackage(packageString, installPath, {
71
+ isLocal,
72
+ client: options.client,
73
+ limitConcurrency: options.limitConcurrency,
74
+ networkConcurrency: options.networkConcurrency,
75
+ installTimeout: options.installTimeout,
76
+ })
77
+
78
+ const externals = getExternals(packageName, installPath)
80
79
  const [pacakgeJSONDetails, builtDetails] = await Promise.all([
81
80
  getPackageJSONDetails(packageName, installPath),
82
81
  BuildUtils.buildPackageIgnoringMissingDeps({
@@ -31,7 +31,7 @@ export function exec(command: string, options: any, timeout?: number) {
31
31
  reject(
32
32
  `Execution of ${command.substring(
33
33
  0,
34
- 20
34
+ 40
35
35
  )}... cancelled as it exceeded a timeout of ${timeout} ms`
36
36
  )
37
37
  }, timeout)
@@ -1,56 +0,0 @@
1
- declare type Minifier = 'esbuild' | 'terser'
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
- }
47
- export declare type Externals = {
48
- externalPackages: Array<string>
49
- externalBuiltIns: Array<string>
50
- }
51
- export declare type WebpackError = {
52
- name: 'ModuleNotFoundError'
53
- details?: string
54
- error: Error
55
- }
56
- export {}
@@ -1,2 +0,0 @@
1
- 'use strict'
2
- Object.defineProperty(exports, '__esModule', { value: true })
@@ -1,4 +0,0 @@
1
- declare const _default: {
2
- tmp: string
3
- }
4
- export default _default
@@ -1,12 +0,0 @@
1
- 'use strict'
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'))
10
- exports.default = {
11
- tmp: path_1.default.join('/tmp', 'tmp-build'),
12
- }
@@ -1,17 +0,0 @@
1
- import webpack, { Entry } from 'webpack'
2
- import { Externals } from '../common.types'
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 {}
@@ -1,242 +0,0 @@
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')
24
- // @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
- },
81
- },
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
- },
160
- },
161
- },
162
- {
163
- test: /\.vue$/,
164
- loader: require.resolve('vue-loader'),
165
- },
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',
196
- ],
197
- }),
198
- ],
199
- },
200
- },
201
- {
202
- loader: require.resolve('less-loader'),
203
- options: {
204
- webpackImporter: true,
205
- },
206
- },
207
- ],
208
- },
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
- },
216
- },
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
- }
229
- }
230
- exports.default = makeWebpackConfig
231
- 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)
242
- }
@@ -1,40 +0,0 @@
1
- /**
2
- * Wraps the original error with a identifiable
3
- * name.
4
- */
5
- declare class CustomError extends Error {
6
- originalError: any
7
- extra: any
8
- constructor(name: string, originalError: Error, extra?: any)
9
- }
10
- export declare class BuildError extends CustomError {
11
- constructor(originalError: any, extra?: any)
12
- }
13
- export declare class EntryPointError extends CustomError {
14
- constructor(originalError: any, extra?: any)
15
- }
16
- export declare class InstallError extends CustomError {
17
- constructor(originalError: any, extra?: any)
18
- }
19
- export declare class PackageNotFoundError extends CustomError {
20
- constructor(originalError: any, extra?: any)
21
- }
22
- export declare class CLIBuildError extends CustomError {
23
- constructor(originalError: any, extra?: any)
24
- }
25
- export declare class MinifyError extends CustomError {
26
- constructor(originalError: any, extra?: any)
27
- }
28
- export declare class MissingDependencyError extends CustomError {
29
- missingModules: Array<string>
30
- constructor(
31
- originalError: any,
32
- extra: {
33
- missingModules: Array<string>
34
- }
35
- )
36
- }
37
- export declare class UnexpectedBuildError extends CustomError {
38
- constructor(originalError: any, extra?: any)
39
- }
40
- export {}
@@ -1,73 +0,0 @@
1
- 'use strict'
2
- Object.defineProperty(exports, '__esModule', { value: true })
3
- exports.UnexpectedBuildError = exports.MissingDependencyError = exports.MinifyError = exports.CLIBuildError = exports.PackageNotFoundError = exports.InstallError = exports.EntryPointError = exports.BuildError = void 0
4
- /**
5
- * Wraps the original error with a identifiable
6
- * name.
7
- */
8
- class CustomError extends Error {
9
- constructor(name, originalError, extra) {
10
- super(name)
11
- this.name = name
12
- this.originalError = originalError
13
- this.extra = extra
14
- Object.setPrototypeOf(this, CustomError.prototype)
15
- }
16
- }
17
- class BuildError extends CustomError {
18
- constructor(originalError, extra) {
19
- super('BuildError', originalError, extra)
20
- Object.setPrototypeOf(this, BuildError.prototype)
21
- }
22
- }
23
- exports.BuildError = BuildError
24
- class EntryPointError extends CustomError {
25
- constructor(originalError, extra) {
26
- super('EntryPointError', originalError, extra)
27
- Object.setPrototypeOf(this, EntryPointError.prototype)
28
- }
29
- }
30
- exports.EntryPointError = EntryPointError
31
- class InstallError extends CustomError {
32
- constructor(originalError, extra) {
33
- super('InstallError', originalError, extra)
34
- Object.setPrototypeOf(this, InstallError.prototype)
35
- }
36
- }
37
- exports.InstallError = InstallError
38
- class PackageNotFoundError extends CustomError {
39
- constructor(originalError, extra) {
40
- super('PackageNotFoundError', originalError, extra)
41
- Object.setPrototypeOf(this, PackageNotFoundError.prototype)
42
- }
43
- }
44
- exports.PackageNotFoundError = PackageNotFoundError
45
- class CLIBuildError extends CustomError {
46
- constructor(originalError, extra) {
47
- super('CLIBuildError', originalError, extra)
48
- Object.setPrototypeOf(this, CLIBuildError.prototype)
49
- }
50
- }
51
- exports.CLIBuildError = CLIBuildError
52
- class MinifyError extends CustomError {
53
- constructor(originalError, extra) {
54
- super('MinifyError', originalError, extra)
55
- Object.setPrototypeOf(this, MinifyError.prototype)
56
- }
57
- }
58
- exports.MinifyError = MinifyError
59
- class MissingDependencyError extends CustomError {
60
- constructor(originalError, extra) {
61
- super('MissingDependencyError', originalError, extra)
62
- this.missingModules = extra.missingModules
63
- Object.setPrototypeOf(this, MissingDependencyError.prototype)
64
- }
65
- }
66
- exports.MissingDependencyError = MissingDependencyError
67
- class UnexpectedBuildError extends CustomError {
68
- constructor(originalError, extra) {
69
- super('UnexpectedBuildError', originalError, extra)
70
- Object.setPrototypeOf(this, UnexpectedBuildError.prototype)
71
- }
72
- }
73
- exports.UnexpectedBuildError = UnexpectedBuildError
@@ -1,12 +0,0 @@
1
- import webpack from 'webpack'
2
- declare function bundleSizeTree(
3
- packageName: string,
4
- stats: webpack.Stats.ToJsonOutput,
5
- minifier: 'terser' | 'esbuild'
6
- ): Promise<
7
- {
8
- name: string
9
- approximateSize: number
10
- }[]
11
- >
12
- export default bundleSizeTree