@amazon/vinyl-build-utils 3.0.0 → 3.1.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/dist/browserstack/browserStackConfig.d.ts +111 -0
- package/dist/browserstack/browserStackConfig.d.ts.map +1 -0
- package/dist/browserstack/browserStackConfig.js +26 -0
- package/dist/browserstack/browserStackRestApi.d.ts +2 -33
- package/dist/browserstack/browserStackRestApi.d.ts.map +1 -1
- package/dist/browserstack/browserStackRestApi.js +0 -21
- package/dist/esbuild/analyzeExports.d.ts.map +1 -1
- package/dist/esbuild/analyzeExports.js +37 -24
- package/dist/index.d.ts +1 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/vinyl/vinylDefaultBrowserStackOptions.d.ts +1 -1
- package/dist/vinyl/vinylDefaultBrowserStackOptions.js +2 -2
- package/dist/vinyl/vinylSupportedBrowsers.d.ts +1 -1
- package/dist/vinyl/vinylSupportedBrowsers.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/browserstack/BrowserStackWorker.d.ts +0 -158
- package/dist/browserstack/BrowserStackWorker.d.ts.map +0 -1
- package/dist/browserstack/BrowserStackWorker.js +0 -330
- package/dist/browserstack/BrowserStackWorkerController.d.ts +0 -103
- package/dist/browserstack/BrowserStackWorkerController.d.ts.map +0 -1
- package/dist/browserstack/BrowserStackWorkerController.js +0 -199
- package/dist/browserstack/runBrowserStack.d.ts +0 -123
- package/dist/browserstack/runBrowserStack.d.ts.map +0 -1
- package/dist/browserstack/runBrowserStack.js +0 -211
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Options as BsLocalOptions } from 'browserstack-local';
|
|
2
|
+
import type { ServerOptions } from '../express/serve';
|
|
3
|
+
import type { LogLevel } from '../util/Logger';
|
|
4
|
+
import type { BrowserDetails, BrowserStackCredentials, WorkerOptions } from './browserStackRestApi';
|
|
5
|
+
/**
|
|
6
|
+
* Per-worker (per-session) runtime configuration.
|
|
7
|
+
*/
|
|
8
|
+
export interface BrowserStackWorkerOptions {
|
|
9
|
+
/**
|
|
10
|
+
* The number of seconds to wait for data before attempting to retry the test.
|
|
11
|
+
* Default: 45
|
|
12
|
+
*/
|
|
13
|
+
readonly captureTimeout?: number;
|
|
14
|
+
/**
|
|
15
|
+
* The number of retries to start the session before giving up.
|
|
16
|
+
* Default: 2
|
|
17
|
+
*/
|
|
18
|
+
readonly retries?: number;
|
|
19
|
+
/**
|
|
20
|
+
* The number of seconds between session update requests.
|
|
21
|
+
* Default: 5
|
|
22
|
+
*/
|
|
23
|
+
readonly pollInterval?: number;
|
|
24
|
+
/**
|
|
25
|
+
* The directory to emit console logs.
|
|
26
|
+
* Set to null to disable console logging.
|
|
27
|
+
* Default: ./bStackLogs
|
|
28
|
+
*/
|
|
29
|
+
readonly logsDir?: string | null;
|
|
30
|
+
/**
|
|
31
|
+
* If provided, adds the given query parameters to the launched URL.
|
|
32
|
+
*/
|
|
33
|
+
readonly queryParams?: Record<string, string> | null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Configuration for a controller that schedules many workers.
|
|
37
|
+
*/
|
|
38
|
+
export interface BrowserStackWorkerControllerOptions {
|
|
39
|
+
/**
|
|
40
|
+
* Configuration to provide to each worker.
|
|
41
|
+
*/
|
|
42
|
+
readonly worker?: BrowserStackWorkerOptions;
|
|
43
|
+
/**
|
|
44
|
+
* The maximum number of sessions to run in parallel.
|
|
45
|
+
* If not set, the maximum number of sessions according to the automate plan
|
|
46
|
+
* will be used.
|
|
47
|
+
*/
|
|
48
|
+
readonly maxSessions?: number;
|
|
49
|
+
}
|
|
50
|
+
export interface BrowserStackOptions extends BrowserStackWorkerControllerOptions {
|
|
51
|
+
/**
|
|
52
|
+
* BrowserStack local connection options.
|
|
53
|
+
*/
|
|
54
|
+
readonly local?: Partial<BsLocalOptions>;
|
|
55
|
+
/**
|
|
56
|
+
* Local server configuration.
|
|
57
|
+
*/
|
|
58
|
+
readonly server: ServerOptions;
|
|
59
|
+
/**
|
|
60
|
+
* The BrowserStack credentials. If undefined, taken from the environment
|
|
61
|
+
* variables BROWSERSTACK_USERNAME and BROWSERSTACK_ACCESS_KEY (a `.env` file
|
|
62
|
+
* is honored).
|
|
63
|
+
*/
|
|
64
|
+
readonly credentials?: BrowserStackCredentials | Promise<BrowserStackCredentials>;
|
|
65
|
+
/**
|
|
66
|
+
* The list of browsers to test against.
|
|
67
|
+
* `name`, if not provided, is generated from '<device> <os> <browser> <browser_version>'.
|
|
68
|
+
*/
|
|
69
|
+
readonly browsers: readonly WorkerInitOptions[];
|
|
70
|
+
/**
|
|
71
|
+
* Options common to all workers. `build` defaults to a unique identifier.
|
|
72
|
+
*/
|
|
73
|
+
readonly workerCommon?: CommonWorkerInitOptions;
|
|
74
|
+
/**
|
|
75
|
+
* If true, shows continuous progress in the console. If false, progress is
|
|
76
|
+
* logged in at most 10% increments (recommended for CI). Default: true when
|
|
77
|
+
* process.stdout is a terminal.
|
|
78
|
+
*/
|
|
79
|
+
readonly stickyProgress?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* If true, terminates all workers on the first failure. Default: false
|
|
82
|
+
*/
|
|
83
|
+
readonly stopOnFirstFailure?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Sets the log verbosity. Default: LogLevel.INFO
|
|
86
|
+
*/
|
|
87
|
+
readonly logLevel?: LogLevel;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Options used as defaults for all workers. Values set on the worker take
|
|
91
|
+
* priority.
|
|
92
|
+
*/
|
|
93
|
+
export type CommonWorkerInitOptions = Omit<WorkerInitOptions, keyof BrowserDetails>;
|
|
94
|
+
export interface WorkerInitOptions extends Omit<WorkerOptions, 'url'> {
|
|
95
|
+
/**
|
|
96
|
+
* A valid url to navigate the browser to. If not set, the local server URL
|
|
97
|
+
* is used.
|
|
98
|
+
*/
|
|
99
|
+
readonly url?: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* When the BrowserStack run has completed, provides the final results.
|
|
103
|
+
*/
|
|
104
|
+
export interface BrowserStackResults {
|
|
105
|
+
readonly passed: boolean;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Attempts to get the BrowserStackCredentials from the environment.
|
|
109
|
+
*/
|
|
110
|
+
export declare function getEnvBrowserStackCredentials(): BrowserStackCredentials;
|
|
111
|
+
//# sourceMappingURL=browserStackConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browserStackConfig.d.ts","sourceRoot":"","sources":["../../src/browserstack/browserStackConfig.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C,OAAO,KAAK,EACR,cAAc,EACd,uBAAuB,EACvB,aAAa,EAChB,MAAM,uBAAuB,CAAA;AAE9B;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACtC;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAA;IAEhC;;;OAGG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IAEzB;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAE9B;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAEhC;;OAEG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAA;CACvD;AAED;;GAEG;AACH,MAAM,WAAW,mCAAmC;IAChD;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,yBAAyB,CAAA;IAE3C;;;;OAIG;IACH,QAAQ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/worker configuration, shared by runners
|
|
7
|
+
* (e.g. `@amazon/vinyl-browserstack`) regardless of the session transport.
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { config as dotEnvConfig } from 'dotenv';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import process from 'node:process';
|
|
13
|
+
import { getRootProjectDir } from '../util/getRootProjectDir';
|
|
14
|
+
/**
|
|
15
|
+
* Attempts to get the BrowserStackCredentials from the environment.
|
|
16
|
+
*/
|
|
17
|
+
export function getEnvBrowserStackCredentials() {
|
|
18
|
+
const rootDir = getRootProjectDir();
|
|
19
|
+
if (!rootDir)
|
|
20
|
+
throw new Error('Could not find root project dir from current working directory.');
|
|
21
|
+
dotEnvConfig({ path: path.resolve(rootDir, '.env') });
|
|
22
|
+
return {
|
|
23
|
+
username: process.env.BROWSERSTACK_USERNAME,
|
|
24
|
+
key: process.env.BROWSERSTACK_ACCESS_KEY,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -83,16 +83,6 @@ export interface WorkerOptions extends BrowserDetails {
|
|
|
83
83
|
*/
|
|
84
84
|
readonly fallbackBrowser?: BrowserDetails | null;
|
|
85
85
|
}
|
|
86
|
-
export interface NewWorker {
|
|
87
|
-
/**
|
|
88
|
-
* The identifier of the new Worker. Can be used to get worker details which includes the session id.
|
|
89
|
-
*/
|
|
90
|
-
readonly id: number;
|
|
91
|
-
/**
|
|
92
|
-
* The url of the worker.
|
|
93
|
-
*/
|
|
94
|
-
readonly url: string;
|
|
95
|
-
}
|
|
96
86
|
/**
|
|
97
87
|
* https://www.browserstack.com/docs/automate/api-reference/selenium/session#set-test-status
|
|
98
88
|
*/
|
|
@@ -165,19 +155,6 @@ export interface PlanDetails {
|
|
|
165
155
|
*/
|
|
166
156
|
readonly queued_sessions_max_allowed: number;
|
|
167
157
|
}
|
|
168
|
-
/**
|
|
169
|
-
* Information about the worker.
|
|
170
|
-
*/
|
|
171
|
-
export interface WorkerDetails extends BrowserDetails {
|
|
172
|
-
readonly id: number;
|
|
173
|
-
readonly status: SessionStatus;
|
|
174
|
-
readonly real_mobile: null | boolean;
|
|
175
|
-
readonly browser_url: string;
|
|
176
|
-
readonly sessionId: string;
|
|
177
|
-
}
|
|
178
|
-
export interface DeleteWorkerResponse {
|
|
179
|
-
readonly time: number;
|
|
180
|
-
}
|
|
181
158
|
export type SessionStatus = 'passed' | 'failed' | 'timeout' | 'running' | 'queued';
|
|
182
159
|
export type ExecutionStatus = 'running' | 'done' | 'timeout' | 'queued';
|
|
183
160
|
export interface SessionDetails extends BrowserDetails {
|
|
@@ -280,14 +257,6 @@ export type RequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
|
280
257
|
declare class BrowserStackClient {
|
|
281
258
|
readonly credentials: BrowserStackCredentials;
|
|
282
259
|
constructor(credentials: BrowserStackCredentials);
|
|
283
|
-
createWorker(options: WorkerOptions): Promise<NewWorker>;
|
|
284
|
-
deleteWorker(workerId: number): Promise<DeleteWorkerResponse>;
|
|
285
|
-
getWorker(workerId: number): Promise<WorkerDetails>;
|
|
286
|
-
/**
|
|
287
|
-
* Deletes a build and all sessions contained within it. Builds once deleted cannot be recovered.
|
|
288
|
-
* @param buildId
|
|
289
|
-
*/
|
|
290
|
-
deleteBuild(buildId: number): Promise<DeleteWorkerResponse>;
|
|
291
260
|
protected doRequest(url: string, method: RequestMethod, body?: any, type?: 'json' | 'text', retries?: number): Promise<any>;
|
|
292
261
|
}
|
|
293
262
|
export declare class ServiceResponseError extends Error {
|
|
@@ -307,8 +276,8 @@ export declare class BrowserStackAutomateClient extends BrowserStackClient {
|
|
|
307
276
|
* @param sessionId
|
|
308
277
|
*/
|
|
309
278
|
deleteSession(sessionId: string): Promise<DeleteResponse>;
|
|
310
|
-
getBuilds(options: GetBuildsOptions): Promise<
|
|
311
|
-
updateBuild(buildId: string, buildOptions: UpdateBuildOptions): Promise<
|
|
279
|
+
getBuilds(options: GetBuildsOptions): Promise<AnyRecord>;
|
|
280
|
+
updateBuild(buildId: string, buildOptions: UpdateBuildOptions): Promise<AnyRecord>;
|
|
312
281
|
}
|
|
313
282
|
export {};
|
|
314
283
|
//# sourceMappingURL=browserStackRestApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browserStackRestApi.d.ts","sourceRoot":"","sources":["../../src/browserstack/browserStackRestApi.ts"],"names":[],"mappings":"AAeA;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACvB;AAED,MAAM,WAAW,cAAc;IAC3B;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IAEzB;;OAEG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;IAEjC;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IAEnB;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAE3B;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAClC;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAc,SAAQ,cAAc;IACjD;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAE5B;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IAEtB;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IAEzB;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IAEpB;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IAEvB;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IAEzB;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;IAExB;;;;OAIG;IACH,QAAQ,CAA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ACf,OAAO,EAAE,kBAAkB,GAC5B,OAAO,CAAC,SAAS,kBAAkB,EAAE,CAAC;IAYnC,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAS1D,aAAa,CACf,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,oBAAoB,GAC9B,OAAO,CAAC,cAAc,CAAC;IAU1B;;;;OAIG;IACG,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAOzD,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;IAIxD,WAAW,CACb,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,kBAAkB,GACjC,OAAO,CAAC,SAAS,CAAC;CAOxB"}
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { sleep } from '../util/sleep';
|
|
12
12
|
import { logger } from '../util/Logger';
|
|
13
|
-
const API = 'https://api.browserstack.com/5';
|
|
14
13
|
const retryableStatuses = new Set([
|
|
15
14
|
400, // Bad request
|
|
16
15
|
429, // Too many requests
|
|
@@ -23,26 +22,6 @@ class BrowserStackClient {
|
|
|
23
22
|
constructor(credentials) {
|
|
24
23
|
this.credentials = credentials;
|
|
25
24
|
}
|
|
26
|
-
async createWorker(options) {
|
|
27
|
-
return this.doRequest(`${API}/worker`, 'POST', options);
|
|
28
|
-
}
|
|
29
|
-
async deleteWorker(workerId) {
|
|
30
|
-
return this.doRequest(`${API}/worker/${workerId}`, 'DELETE');
|
|
31
|
-
}
|
|
32
|
-
async getWorker(workerId) {
|
|
33
|
-
const workerDetails = await this.doRequest(`${API}/worker/${workerId}`, 'GET');
|
|
34
|
-
if (!('sessionId' in workerDetails)) {
|
|
35
|
-
throw new Error(`worker ${workerId} not found`);
|
|
36
|
-
}
|
|
37
|
-
return workerDetails;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Deletes a build and all sessions contained within it. Builds once deleted cannot be recovered.
|
|
41
|
-
* @param buildId
|
|
42
|
-
*/
|
|
43
|
-
async deleteBuild(buildId) {
|
|
44
|
-
return this.doRequest(`${API}/builds/${buildId}`, 'DELETE');
|
|
45
|
-
}
|
|
46
25
|
async doRequest(url, method, body, type = 'json', retries = 3) {
|
|
47
26
|
let response = null;
|
|
48
27
|
let error = null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzeExports.d.ts","sourceRoot":"","sources":["../../src/esbuild/analyzeExports.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"analyzeExports.d.ts","sourceRoot":"","sources":["../../src/esbuild/analyzeExports.ts"],"names":[],"mappings":"AA0DA,MAAM,WAAW,qBAAqB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC/B;AAED,wBAAsB,cAAc,CAAC,EACjC,IAAI,EACJ,MAAM,EACN,UAAU,GACb,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsEvC"}
|
|
@@ -8,27 +8,38 @@ import fs from 'fs/promises';
|
|
|
8
8
|
import os from 'os';
|
|
9
9
|
import { exit } from 'process';
|
|
10
10
|
import esbuild from 'esbuild';
|
|
11
|
-
import crypto from 'node:crypto';
|
|
12
11
|
const write = process.argv.includes('--write');
|
|
13
12
|
async function getBundleSize(importName, importPath) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
// A `stdin` entry avoids writing (and cleaning up) a temp file per export;
|
|
14
|
+
// the absolute `importPath` resolves regardless of `resolveDir`.
|
|
15
|
+
const result = await esbuild.build({
|
|
16
|
+
stdin: {
|
|
17
|
+
contents: `import { ${importName} } from ${JSON.stringify(importPath)};\nconsole.log(${importName});`,
|
|
18
|
+
resolveDir: path.dirname(importPath),
|
|
19
|
+
loader: 'js',
|
|
20
|
+
},
|
|
21
|
+
bundle: true,
|
|
22
|
+
write: false,
|
|
23
|
+
treeShaking: true,
|
|
24
|
+
minify: true,
|
|
25
|
+
format: 'esm',
|
|
26
|
+
platform: 'node',
|
|
27
|
+
logLevel: 'silent',
|
|
28
|
+
});
|
|
29
|
+
return result.outputFiles[0].text.length;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Runs `task` over every item with at most `concurrency` in flight. Order is
|
|
33
|
+
* not preserved; each task writes its own result.
|
|
34
|
+
*/
|
|
35
|
+
async function forEachConcurrent(items, concurrency, task) {
|
|
36
|
+
let next = 0;
|
|
37
|
+
const runners = Array.from({ length: Math.min(concurrency, items.length) }, async () => {
|
|
38
|
+
while (next < items.length) {
|
|
39
|
+
await task(items[next++]);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
await Promise.all(runners);
|
|
32
43
|
}
|
|
33
44
|
export async function analyzeExports({ name, target, reportPath, }) {
|
|
34
45
|
const exportSizes = {};
|
|
@@ -36,15 +47,17 @@ export async function analyzeExports({ name, target, reportPath, }) {
|
|
|
36
47
|
const importPath = path.resolve(target);
|
|
37
48
|
const exports = await import(importPath);
|
|
38
49
|
const exportNames = Object.keys(exports);
|
|
39
|
-
|
|
50
|
+
// Each export is bundled independently to measure its tree-shaken size;
|
|
51
|
+
// the builds are independent, so run them concurrently (bounded by CPUs).
|
|
52
|
+
await forEachConcurrent(exportNames, Math.max(1, os.cpus().length), async (exportName) => {
|
|
40
53
|
try {
|
|
41
|
-
exportSizes[
|
|
54
|
+
exportSizes[exportName] = await getBundleSize(exportName, importPath);
|
|
42
55
|
}
|
|
43
56
|
catch (err) {
|
|
44
|
-
exportSizes[
|
|
45
|
-
console.error(`Failed to bundle "${
|
|
57
|
+
exportSizes[exportName] = -1; // Mark error
|
|
58
|
+
console.error(`Failed to bundle "${exportName}":`, err.message);
|
|
46
59
|
}
|
|
47
|
-
}
|
|
60
|
+
});
|
|
48
61
|
const validSizes = Object.values(exportSizes).filter((size) => size > 0);
|
|
49
62
|
const minBundleSize = validSizes.length > 0 ? Math.min(...validSizes) : 0;
|
|
50
63
|
const report = { minBundleSize };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/** Auto-generated from build scripts */
|
|
2
2
|
export * from './babel/compatTransform';
|
|
3
|
+
export * from './browserstack/browserStackConfig';
|
|
3
4
|
export * from './browserstack/browserStackLocal';
|
|
4
5
|
export * from './browserstack/browserStackRestApi';
|
|
5
|
-
export * from './browserstack/BrowserStackWorker';
|
|
6
|
-
export * from './browserstack/BrowserStackWorkerController';
|
|
7
6
|
export * from './browserstack/configureReporterApi';
|
|
8
|
-
export * from './browserstack/runBrowserStack';
|
|
9
7
|
export * from './esbuild/analyzeExports';
|
|
10
8
|
export * from './esbuild/buildAll';
|
|
11
9
|
export * from './esbuild/CompatTransformPlugin';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,cAAc,yBAAyB,CAAA;AACvC,cAAc,mCAAmC,CAAA;AACjD,cAAc,kCAAkC,CAAA;AAChD,cAAc,oCAAoC,CAAA;AAClD,cAAc,qCAAqC,CAAA;AACnD,cAAc,0BAA0B,CAAA;AACxC,cAAc,oBAAoB,CAAA;AAClC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,+BAA+B,CAAA;AAC7C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kCAAkC,CAAA;AAChD,cAAc,iBAAiB,CAAA;AAC/B,cAAc,8BAA8B,CAAA;AAC5C,cAAc,oCAAoC,CAAA;AAClD,cAAc,4BAA4B,CAAA;AAC1C,cAAc,iCAAiC,CAAA;AAC/C,cAAc,uCAAuC,CAAA;AACrD,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,yCAAyC,CAAA;AACvD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,gCAAgC,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/** Auto-generated from build scripts */
|
|
2
2
|
export * from './babel/compatTransform';
|
|
3
|
+
export * from './browserstack/browserStackConfig';
|
|
3
4
|
export * from './browserstack/browserStackLocal';
|
|
4
5
|
export * from './browserstack/browserStackRestApi';
|
|
5
|
-
export * from './browserstack/BrowserStackWorker';
|
|
6
|
-
export * from './browserstack/BrowserStackWorkerController';
|
|
7
6
|
export * from './browserstack/configureReporterApi';
|
|
8
|
-
export * from './browserstack/runBrowserStack';
|
|
9
7
|
export * from './esbuild/analyzeExports';
|
|
10
8
|
export * from './esbuild/buildAll';
|
|
11
9
|
export * from './esbuild/CompatTransformPlugin';
|