package-build-stats 8.2.5 → 8.2.6

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.
@@ -6,6 +6,7 @@ type MakeRspackConfigOptions = {
6
6
  debug?: boolean;
7
7
  minify?: boolean;
8
8
  entry: Entry;
9
+ outputPath: string;
9
10
  };
10
- export default function makeRspackConfig({ packageName: _packageName, entry, externals, debug: _debug, minify, }: MakeRspackConfigOptions): Configuration;
11
+ export default function makeRspackConfig({ packageName: _packageName, entry, externals, debug: _debug, minify, outputPath, }: MakeRspackConfigOptions): Configuration;
11
12
  export {};
@@ -3,7 +3,7 @@ import escapeRegex from 'escape-string-regexp';
3
3
  import rspack from '@rspack/core';
4
4
  import { createRequire } from 'module';
5
5
  const require = createRequire(import.meta.url);
6
- export default function makeRspackConfig({ packageName: _packageName, entry, externals, debug: _debug, minify = true, }) {
6
+ export default function makeRspackConfig({ packageName: _packageName, entry, externals, debug: _debug, minify = true, outputPath, }) {
7
7
  const externalsRegex = makeExternalsRegex(externals.externalPackages);
8
8
  const isExternalRequest = (request) => {
9
9
  const isPeerDep = externals.externalPackages.length
@@ -154,6 +154,7 @@ export default function makeRspackConfig({ packageName: _packageName, entry, ext
154
154
  },
155
155
  output: {
156
156
  filename: '[name].bundle.js',
157
+ path: outputPath,
157
158
  },
158
159
  externals: ({ request }, callback) => isExternalRequest(request || '')
159
160
  ? callback(undefined, 'commonjs ' + request)
@@ -7,6 +7,7 @@ type CompilePackageArgs = {
7
7
  entry: Entry;
8
8
  debug?: boolean;
9
9
  minify?: boolean;
10
+ outputPath: string;
10
11
  };
11
12
  type CompilePackageReturn = {
12
13
  stats: Stats;
@@ -36,7 +37,7 @@ type BuildPackageResultWithIgnored = BuildPackageResult & {
36
37
  declare function getCompilationErrors(stats: Stats): import("@rspack/core").RspackError[];
37
38
  declare const BuildUtils: {
38
39
  createEntryPoint(packageName: string, installPath: string, options: CreateEntryPointOptions): string;
39
- compilePackage({ name, entry, externals, debug, minify, }: CompilePackageArgs): Promise<CompilePackageReturn>;
40
+ compilePackage({ name, entry, externals, debug, minify, outputPath, }: CompilePackageArgs): Promise<CompilePackageReturn>;
40
41
  _parseMissingModules(errors: ReturnType<typeof getCompilationErrors>): string[];
41
42
  buildPackage({ name, installPath, externals, options, }: BuildPackageArgs): Promise<{
42
43
  assets: {
@@ -1,4 +1,5 @@
1
1
  import path from 'path';
2
+ import config from '../config/config.js';
2
3
  import { rspack } from '@rspack/core';
3
4
  import isValidNPMName from 'is-valid-npm-name';
4
5
  import { gzipSync } from 'zlib';
@@ -60,7 +61,7 @@ const BuildUtils = {
60
61
  throw new EntryPointError(err);
61
62
  }
62
63
  },
63
- compilePackage({ name, entry, externals, debug, minify, }) {
64
+ compilePackage({ name, entry, externals, debug, minify, outputPath, }) {
64
65
  const startTime = performance.now();
65
66
  const options = makeRspackConfig({
66
67
  packageName: name,
@@ -68,6 +69,7 @@ const BuildUtils = {
68
69
  externals,
69
70
  debug,
70
71
  minify,
72
+ outputPath,
71
73
  });
72
74
  const compiler = rspack(options);
73
75
  return new Promise((resolve, reject) => {
@@ -119,6 +121,7 @@ const BuildUtils = {
119
121
  },
120
122
  async buildPackage({ name, installPath, externals, options, }) {
121
123
  var _a;
124
+ const outputPath = config.tmp;
122
125
  let entry = {};
123
126
  if (options.splitCustomImports) {
124
127
  if (!options.customImports || !options.customImports.length) {
@@ -144,6 +147,7 @@ const BuildUtils = {
144
147
  externals,
145
148
  debug: options.debug,
146
149
  minify: options.minify,
150
+ outputPath,
147
151
  });
148
152
  const jsonStatsStartTime = performance.now();
149
153
  let jsonStats = stats.toJson({
@@ -195,7 +199,7 @@ const BuildUtils = {
195
199
  }
196
200
  else {
197
201
  const getAssetStats = async (asset) => {
198
- const bundle = path.join(process.cwd(), 'dist', asset.name);
202
+ const bundle = path.join(outputPath, asset.name);
199
203
  const bundleContents = await fs.promises.readFile(bundle);
200
204
  const gzip = gzipSync(bundleContents, {}).length;
201
205
  const matches = asset.name.match(/(.+?)\.bundle\.(.+)$/);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "package-build-stats",
3
- "version": "8.2.5",
3
+ "version": "8.2.6",
4
4
  "type": "module",
5
5
  "author": "Shubham Kanodia <shubham.kanodia10@gmail.com>",
6
6
  "repository": "https://github.com/pastelsky/package-build-stats",
@@ -15,6 +15,7 @@ type MakeRspackConfigOptions = {
15
15
  debug?: boolean
16
16
  minify?: boolean
17
17
  entry: Entry
18
+ outputPath: string
18
19
  }
19
20
 
20
21
  export default function makeRspackConfig({
@@ -23,6 +24,7 @@ export default function makeRspackConfig({
23
24
  externals,
24
25
  debug: _debug,
25
26
  minify = true,
27
+ outputPath,
26
28
  }: MakeRspackConfigOptions): Configuration {
27
29
  const externalsRegex = makeExternalsRegex(externals.externalPackages)
28
30
  const isExternalRequest = (request: string) => {
@@ -176,6 +178,7 @@ export default function makeRspackConfig({
176
178
  },
177
179
  output: {
178
180
  filename: '[name].bundle.js',
181
+ path: outputPath,
179
182
  },
180
183
  externals: ({ request }, callback) =>
181
184
  isExternalRequest(request || '')
@@ -1,4 +1,5 @@
1
1
  import path from 'path'
2
+ import config from '../config/config.js'
2
3
  import { Entry, rspack } from '@rspack/core'
3
4
  import isValidNPMName from 'is-valid-npm-name'
4
5
  import { gzipSync } from 'zlib'
@@ -28,6 +29,7 @@ type CompilePackageArgs = {
28
29
  entry: Entry
29
30
  debug?: boolean
30
31
  minify?: boolean
32
+ outputPath: string
31
33
  }
32
34
 
33
35
  type CompilePackageReturn = {
@@ -133,6 +135,7 @@ const BuildUtils = {
133
135
  externals,
134
136
  debug,
135
137
  minify,
138
+ outputPath,
136
139
  }: CompilePackageArgs) {
137
140
  const startTime = performance.now()
138
141
 
@@ -142,6 +145,7 @@ const BuildUtils = {
142
145
  externals,
143
146
  debug,
144
147
  minify,
148
+ outputPath,
145
149
  })
146
150
 
147
151
  const compiler = rspack(options)
@@ -214,6 +218,7 @@ const BuildUtils = {
214
218
  externals,
215
219
  options,
216
220
  }: BuildPackageArgs) {
221
+ const outputPath = config.tmp
217
222
  let entry: any = {}
218
223
 
219
224
  if (options.splitCustomImports) {
@@ -240,6 +245,7 @@ const BuildUtils = {
240
245
  externals,
241
246
  debug: options.debug,
242
247
  minify: options.minify,
248
+ outputPath,
243
249
  })
244
250
 
245
251
  const jsonStatsStartTime = performance.now()
@@ -300,7 +306,7 @@ const BuildUtils = {
300
306
  }
301
307
  } else {
302
308
  const getAssetStats = async (asset: RspackStatsAsset) => {
303
- const bundle = path.join(process.cwd(), 'dist', asset.name)
309
+ const bundle = path.join(outputPath, asset.name)
304
310
  const bundleContents = await fs.promises.readFile(bundle)
305
311
 
306
312
  const gzip = gzipSync(bundleContents, {}).length