@knapsack/package-bundler 4.101.0--canary.8110.15bba7c.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/.lintstagedrc.mjs +11 -0
- package/INSTRUCTIONS-FOR-CUSTOMERS.md +130 -0
- package/dist/bundle.d.ts +41 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +348 -0
- package/dist/bundle.js.map +1 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +165 -0
- package/dist/cli.js.map +1 -0
- package/dist/errors.d.ts +63 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +155 -0
- package/dist/errors.js.map +1 -0
- package/dist/help-text.d.ts +16 -0
- package/dist/help-text.d.ts.map +1 -0
- package/dist/help-text.js +180 -0
- package/dist/help-text.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/log.d.ts +42 -0
- package/dist/log.d.ts.map +1 -0
- package/dist/log.js +114 -0
- package/dist/log.js.map +1 -0
- package/dist/metadata.d.ts +112 -0
- package/dist/metadata.d.ts.map +1 -0
- package/dist/metadata.js +204 -0
- package/dist/metadata.js.map +1 -0
- package/dist/prompts.d.ts +54 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +125 -0
- package/dist/prompts.js.map +1 -0
- package/dist/resolve-entries.d.ts +56 -0
- package/dist/resolve-entries.d.ts.map +1 -0
- package/dist/resolve-entries.js +333 -0
- package/dist/resolve-entries.js.map +1 -0
- package/dist/resolve-source.d.ts +53 -0
- package/dist/resolve-source.d.ts.map +1 -0
- package/dist/resolve-source.js +174 -0
- package/dist/resolve-source.js.map +1 -0
- package/dist/run.d.ts +52 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +276 -0
- package/dist/run.js.map +1 -0
- package/dist/types.d.ts +67 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +62 -0
- package/dist/types.js.map +1 -0
- package/dist/vendor.d.ts +59 -0
- package/dist/vendor.d.ts.map +1 -0
- package/dist/vendor.js +134 -0
- package/dist/vendor.js.map +1 -0
- package/dist/verify-bundle.d.ts +59 -0
- package/dist/verify-bundle.d.ts.map +1 -0
- package/dist/verify-bundle.js +238 -0
- package/dist/verify-bundle.js.map +1 -0
- package/dist/write-output.d.ts +82 -0
- package/dist/write-output.d.ts.map +1 -0
- package/dist/write-output.js +214 -0
- package/dist/write-output.js.map +1 -0
- package/package.json +53 -0
- package/readme.md +127 -0
- package/tsconfig.json +9 -0
- package/tsconfig.test.json +13 -0
- package/vitest.config.ts +9 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @knapsack/package-bundler
|
|
3
|
+
*
|
|
4
|
+
* Programmatic entry point. The CLI in `cli.ts` is a thin shell over `run()`; anything
|
|
5
|
+
* that wants to bundle a package from code should call this instead of shelling out.
|
|
6
|
+
*/
|
|
7
|
+
export { run, decideExternals } from './run.js';
|
|
8
|
+
export { bundlePackage, } from './bundle.js';
|
|
9
|
+
export { resolveSource, } from './resolve-source.js';
|
|
10
|
+
export { resolveEntries } from './resolve-entries.js';
|
|
11
|
+
export { verifyBundle, toPackageName, } from './verify-bundle.js';
|
|
12
|
+
export { vendorPackages, findPackageDir } from './vendor.js';
|
|
13
|
+
export { buildMetadata, buildOutputDirName, defaultOutputParent, renderBundleReadme, collectGitProvenance, } from './metadata.js';
|
|
14
|
+
export { buildBundlePackageJson, fixBinShebang, hoistUseClient, } from './write-output.js';
|
|
15
|
+
export { validateOptions, validateSource, validateOutDir, validateStrategy, validateTreeshake, } from './prompts.js';
|
|
16
|
+
export { BundlerError, isBundlerError, formatError, getAllRecoverySteps, ERROR_CODES, } from './errors.js';
|
|
17
|
+
export { buildHelpText } from './help-text.js';
|
|
18
|
+
export { createBundlerLogger, isTelemetryEnabled, } from './log.js';
|
|
19
|
+
export { EXTERNAL_REASONS, EXTERNAL_REASON_LABELS, NEVER_INLINE_BY_DEFAULT, BUILD_TIME_CSS_PACKAGES, } from './types.js';
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,eAAe,EAAkB,MAAM,UAAU,CAAC;AAChE,OAAO,EACL,aAAa,GAGd,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,aAAa,GAGd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,cAAc,EAA0B,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EACL,YAAY,EACZ,aAAa,GAGd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAqB,MAAM,aAAa,CAAC;AAChF,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,GAErB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,sBAAsB,EACtB,aAAa,EACb,cAAc,GACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,eAAe,EACf,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,iBAAiB,GAElB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,WAAW,EACX,mBAAmB,EACnB,WAAW,GAEZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,mBAAmB,EACnB,kBAAkB,GAEnB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,GAKxB,MAAM,YAAY,CAAC"}
|
package/dist/log.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging for a CLI that mostly runs on other people's machines.
|
|
3
|
+
*
|
|
4
|
+
* Two things differ from the server-side loggers in this repo:
|
|
5
|
+
*
|
|
6
|
+
* 1. Log lines go to **stderr**, not stdout. `--json` puts a machine-readable result on
|
|
7
|
+
* stdout, and the interactive prompts draw there too; mixing structured log output in
|
|
8
|
+
* would corrupt both.
|
|
9
|
+
* 2. Delivery uses a Datadog **client** token rather than a private API key. A published
|
|
10
|
+
* npm package cannot carry a private key, and without any key the logger no-ops —
|
|
11
|
+
* which would mean never hearing about the failures we most need to see. Client tokens
|
|
12
|
+
* are the browser/RUM credential, designed to be distributed publicly, and
|
|
13
|
+
* `createSendToDatadog` already supports them via `keyType: 'publicClientKey'`.
|
|
14
|
+
*/
|
|
15
|
+
import { type LogMetadata } from '@knapsack/logger';
|
|
16
|
+
/** Users can turn reporting off entirely. */
|
|
17
|
+
export declare function isTelemetryEnabled({ noTelemetryFlag, }: {
|
|
18
|
+
noTelemetryFlag: boolean;
|
|
19
|
+
}): boolean;
|
|
20
|
+
export interface BundlerLogger {
|
|
21
|
+
info(message: string, metadata?: LogMetadata): void;
|
|
22
|
+
warn(message: string, metadata?: LogMetadata): void;
|
|
23
|
+
debug(message: string, metadata?: LogMetadata): void;
|
|
24
|
+
error(message: string, metadata?: LogMetadata): void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Build the logger. `verbose` controls whether `debug` reaches the terminal; it never
|
|
28
|
+
* affects what ships to Datadog.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createBundlerLogger({ verbose, telemetryEnabled, version, }: {
|
|
31
|
+
verbose: boolean;
|
|
32
|
+
telemetryEnabled: boolean;
|
|
33
|
+
version: string;
|
|
34
|
+
}): BundlerLogger;
|
|
35
|
+
/**
|
|
36
|
+
* Give pending telemetry a moment to land before the process exits. Bounded, because a
|
|
37
|
+
* slow network must not hold the CLI open — a dropped log is better than a hang.
|
|
38
|
+
*/
|
|
39
|
+
export declare function flushTelemetry({ timeoutMs, }?: {
|
|
40
|
+
timeoutMs?: number;
|
|
41
|
+
}): Promise<void>;
|
|
42
|
+
//# sourceMappingURL=log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAiBlE,6CAA6C;AAC7C,wBAAgB,kBAAkB,CAAC,EACjC,eAAe,GAChB,EAAE;IACD,eAAe,EAAE,OAAO,CAAC;CAC1B,GAAG,OAAO,CAKV;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACpD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACpD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACrD,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CACtD;AAID;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,gBAAgB,EAChB,OAAO,GACR,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,aAAa,CAkEhB;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAAC,EACnC,SAAgB,GACjB,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAM7C"}
|
package/dist/log.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logging for a CLI that mostly runs on other people's machines.
|
|
3
|
+
*
|
|
4
|
+
* Two things differ from the server-side loggers in this repo:
|
|
5
|
+
*
|
|
6
|
+
* 1. Log lines go to **stderr**, not stdout. `--json` puts a machine-readable result on
|
|
7
|
+
* stdout, and the interactive prompts draw there too; mixing structured log output in
|
|
8
|
+
* would corrupt both.
|
|
9
|
+
* 2. Delivery uses a Datadog **client** token rather than a private API key. A published
|
|
10
|
+
* npm package cannot carry a private key, and without any key the logger no-ops —
|
|
11
|
+
* which would mean never hearing about the failures we most need to see. Client tokens
|
|
12
|
+
* are the browser/RUM credential, designed to be distributed publicly, and
|
|
13
|
+
* `createSendToDatadog` already supports them via `keyType: 'publicClientKey'`.
|
|
14
|
+
*/
|
|
15
|
+
import { createLogger } from '@knapsack/logger';
|
|
16
|
+
import { createSendToDatadog } from '@knapsack/logger/cjs';
|
|
17
|
+
const SERVICE = 'package-bundler';
|
|
18
|
+
/**
|
|
19
|
+
* Datadog client token, safe to ship in a public package. Overridable via
|
|
20
|
+
* `KS_DATADOG_CLIENT_TOKEN` so staff and CI can point runs at a different org.
|
|
21
|
+
*
|
|
22
|
+
* While the constant holds a `REPLACE_WITH_` placeholder, telemetry no-ops and nothing
|
|
23
|
+
* else about the CLI changes.
|
|
24
|
+
*/
|
|
25
|
+
const DATADOG_CLIENT_TOKEN = process.env.KS_DATADOG_CLIENT_TOKEN || 'REPLACE_WITH_DATADOG_CLIENT_TOKEN';
|
|
26
|
+
const IS_PLACEHOLDER_TOKEN = DATADOG_CLIENT_TOKEN.startsWith('REPLACE_WITH_');
|
|
27
|
+
/** Users can turn reporting off entirely. */
|
|
28
|
+
export function isTelemetryEnabled({ noTelemetryFlag, }) {
|
|
29
|
+
if (noTelemetryFlag)
|
|
30
|
+
return false;
|
|
31
|
+
if (process.env.KS_TELEMETRY === 'no')
|
|
32
|
+
return false;
|
|
33
|
+
if (process.env.DO_NOT_TRACK === '1')
|
|
34
|
+
return false;
|
|
35
|
+
return !IS_PLACEHOLDER_TOKEN;
|
|
36
|
+
}
|
|
37
|
+
const inFlight = new Set();
|
|
38
|
+
/**
|
|
39
|
+
* Build the logger. `verbose` controls whether `debug` reaches the terminal; it never
|
|
40
|
+
* affects what ships to Datadog.
|
|
41
|
+
*/
|
|
42
|
+
export function createBundlerLogger({ verbose, telemetryEnabled, version, }) {
|
|
43
|
+
// Everything to stderr — stdout belongs to --json output and the prompts.
|
|
44
|
+
const stderrConsole = {
|
|
45
|
+
info: (...args) => console.error(...args),
|
|
46
|
+
warn: (...args) => console.error(...args),
|
|
47
|
+
debug: (...args) => {
|
|
48
|
+
if (verbose)
|
|
49
|
+
console.error(...args);
|
|
50
|
+
},
|
|
51
|
+
error: (...args) => console.error(...args),
|
|
52
|
+
};
|
|
53
|
+
// A private API key from the environment wins when present (staff and CI runs get
|
|
54
|
+
// full fidelity); otherwise fall back to the public client token so field errors
|
|
55
|
+
// still reach us.
|
|
56
|
+
const privateKey = process.env.DATADOG_API_KEY__APP_API;
|
|
57
|
+
if (privateKey) {
|
|
58
|
+
return createLogger({
|
|
59
|
+
defaultMeta: { service: SERVICE, env: 'production', version },
|
|
60
|
+
dataDogApiKey: privateKey,
|
|
61
|
+
enableDataDogLogger: telemetryEnabled,
|
|
62
|
+
console: stderrConsole,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
// `createLogger` only speaks private-key, so wire the client-token sender directly.
|
|
66
|
+
const sendToDd = createSendToDatadog({
|
|
67
|
+
ddsource: 'nodejs',
|
|
68
|
+
service: SERVICE,
|
|
69
|
+
env: 'production',
|
|
70
|
+
version,
|
|
71
|
+
keyType: 'publicClientKey',
|
|
72
|
+
key: telemetryEnabled ? DATADOG_CLIENT_TOKEN : '',
|
|
73
|
+
enabled: telemetryEnabled,
|
|
74
|
+
});
|
|
75
|
+
const send = (status, message, metadata) => {
|
|
76
|
+
// Fire-and-forget: a CLI has no request lifecycle to keep alive, and a telemetry
|
|
77
|
+
// failure must never surface as a bundling failure. `flushTelemetry` gives the
|
|
78
|
+
// in-flight sends a bounded window to land before exit.
|
|
79
|
+
const promise = sendToDd({ ...metadata, status, message }).catch(() => { });
|
|
80
|
+
inFlight.add(promise);
|
|
81
|
+
void promise.finally(() => inFlight.delete(promise));
|
|
82
|
+
};
|
|
83
|
+
return {
|
|
84
|
+
info(message, metadata) {
|
|
85
|
+
stderrConsole.info(message, metadata);
|
|
86
|
+
send('info', message, metadata);
|
|
87
|
+
},
|
|
88
|
+
warn(message, metadata) {
|
|
89
|
+
stderrConsole.warn(message, metadata);
|
|
90
|
+
send('warn', message, metadata);
|
|
91
|
+
},
|
|
92
|
+
debug(message, metadata) {
|
|
93
|
+
stderrConsole.debug(message, metadata);
|
|
94
|
+
send('debug', message, metadata);
|
|
95
|
+
},
|
|
96
|
+
error(message, metadata) {
|
|
97
|
+
stderrConsole.error(message, metadata);
|
|
98
|
+
send('error', message, metadata);
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Give pending telemetry a moment to land before the process exits. Bounded, because a
|
|
104
|
+
* slow network must not hold the CLI open — a dropped log is better than a hang.
|
|
105
|
+
*/
|
|
106
|
+
export async function flushTelemetry({ timeoutMs = 2000, } = {}) {
|
|
107
|
+
if (inFlight.size === 0)
|
|
108
|
+
return;
|
|
109
|
+
await Promise.race([
|
|
110
|
+
Promise.allSettled([...inFlight]),
|
|
111
|
+
new Promise((resolve) => setTimeout(resolve, timeoutMs)),
|
|
112
|
+
]);
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=log.js.map
|
package/dist/log.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,YAAY,EAAoB,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,MAAM,OAAO,GAAG,iB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C,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QAClC,CAAC;QACD,KAAK,CAAC,OAAO,EAAE,QAAQ;YACrB,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YACvC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QACnC,CAAC;QACD,KAAK,CAAC,OAAO,EAAE,QAAQ;YACrB,aAAa,CAAC,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YACvC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;QACnC,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EACnC,SAAS,GAAG,IAAI,MACU,EAAE;IAC5B,IAAI,QAAQ,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO;IAChC,MAAM,OAAO,CAAC,IAAI,CAAC;QACjB,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC;QACjC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;KACzD,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provenance. Whoever receives a bundle should be able to answer "what exactly is this,
|
|
3
|
+
* where did it come from, and what was left out" without asking the person who made it.
|
|
4
|
+
*/
|
|
5
|
+
import type { SourcePackageJson } from './resolve-entries.js';
|
|
6
|
+
import type { SourceOrigin } from './resolve-source.js';
|
|
7
|
+
import { type BundleWarning, type EntryPoint, type ExternalPackage } from './types.js';
|
|
8
|
+
import type { VerifyReport } from './verify-bundle.js';
|
|
9
|
+
export interface GitProvenance {
|
|
10
|
+
readonly root: string;
|
|
11
|
+
readonly remote?: string;
|
|
12
|
+
readonly branch?: string;
|
|
13
|
+
readonly commit?: string;
|
|
14
|
+
readonly dirty: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Git details for the source package, when it lives in a repo at all — an npm-installed
|
|
18
|
+
* package won't. `findGitRoot` is worktree-aware, which matters because a worktree's
|
|
19
|
+
* `.git` is a file rather than a directory.
|
|
20
|
+
*/
|
|
21
|
+
export declare function collectGitProvenance(pkgDir: string): GitProvenance | undefined;
|
|
22
|
+
/** Where the output folder goes: Downloads if the user has one, else a temp dir. */
|
|
23
|
+
export declare function defaultOutputParent(): string;
|
|
24
|
+
/** A folder name that sorts chronologically and survives every filesystem. */
|
|
25
|
+
export declare function buildOutputDirName({ pkgName, version, now, }: {
|
|
26
|
+
pkgName: string;
|
|
27
|
+
version?: string;
|
|
28
|
+
now?: Date;
|
|
29
|
+
}): string;
|
|
30
|
+
export interface BundleMetadata {
|
|
31
|
+
readonly bundledAt: string;
|
|
32
|
+
readonly bundler: {
|
|
33
|
+
readonly name: string;
|
|
34
|
+
readonly version: string;
|
|
35
|
+
};
|
|
36
|
+
readonly environment: {
|
|
37
|
+
readonly node: string;
|
|
38
|
+
readonly platform: string;
|
|
39
|
+
readonly release: string;
|
|
40
|
+
readonly arch: string;
|
|
41
|
+
};
|
|
42
|
+
readonly source: {
|
|
43
|
+
readonly name?: string;
|
|
44
|
+
readonly version?: string;
|
|
45
|
+
readonly origin: SourceOrigin;
|
|
46
|
+
readonly git?: GitProvenance;
|
|
47
|
+
};
|
|
48
|
+
readonly entryPoints: readonly {
|
|
49
|
+
readonly subpath: string;
|
|
50
|
+
readonly emitted: string;
|
|
51
|
+
readonly fromSourceFile: string;
|
|
52
|
+
readonly fromWildcard: boolean;
|
|
53
|
+
readonly bin?: string;
|
|
54
|
+
readonly bytes?: number;
|
|
55
|
+
}[];
|
|
56
|
+
readonly dependencies: {
|
|
57
|
+
readonly declared: Record<string, string>;
|
|
58
|
+
readonly peer: Record<string, string>;
|
|
59
|
+
readonly inlined: readonly string[];
|
|
60
|
+
readonly external: readonly {
|
|
61
|
+
readonly name: string;
|
|
62
|
+
readonly version?: string;
|
|
63
|
+
readonly vendored: boolean;
|
|
64
|
+
readonly reason: string;
|
|
65
|
+
readonly explanation: string;
|
|
66
|
+
}[];
|
|
67
|
+
};
|
|
68
|
+
readonly verification: {
|
|
69
|
+
readonly chunksChecked: number;
|
|
70
|
+
readonly selfContained: boolean;
|
|
71
|
+
readonly importableEntries: readonly string[];
|
|
72
|
+
readonly importFailures: readonly {
|
|
73
|
+
readonly entry: string;
|
|
74
|
+
readonly message: string;
|
|
75
|
+
readonly expected: boolean;
|
|
76
|
+
}[];
|
|
77
|
+
};
|
|
78
|
+
readonly warnings: readonly BundleWarning[];
|
|
79
|
+
readonly notes: {
|
|
80
|
+
readonly hoistedUseClient: boolean;
|
|
81
|
+
readonly treeshake: string;
|
|
82
|
+
readonly minified: false;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export declare function buildMetadata({ pkgJson, origin, entries, externals, inlined, warnings, verifyReport, bundleDir, bundlerVersion, hadUseClientDirective, treeshake, }: {
|
|
86
|
+
pkgJson: SourcePackageJson;
|
|
87
|
+
origin: SourceOrigin;
|
|
88
|
+
entries: readonly EntryPoint[];
|
|
89
|
+
externals: readonly ExternalPackage[];
|
|
90
|
+
inlined: readonly string[];
|
|
91
|
+
warnings: readonly BundleWarning[];
|
|
92
|
+
verifyReport: VerifyReport;
|
|
93
|
+
bundleDir: string;
|
|
94
|
+
bundlerVersion: string;
|
|
95
|
+
hadUseClientDirective: boolean;
|
|
96
|
+
treeshake: string;
|
|
97
|
+
}): BundleMetadata;
|
|
98
|
+
export declare function writeMetadata({ outputDir, metadata, }: {
|
|
99
|
+
outputDir: string;
|
|
100
|
+
metadata: BundleMetadata;
|
|
101
|
+
}): void;
|
|
102
|
+
/**
|
|
103
|
+
* The README that ships inside the output folder. Written for whoever opens the folder
|
|
104
|
+
* next — which is usually not the person who made it — so it leads with what the thing
|
|
105
|
+
* is and what is missing from it, rather than how it was produced.
|
|
106
|
+
*/
|
|
107
|
+
export declare function renderBundleReadme(metadata: BundleMetadata): string;
|
|
108
|
+
export declare function writeBundleReadme({ outputDir, metadata, }: {
|
|
109
|
+
outputDir: string;
|
|
110
|
+
metadata: BundleMetadata;
|
|
111
|
+
}): void;
|
|
112
|
+
//# sourceMappingURL=metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,eAAe,EACrB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAoBD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,GACb,aAAa,GAAG,SAAS,CAkB3B;AAED,oFAAoF;AACpF,wBAAgB,mBAAmB,IAAI,MAAM,CAI5C;AAED,8EAA8E;AAC9E,wBAAgB,kBAAkB,CAAC,EACjC,OAAO,EACP,OAAO,EACP,GAAgB,GACjB,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,IAAI,CAAC;CACZ,GAAG,MAAM,CAIT;AAED,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,EAAE,CAAC;IAC3B,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IACnC,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG,cAAc,CA0DjB;AAED,wBAAgB,aAAa,CAAC,EAC5B,SAAS,EACT,QAAQ,GACT,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,cAAc,CAAC;CAC1B,GAAG,IAAI,CAKP;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAsInE;AAED,wBAAgB,iBAAiB,CAAC,EAChC,SAAS,EACT,QAAQ,GACT,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,cAAc,CAAC;CAC1B,GAAG,IAAI,CAEP"}
|
package/dist/metadata.js
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provenance. Whoever receives a bundle should be able to answer "what exactly is this,
|
|
3
|
+
* where did it come from, and what was left out" without asking the person who made it.
|
|
4
|
+
*/
|
|
5
|
+
import { execFileSync } from 'node:child_process';
|
|
6
|
+
import { existsSync, statSync, writeFileSync } from 'node:fs';
|
|
7
|
+
import { arch, homedir, platform, release } from 'node:os';
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { findGitRoot } from '@knapsack/file-utils';
|
|
10
|
+
import { EXTERNAL_REASON_LABELS, } from './types.js';
|
|
11
|
+
function gitOutput({ args, cwd, }) {
|
|
12
|
+
try {
|
|
13
|
+
return execFileSync('git', [...args], {
|
|
14
|
+
cwd,
|
|
15
|
+
encoding: 'utf8',
|
|
16
|
+
stdio: 'pipe',
|
|
17
|
+
}).trim();
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Git details for the source package, when it lives in a repo at all — an npm-installed
|
|
25
|
+
* package won't. `findGitRoot` is worktree-aware, which matters because a worktree's
|
|
26
|
+
* `.git` is a file rather than a directory.
|
|
27
|
+
*/
|
|
28
|
+
export function collectGitProvenance(pkgDir) {
|
|
29
|
+
const root = findGitRoot(pkgDir);
|
|
30
|
+
if (!root)
|
|
31
|
+
return undefined;
|
|
32
|
+
const commit = gitOutput({ args: ['rev-parse', 'HEAD'], cwd: root });
|
|
33
|
+
return {
|
|
34
|
+
root,
|
|
35
|
+
remote: gitOutput({ args: ['remote', 'get-url', 'origin'], cwd: root }) ||
|
|
36
|
+
undefined,
|
|
37
|
+
branch: gitOutput({ args: ['rev-parse', '--abbrev-ref', 'HEAD'], cwd: root }) ||
|
|
38
|
+
undefined,
|
|
39
|
+
commit: commit || undefined,
|
|
40
|
+
// Reported rather than judged: bundling a dirty tree is normal during development,
|
|
41
|
+
// but the recipient should know the commit alone doesn't reproduce the artifact.
|
|
42
|
+
dirty: gitOutput({ args: ['status', '--porcelain'], cwd: root }).length > 0,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** Where the output folder goes: Downloads if the user has one, else a temp dir. */
|
|
46
|
+
export function defaultOutputParent() {
|
|
47
|
+
const downloads = join(homedir(), 'Downloads');
|
|
48
|
+
if (existsSync(downloads))
|
|
49
|
+
return downloads;
|
|
50
|
+
return process.env.TMPDIR || '/tmp';
|
|
51
|
+
}
|
|
52
|
+
/** A folder name that sorts chronologically and survives every filesystem. */
|
|
53
|
+
export function buildOutputDirName({ pkgName, version, now = new Date(), }) {
|
|
54
|
+
const safeName = pkgName.replace(/^@/, '').replace(/[^a-zA-Z0-9._-]+/g, '-');
|
|
55
|
+
const stamp = now.toISOString().replace(/[:.]/g, '-').replace('Z', 'Z');
|
|
56
|
+
return `ks-bundle--${safeName}--${version ?? 'unknown'}--${stamp}`;
|
|
57
|
+
}
|
|
58
|
+
export function buildMetadata({ pkgJson, origin, entries, externals, inlined, warnings, verifyReport, bundleDir, bundlerVersion, hadUseClientDirective, treeshake, }) {
|
|
59
|
+
const pkgDir = origin.kind === 'directory'
|
|
60
|
+
? origin.path
|
|
61
|
+
: join(origin.installedTo, 'node_modules');
|
|
62
|
+
return {
|
|
63
|
+
bundledAt: new Date().toISOString(),
|
|
64
|
+
bundler: { name: '@knapsack/package-bundler', version: bundlerVersion },
|
|
65
|
+
environment: {
|
|
66
|
+
node: process.version,
|
|
67
|
+
platform: platform(),
|
|
68
|
+
release: release(),
|
|
69
|
+
arch: arch(),
|
|
70
|
+
},
|
|
71
|
+
source: {
|
|
72
|
+
name: pkgJson.name,
|
|
73
|
+
version: pkgJson.version,
|
|
74
|
+
origin,
|
|
75
|
+
git: collectGitProvenance(pkgDir),
|
|
76
|
+
},
|
|
77
|
+
entryPoints: entries.map((entry) => {
|
|
78
|
+
const emitted = `${entry.name}.mjs`;
|
|
79
|
+
const file = join(bundleDir, emitted);
|
|
80
|
+
return {
|
|
81
|
+
subpath: entry.subpath,
|
|
82
|
+
emitted,
|
|
83
|
+
fromSourceFile: entry.sourceFile,
|
|
84
|
+
fromWildcard: entry.fromWildcard,
|
|
85
|
+
...(entry.binName ? { bin: entry.binName } : {}),
|
|
86
|
+
...(existsSync(file) ? { bytes: statSync(file).size } : {}),
|
|
87
|
+
};
|
|
88
|
+
}),
|
|
89
|
+
dependencies: {
|
|
90
|
+
declared: pkgJson.dependencies ?? {},
|
|
91
|
+
peer: pkgJson.peerDependencies ?? {},
|
|
92
|
+
inlined,
|
|
93
|
+
external: externals.map((external) => ({
|
|
94
|
+
name: external.name,
|
|
95
|
+
version: external.version,
|
|
96
|
+
vendored: external.vendored,
|
|
97
|
+
reason: external.reason,
|
|
98
|
+
explanation: EXTERNAL_REASON_LABELS[external.reason],
|
|
99
|
+
})),
|
|
100
|
+
},
|
|
101
|
+
verification: {
|
|
102
|
+
chunksChecked: verifyReport.chunksChecked,
|
|
103
|
+
selfContained: verifyReport.leaked.length === 0,
|
|
104
|
+
importableEntries: verifyReport.importable,
|
|
105
|
+
importFailures: verifyReport.importFailures,
|
|
106
|
+
},
|
|
107
|
+
warnings,
|
|
108
|
+
notes: {
|
|
109
|
+
hoistedUseClient: hadUseClientDirective,
|
|
110
|
+
treeshake,
|
|
111
|
+
minified: false,
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export function writeMetadata({ outputDir, metadata, }) {
|
|
116
|
+
writeFileSync(join(outputDir, 'bundle-metadata.json'), `${JSON.stringify(metadata, null, 2)}\n`);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The README that ships inside the output folder. Written for whoever opens the folder
|
|
120
|
+
* next — which is usually not the person who made it — so it leads with what the thing
|
|
121
|
+
* is and what is missing from it, rather than how it was produced.
|
|
122
|
+
*/
|
|
123
|
+
export function renderBundleReadme(metadata) {
|
|
124
|
+
const { source, dependencies, verification, warnings, entryPoints } = metadata;
|
|
125
|
+
const externalNotVendored = dependencies.external.filter((item) => !item.vendored);
|
|
126
|
+
const vendored = dependencies.external.filter((item) => item.vendored);
|
|
127
|
+
const lines = [
|
|
128
|
+
`# Bundle of ${source.name ?? 'unknown package'}${source.version ? ` v${source.version}` : ''}`,
|
|
129
|
+
'',
|
|
130
|
+
'A self-contained copy of an already-built npm package, with its runtime dependencies',
|
|
131
|
+
'inlined. Produced by `@knapsack/package-bundler`. Not minified; not transpiled to an',
|
|
132
|
+
'older target.',
|
|
133
|
+
'',
|
|
134
|
+
'## What is in here',
|
|
135
|
+
'',
|
|
136
|
+
'| Path | What it is |',
|
|
137
|
+
'| --- | --- |',
|
|
138
|
+
'| `bundle/` | The package itself. This is the part you use. |',
|
|
139
|
+
'| `package.original.json` | The source package.json, verbatim. |',
|
|
140
|
+
'| `bundle-metadata.json` | Full machine-readable provenance. |',
|
|
141
|
+
'| `build-log.txt` | Everything the bundler printed, including all warnings. |',
|
|
142
|
+
'',
|
|
143
|
+
'## How to use it',
|
|
144
|
+
'',
|
|
145
|
+
'```bash',
|
|
146
|
+
'cd bundle',
|
|
147
|
+
`node -e "import('./${entryPoints.find((entry) => entry.subpath === '.')?.emitted ?? 'index.mjs'}').then(m => console.log(Object.keys(m)))"`,
|
|
148
|
+
'```',
|
|
149
|
+
'',
|
|
150
|
+
];
|
|
151
|
+
if (externalNotVendored.length > 0) {
|
|
152
|
+
lines.push('## You must provide these yourself', '', 'These were deliberately **not** inlined. Install them alongside the bundle:', '');
|
|
153
|
+
for (const item of externalNotVendored) {
|
|
154
|
+
lines.push(`- \`${item.name}\`${item.version ? ` (${item.version})` : ''} — ${item.explanation}`);
|
|
155
|
+
}
|
|
156
|
+
lines.push('');
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
lines.push('## Dependencies', '', 'Everything is inlined. Nothing needs installing.', '');
|
|
160
|
+
}
|
|
161
|
+
if (vendored.length > 0) {
|
|
162
|
+
lines.push('## Shipped as files rather than inlined', '', 'These could not be bundled, so their real directories were copied into', '`bundle/node_modules/`. They are present — no install needed.', '');
|
|
163
|
+
for (const item of vendored) {
|
|
164
|
+
lines.push(`- \`${item.name}\` — ${item.explanation}`);
|
|
165
|
+
}
|
|
166
|
+
lines.push('');
|
|
167
|
+
}
|
|
168
|
+
lines.push('## What was verified', '', `- ${verification.chunksChecked} emitted file(s) parsed by Node without error.`, `- Self-contained: **${verification.selfContained ? 'yes' : 'no'}** — every remaining import resolves to a Node built-in, a declared peer dependency, or a package shipped in \`bundle/node_modules/\`.`, `- Entry points that imported cleanly: ${verification.importableEntries.length} of ${entryPoints.length}.`, '');
|
|
169
|
+
if (verification.importFailures.length > 0) {
|
|
170
|
+
lines.push('Some entry points could not be imported in a plain Node process. For a UI', 'component library this is normal — the framework peer is intentionally absent and', 'components often touch browser globals at module scope.', '');
|
|
171
|
+
for (const failure of verification.importFailures) {
|
|
172
|
+
lines.push(`- \`${failure.entry}\` — ${failure.expected ? 'expected' : '**unexpected**'}: ${failure.message}`);
|
|
173
|
+
}
|
|
174
|
+
lines.push('');
|
|
175
|
+
}
|
|
176
|
+
if (metadata.notes.hoistedUseClient) {
|
|
177
|
+
lines.push('## `"use client"`', '', 'The source contained `"use client"` directives. Per-module directives cannot', 'survive being bundled into single files, so one directive was placed at the top of', 'each output file instead — the whole bundle is a client module.', '');
|
|
178
|
+
}
|
|
179
|
+
if (warnings.length > 0) {
|
|
180
|
+
lines.push(`## Warnings (${warnings.length})`, '');
|
|
181
|
+
for (const warning of warnings.slice(0, 25)) {
|
|
182
|
+
lines.push(`- **${warning.code}** — ${warning.message}`);
|
|
183
|
+
if (warning.hint)
|
|
184
|
+
lines.push(` - ${warning.hint}`);
|
|
185
|
+
}
|
|
186
|
+
if (warnings.length > 25) {
|
|
187
|
+
lines.push(`- …and ${warnings.length - 25} more; see \`build-log.txt\`.`);
|
|
188
|
+
}
|
|
189
|
+
lines.push('');
|
|
190
|
+
}
|
|
191
|
+
lines.push('## Provenance', '', `- Bundled at: ${metadata.bundledAt}`, `- Bundler: ${metadata.bundler.name} v${metadata.bundler.version}`, `- Node: ${metadata.environment.node} on ${metadata.environment.platform}/${metadata.environment.arch}`);
|
|
192
|
+
if (source.git) {
|
|
193
|
+
lines.push(`- Git: ${source.git.remote ?? '(no remote)'} @ ${source.git.branch ?? '(detached)'} ${source.git.commit?.slice(0, 12) ?? ''}${source.git.dirty ? ' (uncommitted changes present)' : ''}`);
|
|
194
|
+
}
|
|
195
|
+
if (source.origin.kind === 'npm') {
|
|
196
|
+
lines.push(`- Installed from npm: \`${source.origin.spec}\``);
|
|
197
|
+
}
|
|
198
|
+
lines.push('');
|
|
199
|
+
return lines.join('\n');
|
|
200
|
+
}
|
|
201
|
+
export function writeBundleReadme({ outputDir, metadata, }) {
|
|
202
|
+
writeFileSync(join(outputDir, 'README.md'), renderBundleReadme(metadata));
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|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AI,YAAY,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,EAAE,EAAE,CAC1L,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QACjC,KAAK,CAAC,IAAI,CAAC,2BAA2B,MAAM,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC;IAChE,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAEf,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,EAChC,SAAS,EACT,QAAQ,GAIT;IACC,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE,kBAAkB,CAAC,QAAQ,CAAC,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interactive question flow, and the validation shared with the non-interactive path.
|
|
3
|
+
*
|
|
4
|
+
* The validators live here rather than inside the prompt callbacks so the same rules
|
|
5
|
+
* apply whether an answer arrived by prompt or by flag. A CI run and a customer at a
|
|
6
|
+
* terminal get identical verdicts on the same input.
|
|
7
|
+
*/
|
|
8
|
+
import * as p from '@clack/prompts';
|
|
9
|
+
/** Everything the pipeline needs, once questions and flags are reconciled. */
|
|
10
|
+
export interface BundleOptions {
|
|
11
|
+
readonly source?: string;
|
|
12
|
+
readonly outDir?: string;
|
|
13
|
+
readonly entry: readonly string[];
|
|
14
|
+
readonly external: readonly string[];
|
|
15
|
+
readonly inline: readonly string[];
|
|
16
|
+
readonly strategy: 'inline' | 'vendor';
|
|
17
|
+
readonly treeshake: 'safe' | 'none';
|
|
18
|
+
readonly includePeerDeps: boolean;
|
|
19
|
+
readonly strict: boolean;
|
|
20
|
+
readonly force: boolean;
|
|
21
|
+
readonly telemetry: boolean;
|
|
22
|
+
readonly json: boolean;
|
|
23
|
+
readonly verbose: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** A validator returns an error message, or undefined when the value is fine. */
|
|
26
|
+
export type Validator<T> = (value: T) => string | undefined;
|
|
27
|
+
export declare const validateSource: Validator<string | undefined>;
|
|
28
|
+
export declare const validateOutDir: ({ force }: {
|
|
29
|
+
force: boolean;
|
|
30
|
+
}) => Validator<string | undefined>;
|
|
31
|
+
export declare const validateStrategy: Validator<string>;
|
|
32
|
+
export declare const validateTreeshake: Validator<string>;
|
|
33
|
+
/**
|
|
34
|
+
* Check everything we can before doing any work, and report all problems at once.
|
|
35
|
+
* Finding out about the third bad flag only after fixing the first two is a bad way to
|
|
36
|
+
* spend someone's afternoon.
|
|
37
|
+
*/
|
|
38
|
+
export declare function validateOptions(options: BundleOptions): void;
|
|
39
|
+
/**
|
|
40
|
+
* Fill in anything the flags didn't cover.
|
|
41
|
+
*
|
|
42
|
+
* With `--yes`, or with no TTY, this returns the flags untouched — a CI job or an agent
|
|
43
|
+
* must never block on a prompt it cannot answer. Defaults are all safe, so there is
|
|
44
|
+
* nothing a prompt could ask that would stop the run.
|
|
45
|
+
*/
|
|
46
|
+
export declare function collectAnswers({ options, suggestedOutDir, packageLabel, }: {
|
|
47
|
+
options: BundleOptions;
|
|
48
|
+
/** Where output would go if the user doesn't choose. */
|
|
49
|
+
suggestedOutDir: string;
|
|
50
|
+
/** Name and version of what we're about to bundle, for confirmation. */
|
|
51
|
+
packageLabel: string;
|
|
52
|
+
}): Promise<BundleOptions>;
|
|
53
|
+
export declare const prompts: typeof p;
|
|
54
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;GAM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